@@ -141,6 +141,59 @@ static void initFromString(char*& dest, const cl::opt<std::string>& src) {
141141 }
142142}
143143
144+
145+ #if LDC_LLVM_VER >= 303
146+ static void hide (llvm::StringMap<cl::Option *>& map, const char * name) {
147+ // Check if option exists first for resilience against LLVM changes
148+ // between versions.
149+ if (map.count (name))
150+ map[name]->setHiddenFlag (cl::Hidden);
151+ }
152+
153+ // / Removes command line options exposed from within LLVM that are unlikely
154+ // / to be useful for end users from the -help output.
155+ static void hideLLVMOptions () {
156+ llvm::StringMap<cl::Option *> map;
157+ cl::getRegisteredOptions (map);
158+ hide (map, " bounds-checking-single-trap" );
159+ hide (map, " disable-spill-fusing" );
160+ hide (map, " enable-correct-eh-support" );
161+ hide (map, " enable-load-pre" );
162+ hide (map, " enable-objc-arc-opts" );
163+ hide (map, " enable-tbaa" );
164+ hide (map, " fatal-assembler-warnings" );
165+ hide (map, " internalize-public-api-file" );
166+ hide (map, " internalize-public-api-list" );
167+ hide (map, " join-liveintervals" );
168+ hide (map, " limit-float-precision" );
169+ hide (map, " mc-x86-disable-arith-relaxation" );
170+ hide (map, " pre-RA-sched" );
171+ hide (map, " print-after-all" );
172+ hide (map, " print-before-all" );
173+ hide (map, " print-machineinstrs" );
174+ hide (map, " profile-estimator-loop-weight" );
175+ hide (map, " profile-estimator-loop-weight" );
176+ hide (map, " profile-file" );
177+ hide (map, " profile-info-file" );
178+ hide (map, " profile-verifier-noassert" );
179+ hide (map, " regalloc" );
180+ hide (map, " shrink-wrap" );
181+ hide (map, " spiller" );
182+ hide (map, " stats" );
183+ hide (map, " strip-debug" );
184+ hide (map, " struct-path-tbaa" );
185+ hide (map, " time-passes" );
186+ hide (map, " unit-at-a-time" );
187+ hide (map, " verify-dom-info" );
188+ hide (map, " verify-loop-info" );
189+ hide (map, " verify-regalloc" );
190+ hide (map, " verify-region-info" );
191+ hide (map, " verify-scev" );
192+ hide (map, " x86-early-ifcvt" );
193+ hide (map, " x86-use-vzeroupper" );
194+ }
195+ #endif
196+
144197int main (int argc, char **argv);
145198
146199// / Parses switches from the command line, any response files and the global
@@ -195,6 +248,9 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
195248
196249 // Handle fixed-up arguments!
197250 cl::SetVersionPrinter (&printVersion);
251+ #if LDC_LLVM_VER >= 303
252+ hideLLVMOptions ();
253+ #endif
198254 cl::ParseCommandLineOptions (final_args.size (), const_cast <char **>(&final_args[0 ]),
199255 " LDC - the LLVM D compiler\n "
200256#if LDC_LLVM_VER < 302
0 commit comments