blob: 7c716406ce0a874a2162e500bd8791cfce2b29d1 [file] [log] [blame]
Daniel Dunbarf89a32a2009-11-10 19:51:53 +00001//===--- Options.cpp - clang-cc Option Handling ---------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// This file contains "pure" option handling, it is only responsible for turning
11// the options into internal *Option classes, but shouldn't have any other
12// logic.
13
14#include "Options.h"
Daniel Dunbard2cfa012009-11-11 08:13:55 +000015#include "clang/Basic/LangOptions.h"
16#include "clang/Basic/TargetInfo.h"
17#include "clang/Frontend/AnalysisConsumer.h"
Daniel Dunbarf89a32a2009-11-10 19:51:53 +000018#include "clang/Frontend/CompileOptions.h"
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +000019#include "clang/Frontend/DependencyOutputOptions.h"
Daniel Dunbardcd40fb2009-11-11 08:13:40 +000020#include "clang/Frontend/DiagnosticOptions.h"
Daniel Dunbarf527a122009-11-11 08:13:32 +000021#include "clang/Frontend/HeaderSearchOptions.h"
Daniel Dunbar999215c2009-11-11 06:10:03 +000022#include "clang/Frontend/PCHReader.h"
23#include "clang/Frontend/PreprocessorOptions.h"
Daniel Dunbar22bdabf2009-11-11 10:07:44 +000024#include "clang/Frontend/PreprocessorOutputOptions.h"
Daniel Dunbar999215c2009-11-11 06:10:03 +000025#include "llvm/ADT/STLExtras.h"
Daniel Dunbarf89a32a2009-11-10 19:51:53 +000026#include "llvm/ADT/StringMap.h"
27#include "llvm/Support/CommandLine.h"
Dan Gohmanad5ef3d2009-11-10 21:21:27 +000028#include <stdio.h>
Daniel Dunbarf89a32a2009-11-10 19:51:53 +000029
30using namespace clang;
31
32//===----------------------------------------------------------------------===//
Daniel Dunbard2cfa012009-11-11 08:13:55 +000033// Analyzer Options
34//===----------------------------------------------------------------------===//
35
36namespace analyzeroptions {
37
38static llvm::cl::list<Analyses>
39AnalysisList(llvm::cl::desc("Source Code Analysis - Checks and Analyses"),
40llvm::cl::values(
41#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)\
42clEnumValN(NAME, CMDFLAG, DESC),
43#include "clang/Frontend/Analyses.def"
44clEnumValEnd));
45
46static llvm::cl::opt<AnalysisStores>
47AnalysisStoreOpt("analyzer-store",
48 llvm::cl::desc("Source Code Analysis - Abstract Memory Store Models"),
49 llvm::cl::init(BasicStoreModel),
50 llvm::cl::values(
51#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)\
52clEnumValN(NAME##Model, CMDFLAG, DESC),
53#include "clang/Frontend/Analyses.def"
54clEnumValEnd));
55
56static llvm::cl::opt<AnalysisConstraints>
57AnalysisConstraintsOpt("analyzer-constraints",
58 llvm::cl::desc("Source Code Analysis - Symbolic Constraint Engines"),
59 llvm::cl::init(RangeConstraintsModel),
60 llvm::cl::values(
61#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN)\
62clEnumValN(NAME##Model, CMDFLAG, DESC),
63#include "clang/Frontend/Analyses.def"
64clEnumValEnd));
65
66static llvm::cl::opt<AnalysisDiagClients>
67AnalysisDiagOpt("analyzer-output",
68 llvm::cl::desc("Source Code Analysis - Output Options"),
69 llvm::cl::init(PD_HTML),
70 llvm::cl::values(
71#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN, AUTOCREATE)\
72clEnumValN(PD_##NAME, CMDFLAG, DESC),
73#include "clang/Frontend/Analyses.def"
74clEnumValEnd));
75
76static llvm::cl::opt<bool>
77AnalyzeAll("analyzer-opt-analyze-headers",
78 llvm::cl::desc("Force the static analyzer to analyze "
79 "functions defined in header files"));
80
81static llvm::cl::opt<bool>
82AnalyzerDisplayProgress("analyzer-display-progress",
83 llvm::cl::desc("Emit verbose output about the analyzer's progress."));
84
85static llvm::cl::opt<std::string>
86AnalyzeSpecificFunction("analyze-function",
87 llvm::cl::desc("Run analysis on specific function"));
88
89static llvm::cl::opt<bool>
90EagerlyAssume("analyzer-eagerly-assume",
91 llvm::cl::init(false),
92 llvm::cl::desc("Eagerly assume the truth/falseness of some "
93 "symbolic constraints."));
94
95static llvm::cl::opt<bool>
96PurgeDead("analyzer-purge-dead",
97 llvm::cl::init(true),
98 llvm::cl::desc("Remove dead symbols, bindings, and constraints before"
99 " processing a statement."));
100
101static llvm::cl::opt<bool>
102TrimGraph("trim-egraph",
103 llvm::cl::desc("Only show error-related paths in the analysis graph"));
104
105static llvm::cl::opt<bool>
106VisualizeEGDot("analyzer-viz-egraph-graphviz",
107 llvm::cl::desc("Display exploded graph using GraphViz"));
108
109static llvm::cl::opt<bool>
110VisualizeEGUbi("analyzer-viz-egraph-ubigraph",
111 llvm::cl::desc("Display exploded graph using Ubigraph"));
112
113}
114
115void clang::InitializeAnalyzerOptions(AnalyzerOptions &Opts) {
116 using namespace analyzeroptions;
117 Opts.AnalysisList = AnalysisList;
118 Opts.AnalysisStoreOpt = AnalysisStoreOpt;
119 Opts.AnalysisConstraintsOpt = AnalysisConstraintsOpt;
120 Opts.AnalysisDiagOpt = AnalysisDiagOpt;
121 Opts.VisualizeEGDot = VisualizeEGDot;
122 Opts.VisualizeEGUbi = VisualizeEGUbi;
123 Opts.AnalyzeAll = AnalyzeAll;
124 Opts.AnalyzerDisplayProgress = AnalyzerDisplayProgress;
125 Opts.PurgeDead = PurgeDead;
126 Opts.EagerlyAssume = EagerlyAssume;
127 Opts.AnalyzeSpecificFunction = AnalyzeSpecificFunction;
128 Opts.TrimGraph = TrimGraph;
129}
130
131
132//===----------------------------------------------------------------------===//
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000133// Code Generation Options
134//===----------------------------------------------------------------------===//
135
136namespace codegenoptions {
137
138static llvm::cl::opt<bool>
139DisableLLVMOptimizations("disable-llvm-optzns",
140 llvm::cl::desc("Don't run LLVM optimization passes"));
141
142static llvm::cl::opt<bool>
143DisableRedZone("disable-red-zone",
144 llvm::cl::desc("Do not emit code that uses the red zone."),
145 llvm::cl::init(false));
146
147static llvm::cl::opt<bool>
148GenerateDebugInfo("g",
149 llvm::cl::desc("Generate source level debug information"));
150
151static llvm::cl::opt<bool>
152NoCommon("fno-common",
153 llvm::cl::desc("Compile common globals like normal definitions"),
154 llvm::cl::ValueDisallowed);
155
156static llvm::cl::opt<bool>
157NoImplicitFloat("no-implicit-float",
158 llvm::cl::desc("Don't generate implicit floating point instructions (x86-only)"),
159 llvm::cl::init(false));
160
161static llvm::cl::opt<bool>
162NoMergeConstants("fno-merge-all-constants",
163 llvm::cl::desc("Disallow merging of constants."));
164
165// It might be nice to add bounds to the CommandLine library directly.
166struct OptLevelParser : public llvm::cl::parser<unsigned> {
167 bool parse(llvm::cl::Option &O, llvm::StringRef ArgName,
168 llvm::StringRef Arg, unsigned &Val) {
169 if (llvm::cl::parser<unsigned>::parse(O, ArgName, Arg, Val))
170 return true;
171 if (Val > 3)
172 return O.error("'" + Arg + "' invalid optimization level!");
173 return false;
174 }
175};
176static llvm::cl::opt<unsigned, false, OptLevelParser>
177OptLevel("O", llvm::cl::Prefix,
178 llvm::cl::desc("Optimization level"),
179 llvm::cl::init(0));
180
181static llvm::cl::opt<bool>
182OptSize("Os", llvm::cl::desc("Optimize for size"));
183
184static llvm::cl::opt<std::string>
185TargetCPU("mcpu",
186 llvm::cl::desc("Target a specific cpu type (-mcpu=help for details)"));
187
188static llvm::cl::list<std::string>
189TargetFeatures("target-feature", llvm::cl::desc("Target specific attributes"));
190
191}
192
193//===----------------------------------------------------------------------===//
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +0000194// Dependency Output Options
195//===----------------------------------------------------------------------===//
196
197namespace dependencyoutputoptions {
198
199static llvm::cl::opt<std::string>
200DependencyFile("dependency-file",
201 llvm::cl::desc("Filename (or -) to write dependency output to"));
202
203static llvm::cl::opt<bool>
204DependenciesIncludeSystemHeaders("sys-header-deps",
205 llvm::cl::desc("Include system headers in dependency output"));
206
207static llvm::cl::list<std::string>
208DependencyTargets("MT",
209 llvm::cl::desc("Specify target for dependency"));
210
211static llvm::cl::opt<bool>
212PhonyDependencyTarget("MP",
213 llvm::cl::desc("Create phony target for each dependency "
214 "(other than main file)"));
215
216}
217
218//===----------------------------------------------------------------------===//
Daniel Dunbardcd40fb2009-11-11 08:13:40 +0000219// Diagnostic Options
220//===----------------------------------------------------------------------===//
221
222namespace diagnosticoptions {
223
Daniel Dunbar8fd69a02009-11-12 07:28:21 +0000224static llvm::cl::opt<std::string>
225DumpBuildInformation("dump-build-information",
226 llvm::cl::value_desc("filename"),
227 llvm::cl::desc("output a dump of some build information to a file"));
228
Daniel Dunbardcd40fb2009-11-11 08:13:40 +0000229static llvm::cl::opt<bool>
230NoShowColumn("fno-show-column",
231 llvm::cl::desc("Do not include column number on diagnostics"));
232
233static llvm::cl::opt<bool>
234NoShowLocation("fno-show-source-location",
235 llvm::cl::desc("Do not include source location information with"
236 " diagnostics"));
237
238static llvm::cl::opt<bool>
239NoCaretDiagnostics("fno-caret-diagnostics",
240 llvm::cl::desc("Do not include source line and caret with"
241 " diagnostics"));
242
243static llvm::cl::opt<bool>
244NoDiagnosticsFixIt("fno-diagnostics-fixit-info",
245 llvm::cl::desc("Do not include fixit information in"
246 " diagnostics"));
247
248static llvm::cl::opt<bool>
249PrintSourceRangeInfo("fdiagnostics-print-source-range-info",
250 llvm::cl::desc("Print source range spans in numeric form"));
251
252static llvm::cl::opt<bool>
253PrintDiagnosticOption("fdiagnostics-show-option",
254 llvm::cl::desc("Print diagnostic name with mappable diagnostics"));
255
256static llvm::cl::opt<unsigned>
257MessageLength("fmessage-length",
258 llvm::cl::desc("Format message diagnostics so that they fit "
259 "within N columns or fewer, when possible."),
260 llvm::cl::value_desc("N"));
261
262static llvm::cl::opt<bool>
263PrintColorDiagnostic("fcolor-diagnostics",
264 llvm::cl::desc("Use colors in diagnostics"));
265
266}
267
268//===----------------------------------------------------------------------===//
Daniel Dunbar84dfbfd2009-11-11 07:26:12 +0000269// Language Options
270//===----------------------------------------------------------------------===//
271
272namespace langoptions {
273
274static llvm::cl::opt<bool>
275AllowBuiltins("fbuiltin", llvm::cl::init(true),
276 llvm::cl::desc("Disable implicit builtin knowledge of functions"));
277
278static llvm::cl::opt<bool>
279AltiVec("faltivec", llvm::cl::desc("Enable AltiVec vector initializer syntax"),
280 llvm::cl::init(false));
281
282static llvm::cl::opt<bool>
283AccessControl("faccess-control",
284 llvm::cl::desc("Enable C++ access control"));
285
286static llvm::cl::opt<bool>
287CharIsSigned("fsigned-char",
288 llvm::cl::desc("Force char to be a signed/unsigned type"));
289
290static llvm::cl::opt<bool>
291DollarsInIdents("fdollars-in-identifiers",
292 llvm::cl::desc("Allow '$' in identifiers"));
293
294static llvm::cl::opt<bool>
295EmitAllDecls("femit-all-decls",
296 llvm::cl::desc("Emit all declarations, even if unused"));
297
298static llvm::cl::opt<bool>
299EnableBlocks("fblocks", llvm::cl::desc("enable the 'blocks' language feature"));
300
301static llvm::cl::opt<bool>
302EnableHeinousExtensions("fheinous-gnu-extensions",
303 llvm::cl::desc("enable GNU extensions that you really really shouldn't use"),
304 llvm::cl::ValueDisallowed, llvm::cl::Hidden);
305
306static llvm::cl::opt<bool>
307Exceptions("fexceptions",
308 llvm::cl::desc("Enable support for exception handling"));
309
310static llvm::cl::opt<bool>
311Freestanding("ffreestanding",
312 llvm::cl::desc("Assert that the compilation takes place in a "
313 "freestanding environment"));
314
315static llvm::cl::opt<bool>
316GNURuntime("fgnu-runtime",
317 llvm::cl::desc("Generate output compatible with the standard GNU "
318 "Objective-C runtime"));
319
320/// LangStds - Language standards we support.
321enum LangStds {
322 lang_unspecified,
323 lang_c89, lang_c94, lang_c99,
324 lang_gnu89, lang_gnu99,
325 lang_cxx98, lang_gnucxx98,
326 lang_cxx0x, lang_gnucxx0x
327};
328static llvm::cl::opt<LangStds>
329LangStd("std", llvm::cl::desc("Language standard to compile for"),
330 llvm::cl::init(lang_unspecified),
331 llvm::cl::values(clEnumValN(lang_c89, "c89", "ISO C 1990"),
332 clEnumValN(lang_c89, "c90", "ISO C 1990"),
333 clEnumValN(lang_c89, "iso9899:1990", "ISO C 1990"),
334 clEnumValN(lang_c94, "iso9899:199409",
335 "ISO C 1990 with amendment 1"),
336 clEnumValN(lang_c99, "c99", "ISO C 1999"),
337 clEnumValN(lang_c99, "c9x", "ISO C 1999"),
338 clEnumValN(lang_c99, "iso9899:1999", "ISO C 1999"),
339 clEnumValN(lang_c99, "iso9899:199x", "ISO C 1999"),
340 clEnumValN(lang_gnu89, "gnu89",
341 "ISO C 1990 with GNU extensions"),
342 clEnumValN(lang_gnu99, "gnu99",
343 "ISO C 1999 with GNU extensions (default for C)"),
344 clEnumValN(lang_gnu99, "gnu9x",
345 "ISO C 1999 with GNU extensions"),
346 clEnumValN(lang_cxx98, "c++98",
347 "ISO C++ 1998 with amendments"),
348 clEnumValN(lang_gnucxx98, "gnu++98",
349 "ISO C++ 1998 with amendments and GNU "
350 "extensions (default for C++)"),
351 clEnumValN(lang_cxx0x, "c++0x",
352 "Upcoming ISO C++ 200x with amendments"),
353 clEnumValN(lang_gnucxx0x, "gnu++0x",
354 "Upcoming ISO C++ 200x with amendments and GNU "
355 "extensions"),
356 clEnumValEnd));
357
358static llvm::cl::opt<bool>
359MSExtensions("fms-extensions",
360 llvm::cl::desc("Accept some non-standard constructs used in "
361 "Microsoft header files "));
362
363static llvm::cl::opt<std::string>
364MainFileName("main-file-name",
365 llvm::cl::desc("Main file name to use for debug info"));
366
367static llvm::cl::opt<bool>
368MathErrno("fmath-errno", llvm::cl::init(true),
369 llvm::cl::desc("Require math functions to respect errno"));
370
371static llvm::cl::opt<bool>
372NeXTRuntime("fnext-runtime",
373 llvm::cl::desc("Generate output compatible with the NeXT "
374 "runtime"));
375
376static llvm::cl::opt<bool>
377NoElideConstructors("fno-elide-constructors",
378 llvm::cl::desc("Disable C++ copy constructor elision"));
379
380static llvm::cl::opt<bool>
381NoLaxVectorConversions("fno-lax-vector-conversions",
382 llvm::cl::desc("Disallow implicit conversions between "
383 "vectors with a different number of "
384 "elements or different element types"));
385
386
387static llvm::cl::opt<bool>
388NoOperatorNames("fno-operator-names",
389 llvm::cl::desc("Do not treat C++ operator name keywords as "
390 "synonyms for operators"));
391
392static llvm::cl::opt<std::string>
393ObjCConstantStringClass("fconstant-string-class",
394 llvm::cl::value_desc("class name"),
395 llvm::cl::desc("Specify the class to use for constant "
396 "Objective-C string objects."));
397
398static llvm::cl::opt<bool>
399ObjCEnableGC("fobjc-gc",
400 llvm::cl::desc("Enable Objective-C garbage collection"));
401
402static llvm::cl::opt<bool>
403ObjCExclusiveGC("fobjc-gc-only",
404 llvm::cl::desc("Use GC exclusively for Objective-C related "
405 "memory management"));
406
407static llvm::cl::opt<bool>
408ObjCEnableGCBitmapPrint("print-ivar-layout",
409 llvm::cl::desc("Enable Objective-C Ivar layout bitmap print trace"));
410
411static llvm::cl::opt<bool>
412ObjCNonFragileABI("fobjc-nonfragile-abi",
413 llvm::cl::desc("enable objective-c's nonfragile abi"));
414
415static llvm::cl::opt<bool>
416OverflowChecking("ftrapv",
417 llvm::cl::desc("Trap on integer overflow"),
418 llvm::cl::init(false));
419
420static llvm::cl::opt<unsigned>
421PICLevel("pic-level", llvm::cl::desc("Value for __PIC__"));
422
423static llvm::cl::opt<bool>
424PThread("pthread", llvm::cl::desc("Support POSIX threads in generated code"),
425 llvm::cl::init(false));
426
427static llvm::cl::opt<bool>
428PascalStrings("fpascal-strings",
429 llvm::cl::desc("Recognize and construct Pascal-style "
430 "string literals"));
431
Daniel Dunbar84dfbfd2009-11-11 07:26:12 +0000432static llvm::cl::opt<bool>
433Rtti("frtti", llvm::cl::init(true),
434 llvm::cl::desc("Enable generation of rtti information"));
435
436static llvm::cl::opt<bool>
437ShortWChar("fshort-wchar",
438 llvm::cl::desc("Force wchar_t to be a short unsigned int"));
439
440static llvm::cl::opt<bool>
441StaticDefine("static-define", llvm::cl::desc("Should __STATIC__ be defined"));
442
443static llvm::cl::opt<int>
444StackProtector("stack-protector",
445 llvm::cl::desc("Enable stack protectors"),
446 llvm::cl::init(-1));
447
448static llvm::cl::opt<LangOptions::VisibilityMode>
449SymbolVisibility("fvisibility",
450 llvm::cl::desc("Set the default symbol visibility:"),
451 llvm::cl::init(LangOptions::Default),
452 llvm::cl::values(clEnumValN(LangOptions::Default, "default",
453 "Use default symbol visibility"),
454 clEnumValN(LangOptions::Hidden, "hidden",
455 "Use hidden symbol visibility"),
456 clEnumValN(LangOptions::Protected,"protected",
457 "Use protected symbol visibility"),
458 clEnumValEnd));
459
460static llvm::cl::opt<unsigned>
461TemplateDepth("ftemplate-depth", llvm::cl::init(99),
462 llvm::cl::desc("Maximum depth of recursive template "
463 "instantiation"));
464
465static llvm::cl::opt<bool>
466Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences"));
467
468static llvm::cl::opt<bool>
469WritableStrings("fwritable-strings",
470 llvm::cl::desc("Store string literals as writable data"));
471
472}
473
474//===----------------------------------------------------------------------===//
Daniel Dunbar999215c2009-11-11 06:10:03 +0000475// General Preprocessor Options
476//===----------------------------------------------------------------------===//
477
478namespace preprocessoroptions {
479
480static llvm::cl::list<std::string>
481D_macros("D", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
482 llvm::cl::desc("Predefine the specified macro"));
483
484static llvm::cl::list<std::string>
485ImplicitIncludes("include", llvm::cl::value_desc("file"),
486 llvm::cl::desc("Include file before parsing"));
487static llvm::cl::list<std::string>
488ImplicitMacroIncludes("imacros", llvm::cl::value_desc("file"),
489 llvm::cl::desc("Include macros from file before parsing"));
490
491static llvm::cl::opt<std::string>
492ImplicitIncludePCH("include-pch", llvm::cl::value_desc("file"),
493 llvm::cl::desc("Include precompiled header file"));
494
495static llvm::cl::opt<std::string>
496ImplicitIncludePTH("include-pth", llvm::cl::value_desc("file"),
497 llvm::cl::desc("Include file before parsing"));
498
Daniel Dunbar29403032009-11-12 02:53:59 +0000499static llvm::cl::opt<std::string>
500TokenCache("token-cache", llvm::cl::value_desc("path"),
501 llvm::cl::desc("Use specified token cache file"));
502
Daniel Dunbar999215c2009-11-11 06:10:03 +0000503static llvm::cl::list<std::string>
504U_macros("U", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
505 llvm::cl::desc("Undefine the specified macro"));
506
507static llvm::cl::opt<bool>
508UndefMacros("undef", llvm::cl::value_desc("macro"),
509 llvm::cl::desc("undef all system defines"));
510
511}
512
513//===----------------------------------------------------------------------===//
Daniel Dunbarf527a122009-11-11 08:13:32 +0000514// Header Search Options
515//===----------------------------------------------------------------------===//
516
517namespace headersearchoptions {
518
519static llvm::cl::opt<bool>
520nostdinc("nostdinc", llvm::cl::desc("Disable standard #include directories"));
521
522static llvm::cl::opt<bool>
523nobuiltininc("nobuiltininc",
524 llvm::cl::desc("Disable builtin #include directories"));
525
526// Various command line options. These four add directories to each chain.
527static llvm::cl::list<std::string>
528F_dirs("F", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
529 llvm::cl::desc("Add directory to framework include search path"));
530
531static llvm::cl::list<std::string>
532I_dirs("I", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
533 llvm::cl::desc("Add directory to include search path"));
534
535static llvm::cl::list<std::string>
536idirafter_dirs("idirafter", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
537 llvm::cl::desc("Add directory to AFTER include search path"));
538
539static llvm::cl::list<std::string>
540iquote_dirs("iquote", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
541 llvm::cl::desc("Add directory to QUOTE include search path"));
542
543static llvm::cl::list<std::string>
544isystem_dirs("isystem", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
545 llvm::cl::desc("Add directory to SYSTEM include search path"));
546
547// These handle -iprefix/-iwithprefix/-iwithprefixbefore.
548static llvm::cl::list<std::string>
549iprefix_vals("iprefix", llvm::cl::value_desc("prefix"), llvm::cl::Prefix,
550 llvm::cl::desc("Set the -iwithprefix/-iwithprefixbefore prefix"));
551static llvm::cl::list<std::string>
552iwithprefix_vals("iwithprefix", llvm::cl::value_desc("dir"), llvm::cl::Prefix,
553 llvm::cl::desc("Set directory to SYSTEM include search path with prefix"));
554static llvm::cl::list<std::string>
555iwithprefixbefore_vals("iwithprefixbefore", llvm::cl::value_desc("dir"),
556 llvm::cl::Prefix,
557 llvm::cl::desc("Set directory to include search path with prefix"));
558
559static llvm::cl::opt<std::string>
560isysroot("isysroot", llvm::cl::value_desc("dir"), llvm::cl::init("/"),
561 llvm::cl::desc("Set the system root directory (usually /)"));
562
563}
564
565//===----------------------------------------------------------------------===//
Daniel Dunbar22bdabf2009-11-11 10:07:44 +0000566// Preprocessed Output Options
567//===----------------------------------------------------------------------===//
568
569namespace preprocessoroutputoptions {
570
571static llvm::cl::opt<bool>
572DisableLineMarkers("P", llvm::cl::desc("Disable linemarker output in -E mode"));
573
574static llvm::cl::opt<bool>
575EnableCommentOutput("C", llvm::cl::desc("Enable comment output in -E mode"));
576
577static llvm::cl::opt<bool>
578EnableMacroCommentOutput("CC",
579 llvm::cl::desc("Enable comment output in -E mode, "
580 "even from macro expansions"));
581static llvm::cl::opt<bool>
582DumpMacros("dM", llvm::cl::desc("Print macro definitions in -E mode instead of"
583 " normal output"));
584static llvm::cl::opt<bool>
585DumpDefines("dD", llvm::cl::desc("Print macro definitions in -E mode in "
586 "addition to normal output"));
587
588}
589
590//===----------------------------------------------------------------------===//
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000591// Option Object Construction
592//===----------------------------------------------------------------------===//
593
Daniel Dunbar979586e2009-11-11 09:38:56 +0000594void clang::InitializeCompileOptions(CompileOptions &Opts,
595 const TargetInfo &Target) {
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000596 using namespace codegenoptions;
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000597
Daniel Dunbar979586e2009-11-11 09:38:56 +0000598 // Compute the target features, we need the target to handle this because
599 // features may have dependencies on one another.
600 llvm::StringMap<bool> Features;
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000601 Target.getDefaultFeatures(TargetCPU, Features);
602
603 // Apply the user specified deltas.
604 for (llvm::cl::list<std::string>::iterator it = TargetFeatures.begin(),
605 ie = TargetFeatures.end(); it != ie; ++it) {
606 const char *Name = it->c_str();
607
608 // FIXME: Don't handle errors like this.
609 if (Name[0] != '-' && Name[0] != '+') {
610 fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n",
611 Name);
612 exit(1);
613 }
Daniel Dunbar979586e2009-11-11 09:38:56 +0000614
615 // Apply the feature via the target.
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000616 if (!Target.setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) {
617 fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n",
618 Name + 1);
619 exit(1);
620 }
621 }
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000622
Daniel Dunbar979586e2009-11-11 09:38:56 +0000623 // Add the features to the compile options.
624 //
625 // FIXME: If we are completely confident that we have the right set, we only
626 // need to pass the minuses.
627 for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
628 ie = Features.end(); it != ie; ++it)
629 Opts.Features.push_back(std::string(it->second ? "+" : "-") + it->first());
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000630
631 // -Os implies -O2
632 Opts.OptimizationLevel = OptSize ? 2 : OptLevel;
633
634 // We must always run at least the always inlining pass.
635 Opts.Inlining = (Opts.OptimizationLevel > 1) ? CompileOptions::NormalInlining
636 : CompileOptions::OnlyAlwaysInlining;
637
Daniel Dunbar979586e2009-11-11 09:38:56 +0000638 Opts.CPU = TargetCPU;
639 Opts.DebugInfo = GenerateDebugInfo;
640 Opts.DisableLLVMOpts = DisableLLVMOptimizations;
641 Opts.DisableRedZone = DisableRedZone;
642 Opts.MergeAllConstants = !NoMergeConstants;
643 Opts.NoCommon = NoCommon;
644 Opts.NoImplicitFloat = NoImplicitFloat;
645 Opts.OptimizeSize = OptSize;
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000646 Opts.SimplifyLibCalls = 1;
Daniel Dunbar979586e2009-11-11 09:38:56 +0000647 Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000648
649#ifdef NDEBUG
650 Opts.VerifyModule = 0;
651#endif
Daniel Dunbarf89a32a2009-11-10 19:51:53 +0000652}
Daniel Dunbar999215c2009-11-11 06:10:03 +0000653
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +0000654void clang::InitializeDependencyOutputOptions(DependencyOutputOptions &Opts) {
655 using namespace dependencyoutputoptions;
656
657 Opts.OutputFile = DependencyFile;
658 Opts.Targets.insert(Opts.Targets.begin(), DependencyTargets.begin(),
659 DependencyTargets.end());
660 Opts.IncludeSystemHeaders = DependenciesIncludeSystemHeaders;
661 Opts.UsePhonyTargets = PhonyDependencyTarget;
662}
663
Daniel Dunbardcd40fb2009-11-11 08:13:40 +0000664void clang::InitializeDiagnosticOptions(DiagnosticOptions &Opts) {
665 using namespace diagnosticoptions;
666
Daniel Dunbar8fd69a02009-11-12 07:28:21 +0000667 Opts.DumpBuildInformation = DumpBuildInformation;
Daniel Dunbardcd40fb2009-11-11 08:13:40 +0000668 Opts.MessageLength = MessageLength;
Daniel Dunbar8fd69a02009-11-12 07:28:21 +0000669 Opts.ShowCarets = !NoCaretDiagnostics;
670 Opts.ShowColors = PrintColorDiagnostic;
671 Opts.ShowColumn = !NoShowColumn;
672 Opts.ShowFixits = !NoDiagnosticsFixIt;
673 Opts.ShowLocation = !NoShowLocation;
674 Opts.ShowOptionNames = PrintDiagnosticOption;
675 Opts.ShowSourceRanges = PrintSourceRangeInfo;
Daniel Dunbardcd40fb2009-11-11 08:13:40 +0000676}
677
Daniel Dunbarf527a122009-11-11 08:13:32 +0000678void clang::InitializeHeaderSearchOptions(HeaderSearchOptions &Opts,
679 llvm::StringRef BuiltinIncludePath,
680 bool Verbose,
681 const LangOptions &Lang) {
682 using namespace headersearchoptions;
683
684 Opts.Sysroot = isysroot;
685 Opts.Verbose = Verbose;
686
687 // Handle -I... and -F... options, walking the lists in parallel.
688 unsigned Iidx = 0, Fidx = 0;
689 while (Iidx < I_dirs.size() && Fidx < F_dirs.size()) {
690 if (I_dirs.getPosition(Iidx) < F_dirs.getPosition(Fidx)) {
691 Opts.AddPath(I_dirs[Iidx], frontend::Angled, false, true, false);
692 ++Iidx;
693 } else {
694 Opts.AddPath(F_dirs[Fidx], frontend::Angled, false, true, true);
695 ++Fidx;
696 }
697 }
698
699 // Consume what's left from whatever list was longer.
700 for (; Iidx != I_dirs.size(); ++Iidx)
701 Opts.AddPath(I_dirs[Iidx], frontend::Angled, false, true, false);
702 for (; Fidx != F_dirs.size(); ++Fidx)
703 Opts.AddPath(F_dirs[Fidx], frontend::Angled, false, true, true);
704
705 // Handle -idirafter... options.
706 for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i)
707 Opts.AddPath(idirafter_dirs[i], frontend::After,
708 false, true, false);
709
710 // Handle -iquote... options.
711 for (unsigned i = 0, e = iquote_dirs.size(); i != e; ++i)
712 Opts.AddPath(iquote_dirs[i], frontend::Quoted, false, true, false);
713
714 // Handle -isystem... options.
715 for (unsigned i = 0, e = isystem_dirs.size(); i != e; ++i)
716 Opts.AddPath(isystem_dirs[i], frontend::System, false, true, false);
717
718 // Walk the -iprefix/-iwithprefix/-iwithprefixbefore argument lists in
719 // parallel, processing the values in order of occurance to get the right
720 // prefixes.
721 {
722 std::string Prefix = ""; // FIXME: this isn't the correct default prefix.
723 unsigned iprefix_idx = 0;
724 unsigned iwithprefix_idx = 0;
725 unsigned iwithprefixbefore_idx = 0;
726 bool iprefix_done = iprefix_vals.empty();
727 bool iwithprefix_done = iwithprefix_vals.empty();
728 bool iwithprefixbefore_done = iwithprefixbefore_vals.empty();
729 while (!iprefix_done || !iwithprefix_done || !iwithprefixbefore_done) {
730 if (!iprefix_done &&
731 (iwithprefix_done ||
732 iprefix_vals.getPosition(iprefix_idx) <
733 iwithprefix_vals.getPosition(iwithprefix_idx)) &&
734 (iwithprefixbefore_done ||
735 iprefix_vals.getPosition(iprefix_idx) <
736 iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
737 Prefix = iprefix_vals[iprefix_idx];
738 ++iprefix_idx;
739 iprefix_done = iprefix_idx == iprefix_vals.size();
740 } else if (!iwithprefix_done &&
741 (iwithprefixbefore_done ||
742 iwithprefix_vals.getPosition(iwithprefix_idx) <
743 iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
744 Opts.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx],
745 frontend::System, false, false, false);
746 ++iwithprefix_idx;
747 iwithprefix_done = iwithprefix_idx == iwithprefix_vals.size();
748 } else {
749 Opts.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx],
750 frontend::Angled, false, false, false);
751 ++iwithprefixbefore_idx;
752 iwithprefixbefore_done =
753 iwithprefixbefore_idx == iwithprefixbefore_vals.size();
754 }
755 }
756 }
757
758 // Add CPATH environment paths.
759 if (const char *Env = getenv("CPATH"))
760 Opts.EnvIncPath = Env;
761
762 // Add language specific environment paths.
763 if (Lang.CPlusPlus && Lang.ObjC1) {
764 if (const char *Env = getenv("OBJCPLUS_INCLUDE_PATH"))
765 Opts.LangEnvIncPath = Env;
766 } else if (Lang.CPlusPlus) {
767 if (const char *Env = getenv("CPLUS_INCLUDE_PATH"))
768 Opts.LangEnvIncPath = Env;
769 } else if (Lang.ObjC1) {
770 if (const char *Env = getenv("OBJC_INCLUDE_PATH"))
771 Opts.LangEnvIncPath = Env;
772 } else {
773 if (const char *Env = getenv("C_INCLUDE_PATH"))
774 Opts.LangEnvIncPath = Env;
775 }
776
777 if (!nobuiltininc)
778 Opts.BuiltinIncludePath = BuiltinIncludePath;
779
780 Opts.UseStandardIncludes = !nostdinc;
781}
782
Daniel Dunbar999215c2009-11-11 06:10:03 +0000783void clang::InitializePreprocessorOptions(PreprocessorOptions &Opts) {
784 using namespace preprocessoroptions;
785
786 Opts.setImplicitPCHInclude(ImplicitIncludePCH);
787 Opts.setImplicitPTHInclude(ImplicitIncludePTH);
788
Daniel Dunbar29403032009-11-12 02:53:59 +0000789 // Select the token cache file, we don't support more than one currently so we
790 // can't have both an implicit-pth and a token cache file.
791 if (TokenCache.getPosition() && ImplicitIncludePTH.getPosition()) {
792 // FIXME: Don't fail like this.
793 fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
794 "options\n");
795 exit(1);
796 }
797 if (TokenCache.getPosition())
798 Opts.setTokenCache(TokenCache);
799 else
800 Opts.setTokenCache(ImplicitIncludePTH);
801
Daniel Dunbar999215c2009-11-11 06:10:03 +0000802 // Use predefines?
803 Opts.setUsePredefines(!UndefMacros);
804
805 // Add macros from the command line.
806 unsigned d = 0, D = D_macros.size();
807 unsigned u = 0, U = U_macros.size();
808 while (d < D || u < U) {
809 if (u == U || (d < D && D_macros.getPosition(d) < U_macros.getPosition(u)))
810 Opts.addMacroDef(D_macros[d++]);
811 else
812 Opts.addMacroUndef(U_macros[u++]);
813 }
814
815 // If -imacros are specified, include them now. These are processed before
816 // any -include directives.
817 for (unsigned i = 0, e = ImplicitMacroIncludes.size(); i != e; ++i)
818 Opts.addMacroInclude(ImplicitMacroIncludes[i]);
819
820 // Add the ordered list of -includes, sorting in the implicit include options
821 // at the appropriate location.
822 llvm::SmallVector<std::pair<unsigned, std::string*>, 8> OrderedPaths;
823 std::string OriginalFile;
824
825 if (!ImplicitIncludePTH.empty())
826 OrderedPaths.push_back(std::make_pair(ImplicitIncludePTH.getPosition(),
827 &ImplicitIncludePTH));
828 if (!ImplicitIncludePCH.empty()) {
829 OriginalFile = PCHReader::getOriginalSourceFile(ImplicitIncludePCH);
830 // FIXME: Don't fail like this.
831 if (OriginalFile.empty())
832 exit(1);
833 OrderedPaths.push_back(std::make_pair(ImplicitIncludePCH.getPosition(),
834 &OriginalFile));
835 }
836 for (unsigned i = 0, e = ImplicitIncludes.size(); i != e; ++i)
837 OrderedPaths.push_back(std::make_pair(ImplicitIncludes.getPosition(i),
838 &ImplicitIncludes[i]));
839 llvm::array_pod_sort(OrderedPaths.begin(), OrderedPaths.end());
840
841 for (unsigned i = 0, e = OrderedPaths.size(); i != e; ++i)
842 Opts.addInclude(*OrderedPaths[i].second);
843}
Daniel Dunbar84dfbfd2009-11-11 07:26:12 +0000844
845void clang::InitializeLangOptions(LangOptions &Options, LangKind LK,
846 TargetInfo &Target,
Daniel Dunbar979586e2009-11-11 09:38:56 +0000847 const CompileOptions &CompileOpts) {
Daniel Dunbar84dfbfd2009-11-11 07:26:12 +0000848 using namespace langoptions;
849
850 bool NoPreprocess = false;
851
852 switch (LK) {
853 default: assert(0 && "Unknown language kind!");
854 case langkind_asm_cpp:
855 Options.AsmPreprocessor = 1;
856 // FALLTHROUGH
857 case langkind_c_cpp:
858 NoPreprocess = true;
859 // FALLTHROUGH
860 case langkind_c:
861 // Do nothing.
862 break;
863 case langkind_cxx_cpp:
864 NoPreprocess = true;
865 // FALLTHROUGH
866 case langkind_cxx:
867 Options.CPlusPlus = 1;
868 break;
869 case langkind_objc_cpp:
870 NoPreprocess = true;
871 // FALLTHROUGH
872 case langkind_objc:
873 Options.ObjC1 = Options.ObjC2 = 1;
874 break;
875 case langkind_objcxx_cpp:
876 NoPreprocess = true;
877 // FALLTHROUGH
878 case langkind_objcxx:
879 Options.ObjC1 = Options.ObjC2 = 1;
880 Options.CPlusPlus = 1;
881 break;
882 case langkind_ocl:
883 Options.OpenCL = 1;
884 Options.AltiVec = 1;
885 Options.CXXOperatorNames = 1;
886 Options.LaxVectorConversions = 1;
887 break;
888 }
889
890 if (ObjCExclusiveGC)
891 Options.setGCMode(LangOptions::GCOnly);
892 else if (ObjCEnableGC)
893 Options.setGCMode(LangOptions::HybridGC);
894
895 if (ObjCEnableGCBitmapPrint)
896 Options.ObjCGCBitmapPrint = 1;
897
898 if (AltiVec)
899 Options.AltiVec = 1;
900
901 if (PThread)
902 Options.POSIXThreads = 1;
903
904 Options.setVisibilityMode(SymbolVisibility);
905 Options.OverflowChecking = OverflowChecking;
906
907
908 // Allow the target to set the default the language options as it sees fit.
909 Target.getDefaultLangOptions(Options);
910
911 // Pass the map of target features to the target for validation and
912 // processing.
Daniel Dunbar979586e2009-11-11 09:38:56 +0000913 Target.HandleTargetFeatures(CompileOpts.Features);
Daniel Dunbar84dfbfd2009-11-11 07:26:12 +0000914
915 if (LangStd == lang_unspecified) {
916 // Based on the base language, pick one.
917 switch (LK) {
918 case langkind_ast: assert(0 && "Invalid call for AST inputs");
919 case lang_unspecified: assert(0 && "Unknown base language");
920 case langkind_ocl:
921 LangStd = lang_c99;
922 break;
923 case langkind_c:
924 case langkind_asm_cpp:
925 case langkind_c_cpp:
926 case langkind_objc:
927 case langkind_objc_cpp:
928 LangStd = lang_gnu99;
929 break;
930 case langkind_cxx:
931 case langkind_cxx_cpp:
932 case langkind_objcxx:
933 case langkind_objcxx_cpp:
934 LangStd = lang_gnucxx98;
935 break;
936 }
937 }
938
939 switch (LangStd) {
940 default: assert(0 && "Unknown language standard!");
941
942 // Fall through from newer standards to older ones. This isn't really right.
943 // FIXME: Enable specifically the right features based on the language stds.
944 case lang_gnucxx0x:
945 case lang_cxx0x:
946 Options.CPlusPlus0x = 1;
947 // FALL THROUGH
948 case lang_gnucxx98:
949 case lang_cxx98:
950 Options.CPlusPlus = 1;
951 Options.CXXOperatorNames = !NoOperatorNames;
952 // FALL THROUGH.
953 case lang_gnu99:
954 case lang_c99:
955 Options.C99 = 1;
956 Options.HexFloats = 1;
957 // FALL THROUGH.
958 case lang_gnu89:
959 Options.BCPLComment = 1; // Only for C99/C++.
960 // FALL THROUGH.
961 case lang_c94:
962 Options.Digraphs = 1; // C94, C99, C++.
963 // FALL THROUGH.
964 case lang_c89:
965 break;
966 }
967
968 // GNUMode - Set if we're in gnu99, gnu89, gnucxx98, etc.
969 switch (LangStd) {
970 default: assert(0 && "Unknown language standard!");
971 case lang_gnucxx0x:
972 case lang_gnucxx98:
973 case lang_gnu99:
974 case lang_gnu89:
975 Options.GNUMode = 1;
976 break;
977 case lang_cxx0x:
978 case lang_cxx98:
979 case lang_c99:
980 case lang_c94:
981 case lang_c89:
982 Options.GNUMode = 0;
983 break;
984 }
985
986 if (Options.CPlusPlus) {
987 Options.C99 = 0;
988 Options.HexFloats = 0;
989 }
990
991 if (LangStd == lang_c89 || LangStd == lang_c94 || LangStd == lang_gnu89)
992 Options.ImplicitInt = 1;
993 else
994 Options.ImplicitInt = 0;
995
996 // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
997 // is specified, or -std is set to a conforming mode.
998 Options.Trigraphs = !Options.GNUMode;
999 if (Trigraphs.getPosition())
1000 Options.Trigraphs = Trigraphs; // Command line option wins if specified.
1001
1002 // If in a conformant language mode (e.g. -std=c99) Blocks defaults to off
1003 // even if they are normally on for the target. In GNU modes (e.g.
1004 // -std=gnu99) the default for blocks depends on the target settings.
1005 // However, blocks are not turned off when compiling Obj-C or Obj-C++ code.
1006 if (!Options.ObjC1 && !Options.GNUMode)
1007 Options.Blocks = 0;
1008
1009 // Default to not accepting '$' in identifiers when preprocessing assembler,
1010 // but do accept when preprocessing C. FIXME: these defaults are right for
1011 // darwin, are they right everywhere?
1012 Options.DollarIdents = LK != langkind_asm_cpp;
1013 if (DollarsInIdents.getPosition()) // Explicit setting overrides default.
1014 Options.DollarIdents = DollarsInIdents;
1015
1016 if (PascalStrings.getPosition())
1017 Options.PascalStrings = PascalStrings;
1018 if (MSExtensions.getPosition())
1019 Options.Microsoft = MSExtensions;
1020 Options.WritableStrings = WritableStrings;
1021 if (NoLaxVectorConversions.getPosition())
1022 Options.LaxVectorConversions = 0;
1023 Options.Exceptions = Exceptions;
1024 Options.Rtti = Rtti;
1025 if (EnableBlocks.getPosition())
1026 Options.Blocks = EnableBlocks;
1027 if (CharIsSigned.getPosition())
1028 Options.CharIsSigned = CharIsSigned;
1029 if (ShortWChar.getPosition())
1030 Options.ShortWChar = ShortWChar;
1031
1032 if (!AllowBuiltins)
1033 Options.NoBuiltin = 1;
1034 if (Freestanding)
1035 Options.Freestanding = Options.NoBuiltin = 1;
1036
1037 if (EnableHeinousExtensions)
1038 Options.HeinousExtensions = 1;
1039
1040 if (AccessControl)
1041 Options.AccessControl = 1;
1042
1043 Options.ElideConstructors = !NoElideConstructors;
1044
1045 // OpenCL and C++ both have bool, true, false keywords.
1046 Options.Bool = Options.OpenCL | Options.CPlusPlus;
1047
1048 Options.MathErrno = MathErrno;
1049
1050 Options.InstantiationDepth = TemplateDepth;
1051
1052 // Override the default runtime if the user requested it.
1053 if (NeXTRuntime)
1054 Options.NeXTRuntime = 1;
1055 else if (GNURuntime)
1056 Options.NeXTRuntime = 0;
1057
1058 if (!ObjCConstantStringClass.empty())
1059 Options.ObjCConstantStringClass = ObjCConstantStringClass.c_str();
1060
1061 if (ObjCNonFragileABI)
1062 Options.ObjCNonFragileABI = 1;
1063
1064 if (EmitAllDecls)
1065 Options.EmitAllDecls = 1;
1066
1067 // The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't support.
1068 Options.OptimizeSize = 0;
1069 Options.Optimize = !!CompileOpts.OptimizationLevel;
1070
1071 assert(PICLevel <= 2 && "Invalid value for -pic-level");
1072 Options.PICLevel = PICLevel;
1073
1074 Options.GNUInline = !Options.C99;
1075 // FIXME: This is affected by other options (-fno-inline).
1076
1077 // This is the __NO_INLINE__ define, which just depends on things like the
1078 // optimization level and -fno-inline, not actually whether the backend has
1079 // inlining enabled.
1080 Options.NoInline = !CompileOpts.OptimizationLevel;
1081
1082 Options.Static = StaticDefine;
1083
1084 switch (StackProtector) {
1085 default:
1086 assert(StackProtector <= 2 && "Invalid value for -stack-protector");
1087 case -1: break;
1088 case 0: Options.setStackProtectorMode(LangOptions::SSPOff); break;
1089 case 1: Options.setStackProtectorMode(LangOptions::SSPOn); break;
1090 case 2: Options.setStackProtectorMode(LangOptions::SSPReq); break;
1091 }
1092
1093 if (MainFileName.getPosition())
1094 Options.setMainFileName(MainFileName.c_str());
1095
1096 Target.setForcedLangOptions(Options);
1097}
Daniel Dunbar22bdabf2009-11-11 10:07:44 +00001098
1099void
1100clang::InitializePreprocessorOutputOptions(PreprocessorOutputOptions &Opts) {
1101 using namespace preprocessoroutputoptions;
1102
1103 Opts.ShowCPP = !DumpMacros;
1104 Opts.ShowMacros = DumpMacros || DumpDefines;
1105 Opts.ShowLineMarkers = !DisableLineMarkers;
1106 Opts.ShowComments = EnableCommentOutput;
1107 Opts.ShowMacroComments = EnableMacroCommentOutput;
1108}
1109