diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 07:23:38 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 07:23:38 +0000 |
commit | 5e96f9d983d3996d65c1ee85168dc2134f5132f1 (patch) | |
tree | 3520e4c5d068fe730c862e111de894f8979da91f | |
parent | 8fd57fea85ff7b4dc1895fbbdf73173feaa063b5 (diff) |
clang-cc: Move to CompilerInvocation based command line parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90426 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/clang-cc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tools/clang-cc/Options.cpp | 1283 | ||||
-rw-r--r-- | tools/clang-cc/Options.h | 54 | ||||
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 102 |
4 files changed, 3 insertions, 1437 deletions
diff --git a/tools/clang-cc/CMakeLists.txt b/tools/clang-cc/CMakeLists.txt index c96e8b1d06..5f302df3ed 100644 --- a/tools/clang-cc/CMakeLists.txt +++ b/tools/clang-cc/CMakeLists.txt @@ -24,7 +24,6 @@ set( LLVM_LINK_COMPONENTS add_clang_executable(clang-cc clang-cc.cpp - Options.cpp ) add_dependencies(clang-cc clang-headers) diff --git a/tools/clang-cc/Options.cpp b/tools/clang-cc/Options.cpp deleted file mode 100644 index 62fff38103..0000000000 --- a/tools/clang-cc/Options.cpp +++ /dev/null @@ -1,1283 +0,0 @@ -//===--- Options.cpp - clang-cc Option Handling ---------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// This file contains "pure" option handling, it is only responsible for turning -// the options into internal *Option classes, but shouldn't have any other -// logic. - -#include "Options.h" -#include "clang/Basic/LangOptions.h" -#include "clang/Basic/TargetInfo.h" -#include "clang/Basic/TargetOptions.h" -#include "clang/Frontend/AnalysisConsumer.h" -#include "clang/CodeGen/CodeGenOptions.h" -#include "clang/Frontend/DependencyOutputOptions.h" -#include "clang/Frontend/DiagnosticOptions.h" -#include "clang/Frontend/FrontendOptions.h" -#include "clang/Frontend/HeaderSearchOptions.h" -#include "clang/Frontend/LangStandard.h" -#include "clang/Frontend/PCHReader.h" -#include "clang/Frontend/PreprocessorOptions.h" -#include "clang/Frontend/PreprocessorOutputOptions.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/RegistryParser.h" -#include "llvm/System/Host.h" -#include <stdio.h> - -using namespace clang; - -//===----------------------------------------------------------------------===// -// Analyzer Options -//===----------------------------------------------------------------------===// - -namespace analyzeroptions { - -static llvm::cl::list<Analyses> -AnalysisList(llvm::cl::desc("Source Code Analysis - Checks and Analyses"), -llvm::cl::values( -#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)\ -clEnumValN(NAME, CMDFLAG, DESC), -#include "clang/Frontend/Analyses.def" -clEnumValEnd)); - -static llvm::cl::opt<AnalysisStores> -AnalysisStoreOpt("analyzer-store", - llvm::cl::desc("Source Code Analysis - Abstract Memory Store Models"), - llvm::cl::init(BasicStoreModel), - llvm::cl::values( -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)\ -clEnumValN(NAME##Model, CMDFLAG, DESC), -#include "clang/Frontend/Analyses.def" -clEnumValEnd)); - -static llvm::cl::opt<AnalysisConstraints> -AnalysisConstraintsOpt("analyzer-constraints", - llvm::cl::desc("Source Code Analysis - Symbolic Constraint Engines"), - llvm::cl::init(RangeConstraintsModel), - llvm::cl::values( -#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN)\ -clEnumValN(NAME##Model, CMDFLAG, DESC), -#include "clang/Frontend/Analyses.def" -clEnumValEnd)); - -static llvm::cl::opt<AnalysisDiagClients> -AnalysisDiagOpt("analyzer-output", - llvm::cl::desc("Source Code Analysis - Output Options"), - llvm::cl::init(PD_HTML), - llvm::cl::values( -#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN, AUTOCREATE)\ -clEnumValN(PD_##NAME, CMDFLAG, DESC), -#include "clang/Frontend/Analyses.def" -clEnumValEnd)); - -static llvm::cl::opt<bool> -AnalyzeAll("analyzer-opt-analyze-headers", - llvm::cl::desc("Force the static analyzer to analyze " - "functions defined in header files")); - -static llvm::cl::opt<bool> -AnalyzerDisplayProgress("analyzer-display-progress", - llvm::cl::desc("Emit verbose output about the analyzer's progress")); - -static llvm::cl::opt<bool> -AnalyzerExperimentalChecks("analyzer-experimental-checks", - llvm::cl::desc("Use experimental path-sensitive checks")); - -static llvm::cl::opt<bool> -AnalyzerExperimentalInternalChecks("analyzer-experimental-internal-checks", - llvm::cl::desc("Use new default path-sensitive checks currently in testing")); - -static llvm::cl::opt<std::string> -AnalyzeSpecificFunction("analyze-function", - llvm::cl::desc("Run analysis on specific function")); - -static llvm::cl::opt<bool> -EagerlyAssume("analyzer-eagerly-assume", - llvm::cl::desc("Eagerly assume the truth/falseness of some " - "symbolic constraints")); - -static llvm::cl::opt<bool> -NoPurgeDead("analyzer-no-purge-dead", - llvm::cl::desc("Don't remove dead symbols, bindings, and constraints before" - " processing a statement")); - -static llvm::cl::opt<bool> -TrimGraph("trim-egraph", - llvm::cl::desc("Only show error-related paths in the analysis graph")); - -static llvm::cl::opt<bool> -VisualizeEGDot("analyzer-viz-egraph-graphviz", - llvm::cl::desc("Display exploded graph using GraphViz")); - -static llvm::cl::opt<bool> -VisualizeEGUbi("analyzer-viz-egraph-ubigraph", - llvm::cl::desc("Display exploded graph using Ubigraph")); - -} - -//===----------------------------------------------------------------------===// -// Code Generation Options -//===----------------------------------------------------------------------===// - -namespace codegenoptions { - -static llvm::cl::opt<bool> -DisableLLVMOptimizations("disable-llvm-optzns", - llvm::cl::desc("Don't run LLVM optimization passes")); - -static llvm::cl::opt<bool> -DisableRedZone("disable-red-zone", - llvm::cl::desc("Do not emit code that uses the red zone.")); - -static llvm::cl::opt<bool> -GenerateDebugInfo("g", - llvm::cl::desc("Generate source level debug information")); - -static llvm::cl::opt<bool> -MAsmVerbose("masm-verbose", llvm::cl::desc("Generate verbose assembly output")); - -static llvm::cl::opt<std::string> -MCodeModel("mcode-model", llvm::cl::desc("The code model to use")); - -static llvm::cl::opt<std::string> -MDebugPass("mdebu-pass", llvm::cl::desc("Output additional debug information")); - -static llvm::cl::opt<bool> -MDisableFPElim("mdisable-fp-elim", - llvm::cl::desc("Disable frame pointer elimination optimization")); - -static llvm::cl::opt<std::string> -MFloatABI("mfloat-abi", llvm::cl::desc("The float ABI to use")); - -static llvm::cl::opt<std::string> -MLimitFloatPrecision("mlimit-float-precision", - llvm::cl::desc("Limit float precision to the given value")); - -static llvm::cl::opt<bool> -MNoZeroInitializedInBSS("mno-zero-initialized-in-bss", - llvm::cl::desc("Do not put zero initialized data in the BSS")); - -static llvm::cl::opt<bool> -MSoftFloat("msoft-float", llvm::cl::desc("Use software floating point")); - -static llvm::cl::opt<std::string> -MRelocationModel("mrelocation-model", - llvm::cl::desc("The relocation model to use"), - llvm::cl::init("pic")); - -static llvm::cl::opt<bool> -MUnwindTables("munwind-tables", - llvm::cl::desc("Generate unwinding tables for all functions")); - -static llvm::cl::opt<std::string> -MainFileName("main-file-name", - llvm::cl::desc("Main file name to use for debug info")); - -static llvm::cl::opt<bool> -NoCommon("fno-common", - llvm::cl::desc("Compile common globals like normal definitions"), - llvm::cl::ValueDisallowed); - -static llvm::cl::opt<bool> -NoImplicitFloat("no-implicit-float", - llvm::cl::desc("Don't generate implicit floating point instructions (x86-only)")); - -static llvm::cl::opt<bool> -NoMergeConstants("fno-merge-all-constants", - llvm::cl::desc("Disallow merging of constants.")); - -// It might be nice to add bounds to the CommandLine library directly. -struct OptLevelParser : public llvm::cl::parser<unsigned> { - bool parse(llvm::cl::Option &O, llvm::StringRef ArgName, - llvm::StringRef Arg, unsigned &Val) { - if (llvm::cl::parser<unsigned>::parse(O, ArgName, Arg, Val)) - return true; - if (Val > 3) - return O.error("'" + Arg + "' invalid optimization level!"); - return false; - } -}; -static llvm::cl::opt<unsigned, false, OptLevelParser> -OptLevel("O", llvm::cl::Prefix, - llvm::cl::desc("Optimization level")); - -static llvm::cl::opt<bool> -OptSize("Os", llvm::cl::desc("Optimize for size")); - -} - -//===----------------------------------------------------------------------===// -// Dependency Output Options -//===----------------------------------------------------------------------===// - -namespace dependencyoutputoptions { - -static llvm::cl::opt<std::string> -DependencyFile("dependency-file", - llvm::cl::desc("Filename (or -) to write dependency output to")); - -static llvm::cl::opt<bool> -DependenciesIncludeSystemHeaders("sys-header-deps", - llvm::cl::desc("Include system headers in dependency output")); - -static llvm::cl::list<std::string> -DependencyTargets("MT", - llvm::cl::desc("Specify target for dependency")); - -static llvm::cl::opt<bool> -PhonyDependencyTarget("MP", - llvm::cl::desc("Create phony target for each dependency " - "(other than main file)")); - -} - -//===----------------------------------------------------------------------===// -// Diagnostic Options -//===----------------------------------------------------------------------===// - -namespace diagnosticoptions { - -static llvm::cl::opt<std::string> -DumpBuildInformation("dump-build-information", - llvm::cl::value_desc("filename"), - llvm::cl::desc("output a dump of some build information to a file")); - -static llvm::cl::opt<bool> -NoShowColumn("fno-show-column", - llvm::cl::desc("Do not include column number on diagnostics")); - -static llvm::cl::opt<bool> -NoShowLocation("fno-show-source-location", - llvm::cl::desc("Do not include source location information with" - " diagnostics")); - -static llvm::cl::opt<bool> -NoCaretDiagnostics("fno-caret-diagnostics", - llvm::cl::desc("Do not include source line and caret with" - " diagnostics")); - -static llvm::cl::opt<bool> -NoDiagnosticsFixIt("fno-diagnostics-fixit-info", - llvm::cl::desc("Do not include fixit information in" - " diagnostics")); - -static llvm::cl::opt<bool> OptNoWarnings("w"); - -static llvm::cl::opt<bool> OptPedantic("pedantic"); - -static llvm::cl::opt<bool> OptPedanticErrors("pedantic-errors"); - -// This gets all -W options, including -Werror, -W[no-]system-headers, etc. The -// driver has stripped off -Wa,foo etc. The driver has also translated -W to -// -Wextra, so we don't need to worry about it. -static llvm::cl::list<std::string> -OptWarnings("W", llvm::cl::Prefix, llvm::cl::ValueOptional); - -static llvm::cl::opt<bool> -PrintSourceRangeInfo("fdiagnostics-print-source-range-info", - llvm::cl::desc("Print source range spans in numeric form")); - -static llvm::cl::opt<bool> -PrintDiagnosticOption("fdiagnostics-show-option", - llvm::cl::desc("Print diagnostic name with mappable diagnostics")); - -static llvm::cl::opt<unsigned> -MessageLength("fmessage-length", - llvm::cl::desc("Format message diagnostics so that they fit " - "within N columns or fewer, when possible."), - llvm::cl::value_desc("N")); - -static llvm::cl::opt<bool> -PrintColorDiagnostic("fcolor-diagnostics", - llvm::cl::desc("Use colors in diagnostics")); - -static llvm::cl::opt<bool> -SilenceRewriteMacroWarning("Wno-rewrite-macros", - llvm::cl::desc("Silence ObjC rewriting warnings")); - -static llvm::cl::opt<bool> -VerifyDiagnostics("verify", - llvm::cl::desc("Verify emitted diagnostics and warnings")); - -} - -//===----------------------------------------------------------------------===// -// Frontend Options -//===----------------------------------------------------------------------===// - -namespace frontendoptions { - -using namespace clang::frontend; - -static llvm::cl::opt<ParsedSourceLocation> -CodeCompletionAt("code-completion-at", - llvm::cl::value_desc("file:line:column"), - llvm::cl::desc("Dump code-completion information at a location")); - -static llvm::cl::opt<bool> -NoCodeCompletionDebugPrinter("no-code-completion-debug-printer", - llvm::cl::desc("Don't the \"debug\" code-completion print")); - -static llvm::cl::opt<bool> -CodeCompletionWantsMacros("code-completion-macros", - llvm::cl::desc("Include macros in code-completion results")); - -static llvm::cl::opt<bool> -DisableFree("disable-free", - llvm::cl::desc("Disable freeing of memory on exit")); - -static llvm::cl::opt<bool> -EmptyInputOnly("empty-input-only", - llvm::cl::desc("Force running on an empty input file")); - -static llvm::cl::opt<FrontendOptions::InputKind> -InputType("x", llvm::cl::desc("Input language type"), - llvm::cl::init(FrontendOptions::IK_None), - llvm::cl::values(clEnumValN(FrontendOptions::IK_C, "c", "C"), - clEnumValN(FrontendOptions::IK_OpenCL, "cl", "OpenCL C"), - clEnumValN(FrontendOptions::IK_CXX, "c++", "C++"), - clEnumValN(FrontendOptions::IK_ObjC, "objective-c", - "Objective C"), - clEnumValN(FrontendOptions::IK_ObjCXX, "objective-c++", - "Objective C++"), - clEnumValN(FrontendOptions::IK_PreprocessedC, - "cpp-output", - "Preprocessed C"), - clEnumValN(FrontendOptions::IK_Asm, - "assembler-with-cpp", - "Assembly Source Codde"), - clEnumValN(FrontendOptions::IK_PreprocessedCXX, - "c++-cpp-output", - "Preprocessed C++"), - clEnumValN(FrontendOptions::IK_PreprocessedObjC, - "objective-c-cpp-output", - "Preprocessed Objective C"), - clEnumValN(FrontendOptions::IK_PreprocessedObjCXX, - "objective-c++-cpp-output", - "Preprocessed Objective C++"), - clEnumValN(FrontendOptions::IK_C, "c-header", - "C header"), - clEnumValN(FrontendOptions::IK_ObjC, "objective-c-header", - "Objective-C header"), - clEnumValN(FrontendOptions::IK_CXX, "c++-header", - "C++ header"), - clEnumValN(FrontendOptions::IK_ObjCXX, - "objective-c++-header", - "Objective-C++ header"), - clEnumValN(FrontendOptions::IK_AST, "ast", - "Clang AST"), - clEnumValEnd)); - -static llvm::cl::list<std::string> -InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>")); - -static llvm::cl::opt<std::string> -InheritanceViewCls("cxx-inheritance-view", - llvm::cl::value_desc("class name"), - llvm::cl::desc("View C++ inheritance for a specified class")); - -static llvm::cl::list<ParsedSourceLocation> -FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"), - llvm::cl::desc("Perform Fix-It modifications at the given source location")); - -static llvm::cl::opt<std::string> -OutputFile("o", - llvm::cl::value_desc("path"), - llvm::cl::desc("Specify output file")); - -static llvm::cl::opt<std::string> -PluginActionName("plugin", - llvm::cl::desc("Use the named plugin action " - "(use \"help\" to list available options)")); - -static llvm::cl::opt<ActionKind> -ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, - llvm::cl::init(ParseSyntaxOnly), - llvm::cl::values( - clEnumValN(RunPreprocessorOnly, "Eonly", - "Just run preprocessor, no output (for timings)"), - clEnumValN(PrintPreprocessedInput, "E", - "Run preprocessor, emit preprocessed file"), - clEnumValN(DumpRawTokens, "dump-raw-tokens", - "Lex file in raw mode and dump raw tokens"), - clEnumValN(RunAnalysis, "analyze", - "Run static analysis engine"), - clEnumValN(DumpTokens, "dump-tokens", - "Run preprocessor, dump internal rep of tokens"), - clEnumValN(ParseNoop, "parse-noop", - "Run parser with noop callbacks (for timings)"), - clEnumValN(ParseSyntaxOnly, "fsyntax-only", - "Run parser and perform semantic analysis"), - clEnumValN(FixIt, "fixit", - "Apply fix-it advice to the input source"), - clEnumValN(ParsePrintCallbacks, "parse-print-callbacks", - "Run parser and print each callback invoked"), - clEnumValN(EmitHTML, "emit-html", - "Output input source as HTML"), - clEnumValN(ASTPrint, "ast-print", - "Build ASTs and then pretty-print them"), - clEnumValN(ASTPrintXML, "ast-print-xml", - "Build ASTs and then print them in XML format"), - clEnumValN(ASTDump, "ast-dump", - "Build ASTs and then debug dump them"), - clEnumValN(ASTView, "ast-view", - "Build ASTs and view them with GraphViz"), - clEnumValN(PrintDeclContext, "print-decl-contexts", - "Print DeclContexts and their Decls"), - clEnumValN(DumpRecordLayouts, "dump-record-layouts", - "Dump record layout information"), - clEnumValN(GeneratePTH, "emit-pth", - "Generate pre-tokenized header file"), - clEnumValN(GeneratePCH, "emit-pch", - "Generate pre-compiled header file"), - clEnumValN(EmitAssembly, "S", - "Emit native assembly code"), - clEnumValN(EmitLLVM, "emit-llvm", - "Build ASTs then convert to LLVM, emit .ll file"), - clEnumValN(EmitBC, "emit-llvm-bc", - "Build ASTs then convert to LLVM, emit .bc file"), - clEnumValN(EmitLLVMOnly, "emit-llvm-only", - "Build ASTs and convert to LLVM, discarding output"), - clEnumValN(RewriteTest, "rewrite-test", - "Rewriter playground"), - clEnumValN(RewriteObjC, "rewrite-objc", - "Rewrite ObjC into C (code rewriter example)"), - clEnumValN(RewriteMacros, "rewrite-macros", - "Expand macros without full preprocessing"), - clEnumValN(RewriteBlocks, "rewrite-blocks", - "Rewrite Blocks to C"), - clEnumValEnd)); - -static llvm::cl::opt<bool> -RelocatablePCH("relocatable-pch", - llvm::cl::desc("Whether to build a relocatable precompiled " - "header")); -static llvm::cl::opt<bool> -Stats("print-stats", - llvm::cl::desc("Print performance metrics and statistics")); - -static llvm::cl::opt<bool> -TimeReport("ftime-report", - llvm::cl::desc("Print the amount of time each " - "phase of compilation takes")); - -} - -//===----------------------------------------------------------------------===// -// Language Options -//===----------------------------------------------------------------------===// - -namespace langoptions { - -using namespace clang::frontend; - -static llvm::cl::opt<bool> -NoBuiltin("fno-builtin", - llvm::cl::desc("Disable implicit builtin knowledge of functions")); - -static llvm::cl::opt<bool> -AltiVec("faltivec", llvm::cl::desc("Enable AltiVec vector initializer syntax")); - -static llvm::cl::opt<bool> -AccessControl("faccess-control", - llvm::cl::desc("Enable C++ access control")); - -static llvm::cl::opt<bool> -NoSignedChar("fno-signed-char", - llvm::cl::desc("Char is unsigned")); - -static llvm::cl::opt<bool> -DollarsInIdents("fdollars-in-identifiers", - llvm::cl::desc("Allow '$' in identifiers")); - -static llvm::cl::opt<bool> -EmitAllDecls("femit-all-decls", - llvm::cl::desc("Emit all declarations, even if unused")); - -static llvm::cl::opt<bool> -EnableBlocks("fblocks", llvm::cl::desc("enable the 'blocks' language feature")); - -static llvm::cl::opt<bool> -EnableHeinousExtensions("fheinous-gnu-extensions", - llvm::cl::desc("enable GNU extensions that you really really shouldn't use"), - llvm::cl::ValueDisallowed, llvm::cl::Hidden); - -static llvm::cl::opt<bool> -Exceptions("fexceptions", - llvm::cl::desc("Enable support for exception handling")); - -static llvm::cl::opt<bool> -Freestanding("ffreestanding", - llvm::cl::desc("Assert that the compilation takes place in a " - "freestanding environment")); - -static llvm::cl::opt<bool> -GNURuntime("fgnu-runtime", - llvm::cl::desc("Generate output compatible with the standard GNU " - "Objective-C runtime")); - -static llvm::cl::opt<LangStandard::Kind> -LangStd("std", llvm::cl::desc("Language standard to compile for"), - llvm::cl::init(LangStandard::lang_unspecified), llvm::cl::values( -#define LANGSTANDARD(id, name, desc, features) \ - clEnumValN(LangStandard::lang_##id, name, desc), -#include "clang/Frontend/LangStandards.def" - clEnumValEnd)); - -static llvm::cl::opt<bool> -MSExtensions("fms-extensions", - llvm::cl::desc("Accept some non-standard constructs used in " - "Microsoft header files ")); - -static llvm::cl::opt<bool> -NoMathErrno("fno-math-errno", - llvm::cl::desc("Don't require math functions to respect errno")); - -static llvm::cl::opt<bool> -NoElideConstructors("fno-elide-constructors", - llvm::cl::desc("Disable C++ copy constructor elision")); - -static llvm::cl::opt<bool> -NoLaxVectorConversions("fno-lax-vector-conversions", - llvm::cl::desc("Disallow implicit conversions between " - "vectors with a different number of " - "elements or different element types")); - - -static llvm::cl::opt<bool> -NoOperatorNames("fno-operator-names", - llvm::cl::desc("Do not treat C++ operator name keywords as " - "synonyms for operators")); - -static llvm::cl::opt<std::string> -ObjCConstantStringClass("fconstant-string-class", - llvm::cl::value_desc("class name"), - llvm::cl::desc("Specify the class to use for constant " - "Objective-C string objects.")); - -static llvm::cl::opt<bool> -ObjCEnableGC("fobjc-gc", - llvm::cl::desc("Enable Objective-C garbage collection")); - -static llvm::cl::opt<bool> -ObjCExclusiveGC("fobjc-gc-only", - llvm::cl::desc("Use GC exclusively for Objective-C related " - "memory management")); - -static llvm::cl::opt<bool> -ObjCEnableGCBitmapPrint("print-ivar-layout", - llvm::cl::desc("Enable Objective-C Ivar layout bitmap print trace")); - -static llvm::cl::opt<bool> -ObjCNonFragileABI("fobjc-nonfragile-abi", - llvm::cl::desc("enable objective-c's nonfragile abi")); - -static llvm::cl::opt<bool> -OverflowChecking("ftrapv", - llvm::cl::desc("Trap on integer overflow")); - -static llvm::cl::opt<unsigned> -PICLevel("pic-level", llvm::cl::desc("Value for __PIC__")); - -static llvm::cl::opt<bool> -PThread("pthread", llvm::cl::desc("Support POSIX threads in generated code")); - -static llvm::cl::opt<bool> -PascalStrings("fpascal-strings", - llvm::cl::desc("Recognize and construct Pascal-style " - "string literals")); - -static llvm::cl::opt<bool> -NoRTTI("fno-rtti", - llvm::cl::desc("Disable generation of rtti information")); - -static llvm::cl::opt<bool> -ShortWChar("fshort-wchar", - llvm::cl::desc("Force wchar_t to be a short unsigned int")); - -static llvm::cl::opt<bool> -StaticDefine("static-define", llvm::cl::desc("Should __STATIC__ be defined")); - -static llvm::cl::opt<int> -StackProtector("stack-protector", - llvm::cl::desc("Enable stack protectors")); - -static llvm::cl::opt<LangOptions::VisibilityMode> -SymbolVisibility("fvisibility", - llvm::cl::desc("Set the default symbol visibility:"), - llvm::cl::init(LangOptions::Default), - llvm::cl::values(clEnumValN(LangOptions::Default, "default", - "Use default symbol visibility"), - clEnumValN(LangOptions::Hidden, "hidden", - "Use hidden symbol visibility"), - clEnumValN(LangOptions::Protected,"protected", - "Use protected symbol visibility"), - clEnumValEnd)); - -static llvm::cl::opt<unsigned> -TemplateDepth("ftemplate-depth", - llvm::cl::desc("Maximum depth of recursive template " - "instantiation")); - -static llvm::cl::opt<bool> -Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences")); - -static llvm::cl::opt<bool> -WritableStrings("fwritable-strings", - llvm::cl::desc("Store string literals as writable data")); - -} - -//===----------------------------------------------------------------------===// -// General Preprocessor Options -//===----------------------------------------------------------------------===// - -namespace preprocessoroptions { - -static llvm::cl::list<std::string> -D_macros("D", llvm::cl::value_desc("macro"), llvm::cl::Prefix, - llvm::cl::desc("Predefine the specified macro")); - -static llvm::cl::list<std::string> -ImplicitIncludes("include", llvm::cl::value_desc("file"), - llvm::cl::desc("Include file before parsing")); -static llvm::cl::list<std::string> -ImplicitMacroIncludes("imacros", llvm::cl::value_desc("file"), - llvm::cl::desc("Include macros from file before parsing")); - -static llvm::cl::opt<std::string> -ImplicitIncludePCH("include-pch", llvm::cl::value_desc("file"), - llvm::cl::desc("Include precompiled header file")); - -static llvm::cl::opt<std::string> -ImplicitIncludePTH("include-pth", llvm::cl::value_desc("file"), - llvm::cl::desc("Include file before parsing")); - -static llvm::cl::opt<std::string> -TokenCache("token-cache", llvm::cl::value_desc("path"), - llvm::cl::desc("Use specified token cache file")); - -static llvm::cl::list<std::string> -U_macros("U", llvm::cl::value_desc("macro"), llvm::cl::Prefix, - llvm::cl::desc("Undefine the specified macro")); - -static llvm::cl::opt<bool> -UndefMacros("undef", llvm::cl::value_desc("macro"), - llvm::cl::desc("undef all system defines")); - -static llvm::cl::list<std::string> -RemappedFiles("remap-file", llvm::cl::value_desc("<from>;<to>"), - llvm::cl::desc("replace the contents of the <from> file with the contents of the <to> file")); - -} - -//===----------------------------------------------------------------------===// -// Header Search Options -//===----------------------------------------------------------------------===// - -namespace headersearchoptions { - -static llvm::cl::opt<bool> -nostdinc("nostdinc", llvm::cl::desc("Disable standard #include directories")); - -static llvm::cl::opt<bool> -nobuiltininc("nobuiltininc", - llvm::cl::desc("Disable builtin #include directories")); - -// Various command line options. These four add directories to each chain. -static llvm::cl::list<std::string> -F_dirs("F", llvm::cl::value_desc("directory"), llvm::cl::Prefix, - llvm::cl::desc("Add directory to framework include search path")); - -static llvm::cl::list<std::string> -I_dirs("I", llvm::cl::value_desc("directory"), llvm::cl::Prefix, - llvm::cl::desc("Add directory to include search path")); - -static llvm::cl::list<std::string> -idirafter_dirs("idirafter", llvm::cl::value_desc("directory"), llvm::cl::Prefix, - llvm::cl::desc("Add directory to AFTER include search path")); - -static llvm::cl::list<std::string> -iquote_dirs("iquote", llvm::cl::value_desc("directory"), llvm::cl::Prefix, - llvm::cl::desc("Add directory to QUOTE include search path")); - -static llvm::cl::list<std::string> -isystem_dirs("isystem", llvm::cl::value_desc("directory"), llvm::cl::Prefix, - llvm::cl::desc("Add directory to SYSTEM include search path")); - -// These handle -iprefix/-iwithprefix/-iwithprefixbefore. -static llvm::cl::list<std::string> -iprefix_vals("iprefix", llvm::cl::value_desc("prefix"), llvm::cl::Prefix, - llvm::cl::desc("Set the -iwithprefix/-iwithprefixbefore prefix")); -static llvm::cl::list<std::string> -iwithprefix_vals("iwithprefix", llvm::cl::value_desc("dir"), llvm::cl::Prefix, - llvm::cl::desc("Set directory to SYSTEM include search path with prefix")); -static llvm::cl::list<std::string> -iwithprefixbefore_vals("iwithprefixbefore", llvm::cl::value_desc("dir"), - llvm::cl::Prefix, - llvm::cl::desc("Set directory to include search path with prefix")); - -static llvm::cl::opt<std::string> -isysroot("isysroot", llvm::cl::value_desc("dir"), - llvm::cl::desc("Set the system root directory (usually /)")); - -static llvm::cl::opt<bool> -Verbose("v", llvm::cl::desc("Enable verbose output")); - -} - -//===----------------------------------------------------------------------===// -// Preprocessed Output Options -//===----------------------------------------------------------------------===// - -namespace preprocessoroutputoptions { - -static llvm::cl::opt<bool> -DisableLineMarkers("P", llvm::cl::desc("Disable linemarker output in -E mode")); - -static llvm::cl::opt<bool> -EnableCommentOutput("C", llvm::cl::desc("Enable comment output in -E mode")); - -static llvm::cl::opt<bool> -EnableMacroCommentOutput("CC", - llvm::cl::desc("Enable comment output in -E mode, " - "even from macro expansions")); -static llvm::cl::opt<bool> -DumpMacros("dM", llvm::cl::desc("Print macro definitions in -E mode instead of" - " normal output")); -static llvm::cl::opt<bool> -DumpDefines("dD", llvm::cl::desc("Print macro definitions in -E mode in " - "addition to normal output")); - -} - -//===----------------------------------------------------------------------===// -// Target Options -//===----------------------------------------------------------------------===// - -namespace targetoptions { - -static llvm::cl::opt<std::string> -TargetABI("target-abi", - llvm::cl::desc("Target a particular ABI type")); - -static llvm::cl::opt<std::string> -TargetCPU("mcpu", - llvm::cl::desc("Target a specific cpu type ('-mcpu help' for details)")); - -static llvm::cl::list<std::string> -TargetFeatures("target-feature", llvm::cl::desc("Target specific attributes")); - -static llvm::cl::opt<std::string> -TargetTriple("triple", - llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)")); - -} - -//===----------------------------------------------------------------------===// -// Option Object Construction -//===----------------------------------------------------------------------===// - -void clang::InitializeAnalyzerOptions(AnalyzerOptions &Opts) { - using namespace analyzeroptions; - Opts.AnalysisList = AnalysisList; - Opts.AnalysisStoreOpt = AnalysisStoreOpt; - Opts.AnalysisConstraintsOpt = AnalysisConstraintsOpt; - Opts.AnalysisDiagOpt = AnalysisDiagOpt; - Opts.VisualizeEGDot = VisualizeEGDot; - Opts.VisualizeEGUbi = VisualizeEGUbi; - Opts.AnalyzeAll = AnalyzeAll; - Opts.AnalyzerDisplayProgress = AnalyzerDisplayProgress; - Opts.PurgeDead = !NoPurgeDead; - Opts.EagerlyAssume = EagerlyAssume; - Opts.AnalyzeSpecificFunction = AnalyzeSpecificFunction; - Opts.EnableExperimentalChecks = AnalyzerExperimentalChecks; - Opts.EnableExperimentalInternalChecks = AnalyzerExperimentalInternalChecks; - Opts.TrimGraph = TrimGraph; -} - -void clang::InitializeCodeGenOptions(CodeGenOptions &Opts, - const LangOptions &Lang) { - using namespace codegenoptions; - - // -Os implies -O2 - unsigned Opt = OptLevel.getPosition() ? OptLevel : 0; - Opts.OptimizationLevel = OptSize ? 2 : Opt; - - // We must always run at least the always inlining pass. - Opts.Inlining = (Opts.OptimizationLevel > 1) ? CodeGenOptions::NormalInlining - : CodeGenOptions::OnlyAlwaysInlining; - - Opts.DebugInfo = GenerateDebugInfo; - Opts.DisableLLVMOpts = DisableLLVMOptimizations; - Opts.DisableRedZone = DisableRedZone; - Opts.MergeAllConstants = !NoMergeConstants; - Opts.NoCommon = NoCommon; - Opts.NoImplicitFloat = NoImplicitFloat; - Opts.OptimizeSize = OptSize; - Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize); - - // LLVM Code Generator options. - - Opts.AsmVerbose = MAsmVerbose; - Opts.CodeModel = MCodeModel; - Opts.DebugPass = MDebugPass; - Opts.DisableFPElim = MDisableFPElim; - Opts.FloatABI = MFloatABI; - Opts.LimitFloatPrecision = MLimitFloatPrecision; - Opts.NoZeroInitializedInBSS = MNoZeroInitializedInBSS; - Opts.SoftFloat = MSoftFloat; - Opts.RelocationModel = MRelocationModel; - Opts.UnwindTables = MUnwindTables; - -#ifdef NDEBUG - Opts.VerifyModule = 0; -#endif - - if (MainFileName.getPosition()) - Opts.MainFileName = MainFileName; -} - -void clang::InitializeDependencyOutputOptions(DependencyOutputOptions &Opts) { - using namespace dependencyoutputoptions; - - Opts.OutputFile = DependencyFile; - Opts.Targets = DependencyTargets; - Opts.IncludeSystemHeaders = DependenciesIncludeSystemHeaders; - Opts.UsePhonyTargets = PhonyDependencyTarget; -} - -void clang::InitializeDiagnosticOptions(DiagnosticOptions &Opts) { - using namespace diagnosticoptions; - - Opts.Warnings = OptWarnings; - Opts.DumpBuildInformation = DumpBuildInformation; - Opts.IgnoreWarnings = OptNoWarnings; - Opts.MessageLength = MessageLength; - Opts.NoRewriteMacros = SilenceRewriteMacroWarning; - Opts.Pedantic = OptPedantic; - Opts.PedanticErrors = OptPedanticErrors; - Opts.ShowCarets = !NoCaretDiagnostics; - Opts.ShowColors = PrintColorDiagnostic; - Opts.ShowColumn = !NoShowColumn; - Opts.ShowFixits = !NoDiagnosticsFixIt; - Opts.ShowLocation = !NoShowLocation; - Opts.ShowOptionNames = PrintDiagnosticOption; - Opts.ShowSourceRanges = PrintSourceRangeInfo; - Opts.VerifyDiagnostics = VerifyDiagnostics; -} - -void clang::InitializeFrontendOptions(FrontendOptions &Opts) { - using namespace frontendoptions; - - Opts.ProgramAction = ProgAction; - Opts.ActionName = PluginActionName; - Opts.CodeCompletionAt = CodeCompletionAt; - Opts.DebugCodeCompletionPrinter = !NoCodeCompletionDebugPrinter; - Opts.DisableFree = DisableFree; - Opts.EmptyInputOnly = EmptyInputOnly; - Opts.FixItLocations = FixItAtLocations; - Opts.OutputFile = OutputFile; - Opts.RelocatablePCH = RelocatablePCH; - Opts.ShowMacrosInCodeCompletion = CodeCompletionWantsMacros; - Opts.ShowStats = Stats; - Opts.ShowTimers = TimeReport; - Opts.ViewClassInheritance = InheritanceViewCls; - - // Enforce certain program action implications. - if (!Opts.ActionName.empty()) - Opts.ProgramAction = frontend::PluginAction; - if (!Opts.ViewClassInheritance.empty()) - Opts.ProgramAction = frontend::InheritanceView; - if (!Opts.FixItLocations.empty()) - Opts.P |