driver/cl_options: Use array instead of a gazillion hide() function calls [nfc]

This commit is contained in:
David Nadlinger 2017-02-10 00:09:08 +01:00
parent 72504cb7e5
commit d3b553bba5

View file

@ -546,79 +546,65 @@ void createClashingOptions() {
/// Hides command line options exposed from within LLVM that are unlikely /// Hides command line options exposed from within LLVM that are unlikely
/// to be useful for end users from the -help output. /// to be useful for end users from the -help output.
void hideLLVMOptions() { void hideLLVMOptions() {
#if LDC_LLVM_VER >= 307 static const char *const hiddenOptions[] = {
llvm::StringMap<cl::Option *> &map = cl::getRegisteredOptions(); "bounds-checking-single-trap",
#else "disable-debug-info-verifier",
llvm::StringMap<cl::Option *> map; "disable-objc-arc-checkforcfghazards",
cl::getRegisteredOptions(map); "disable-spill-fusing",
#endif "cppfname",
"cppfor",
auto hide = [&map](const char *name) { "cppgen",
// Check if option exists first for resilience against LLVM changes "enable-correct-eh-support",
// between versions. "enable-load-pre",
if (map.count(name)) { "enable-misched",
map[name]->setHiddenFlag(cl::Hidden); "enable-objc-arc-annotations",
} "enable-objc-arc-opts",
}; "enable-scoped-noalias",
"enable-tbaa",
hide("bounds-checking-single-trap"); "exhaustive-register-search",
hide("disable-debug-info-verifier"); "fatal-assembler-warnings",
hide("disable-objc-arc-checkforcfghazards"); "internalize-public-api-file",
hide("disable-spill-fusing"); "internalize-public-api-list",
hide("cppfname"); "join-liveintervals",
hide("cppfor"); "limit-float-precision",
hide("cppgen"); "mc-x86-disable-arith-relaxation",
hide("enable-correct-eh-support"); "mips16-constant-islands",
hide("enable-load-pre"); "mips16-hard-float",
hide("enable-misched"); "mlsm",
hide("enable-objc-arc-annotations"); "mno-ldc1-sdc1",
hide("enable-objc-arc-opts"); "nvptx-sched4reg",
hide("enable-scoped-noalias"); "no-discriminators",
hide("enable-tbaa"); "objc-arc-annotation-target-identifier",
hide("exhaustive-register-search"); "pre-RA-sched",
hide("fatal-assembler-warnings"); "print-after-all",
hide("internalize-public-api-file"); "print-before-all",
hide("internalize-public-api-list"); "print-machineinstrs",
hide("join-liveintervals"); "profile-estimator-loop-weight",
hide("limit-float-precision"); "profile-estimator-loop-weight",
hide("mc-x86-disable-arith-relaxation"); "profile-file",
hide("mips16-constant-islands"); "profile-info-file",
hide("mips16-hard-float"); "profile-verifier-noassert",
hide("mlsm"); "regalloc",
hide("mno-ldc1-sdc1"); "rewrite-map-file",
hide("nvptx-sched4reg"); "rng-seed",
hide("no-discriminators"); "sample-profile-max-propagate-iterations",
hide("objc-arc-annotation-target-identifier"); "shrink-wrap",
hide("pre-RA-sched"); "spiller",
hide("print-after-all"); "stackmap-version",
hide("print-before-all"); "stats",
hide("print-machineinstrs"); "strip-debug",
hide("profile-estimator-loop-weight"); "struct-path-tbaa",
hide("profile-estimator-loop-weight"); "time-passes",
hide("profile-file"); "unit-at-a-time",
hide("profile-info-file"); "verify-debug-info",
hide("profile-verifier-noassert"); "verify-dom-info",
hide("regalloc"); "verify-loop-info",
hide("rewrite-map-file"); "verify-regalloc",
hide("rng-seed"); "verify-region-info",
hide("sample-profile-max-propagate-iterations"); "verify-scev",
hide("shrink-wrap"); "x86-early-ifcvt",
hide("spiller"); "x86-use-vzeroupper",
hide("stackmap-version"); "x86-recip-refinement-steps",
hide("stats");
hide("strip-debug");
hide("struct-path-tbaa");
hide("time-passes");
hide("unit-at-a-time");
hide("verify-debug-info");
hide("verify-dom-info");
hide("verify-loop-info");
hide("verify-regalloc");
hide("verify-region-info");
hide("verify-scev");
hide("x86-early-ifcvt");
hide("x86-use-vzeroupper");
hide("x86-recip-refinement-steps");
// We enable -fdata-sections/-ffunction-sections by default where it makes // We enable -fdata-sections/-ffunction-sections by default where it makes
// sense for reducing code size, so hide them to avoid confusion. // sense for reducing code size, so hide them to avoid confusion.
@ -627,8 +613,24 @@ void hideLLVMOptions() {
// static TargetMachine members, but the default we want to use depends // static TargetMachine members, but the default we want to use depends
// on the target triple (and thus we do not know it until after the command // on the target triple (and thus we do not know it until after the command
// line has been parsed). // line has been parsed).
hide("fdata-sections"); "fdata-sections",
hide("ffunction-sections"); "ffunction-sections"
};
#if LDC_LLVM_VER >= 307
llvm::StringMap<cl::Option *> &map = cl::getRegisteredOptions();
#else
llvm::StringMap<cl::Option *> map;
cl::getRegisteredOptions(map);
#endif
for (const auto name : hiddenOptions) {
// Check if option exists first for resilience against LLVM changes
// between versions.
if (map.count(name)) {
map[name]->setHiddenFlag(cl::Hidden);
}
}
} }
} // namespace opts } // namespace opts