diff options
Diffstat (limited to 'clang/tools/clang-cc/clang-cc.cpp')
-rw-r--r-- | clang/tools/clang-cc/clang-cc.cpp | 308 |
1 files changed, 154 insertions, 154 deletions
diff --git a/clang/tools/clang-cc/clang-cc.cpp b/clang/tools/clang-cc/clang-cc.cpp index ee6d9267c5f..5c60b519ac1 100644 --- a/clang/tools/clang-cc/clang-cc.cpp +++ b/clang/tools/clang-cc/clang-cc.cpp @@ -109,14 +109,14 @@ static bool HadErrors = false; static llvm::cl::opt<bool> Verbose("v", llvm::cl::desc("Enable verbose output")); static llvm::cl::opt<bool> -Stats("print-stats", +Stats("print-stats", llvm::cl::desc("Print performance metrics and statistics")); static llvm::cl::opt<bool> DisableFree("disable-free", llvm::cl::desc("Disable freeing of memory on exit"), llvm::cl::init(false)); static llvm::cl::opt<bool> -EmptyInputOnly("empty-input-only", +EmptyInputOnly("empty-input-only", llvm::cl::desc("Force running on an empty input file")); enum ProgActions { @@ -129,7 +129,7 @@ enum ProgActions { EmitAssembly, // Emit a .s file. EmitLLVM, // Emit a .ll file. EmitBC, // Emit a .bc file. - EmitLLVMOnly, // Generate LLVM IR, but do not + EmitLLVMOnly, // Generate LLVM IR, but do not EmitHTML, // Translate input source into HTML. ASTPrint, // Parse ASTs and print them. ASTPrintXML, // Parse ASTs and print them in XML. @@ -143,13 +143,13 @@ enum ProgActions { PrintPreprocessedInput, // -E mode. DumpTokens, // Dump out preprocessed tokens. DumpRawTokens, // Dump out raw tokens. - RunAnalysis, // Run one or more source code analyses. + RunAnalysis, // Run one or more source code analyses. GeneratePTH, // Generate pre-tokenized header. GeneratePCH, // Generate pre-compiled header. InheritanceView // View C++ inheritance for a specified class. }; -static llvm::cl::opt<ProgActions> +static llvm::cl::opt<ProgActions> ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, llvm::cl::init(ParseSyntaxOnly), llvm::cl::values( @@ -262,13 +262,13 @@ PrintDiagnosticOption("fdiagnostics-show-option", 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")); + 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> NoColorDiagnostic("fno-color-diagnostics", - llvm::cl::desc("Don't use colors when showing diagnostics " + llvm::cl::desc("Don't use colors when showing diagnostics " "(automatically turned off if output is not a " "terminal).")); //===----------------------------------------------------------------------===// @@ -402,8 +402,9 @@ PThread("pthread", llvm::cl::desc("Support POSIX threads in generated code"), static llvm::cl::opt<bool> ObjCSenderDispatch("fobjc-sender-dependent-dispatch", - llvm::cl::desc("Enable sender-dependent dispatch for" - "Objective-C messages"), llvm::cl::init(false)); + llvm::cl::desc("Enable sender-dependent dispatch for" + "Objective-C messages"), + llvm::cl::init(false)); /// InitializeBaseLanguage - Handle the -x foo options. static void InitializeBaseLanguage() { @@ -416,14 +417,14 @@ static void InitializeBaseLanguage() { static LangKind GetLanguage(const std::string &Filename) { if (BaseLang != langkind_unspecified) return BaseLang; - + std::string::size_type DotPos = Filename.rfind('.'); if (DotPos == std::string::npos) { BaseLang = langkind_c; // Default to C if no extension. return langkind_c; } - + std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end()); // C header: .h // C++ header: .hh or .H; @@ -464,12 +465,12 @@ static void InitializeCOptions(LangOptions &Options) { static void InitializeObjCOptions(LangOptions &Options) { Options.ObjC1 = Options.ObjC2 = 1; } - + static void InitializeLangOptions(LangOptions &Options, LangKind LK){ // FIXME: implement -fpreprocessed mode. bool NoPreprocess = false; - + switch (LK) { default: assert(0 && "Unknown language kind!"); case langkind_asm_cpp: @@ -507,28 +508,28 @@ static void InitializeLangOptions(LangOptions &Options, LangKind LK){ Options.LaxVectorConversions = 1; break; } - + if (ObjCExclusiveGC) Options.setGCMode(LangOptions::GCOnly); else if (ObjCEnableGC) Options.setGCMode(LangOptions::HybridGC); - + if (ObjCEnableGCBitmapPrint) Options.ObjCGCBitmapPrint = 1; - + if (AltiVec) Options.AltiVec = 1; if (PThread) Options.POSIXThreads = 1; - + Options.setVisibilityMode(SymbolVisibility); Options.OverflowChecking = OverflowChecking; } /// LangStds - Language standards we support. enum LangStds { - lang_unspecified, + lang_unspecified, lang_c89, lang_c94, lang_c99, lang_gnu_START, lang_gnu89 = lang_gnu_START, lang_gnu99, @@ -575,7 +576,7 @@ static llvm::cl::opt<bool> PascalStrings("fpascal-strings", llvm::cl::desc("Recognize and construct Pascal-style " "string literals")); - + static llvm::cl::opt<bool> MSExtensions("fms-extensions", llvm::cl::desc("Accept some non-standard constructs used in " @@ -647,7 +648,7 @@ static llvm::cl::opt<bool> OptSize("Os", llvm::cl::desc("Optimize for size")); static llvm::cl::opt<bool> -DisableLLVMOptimizations("disable-llvm-optzns", +DisableLLVMOptimizations("disable-llvm-optzns", llvm::cl::desc("Don't run LLVM optimization passes")); static llvm::cl::opt<bool> @@ -661,7 +662,7 @@ MainFileName("main-file-name", // FIXME: Also add an "-fno-access-control" option. static llvm::cl::opt<bool> -AccessControl("faccess-control", +AccessControl("faccess-control", llvm::cl::desc("Enable C++ access control")); static llvm::cl::opt<bool> @@ -705,7 +706,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, // Pass the map of target features to the target for validation and // processing. Target->HandleTargetFeatures(Features); - + if (LangStd == lang_unspecified) { // Based on the base language, pick one. switch (LK) { @@ -728,7 +729,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, break; } } - + switch (LangStd) { default: assert(0 && "Unknown language standard!"); @@ -760,17 +761,17 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, // GNUMode - Set if we're in gnu99, gnu89, gnucxx98, etc. Options.GNUMode = LangStd >= lang_gnu_START; - + if (Options.CPlusPlus) { Options.C99 = 0; Options.HexFloats = 0; } - + if (LangStd == lang_c89 || LangStd == lang_c94 || LangStd == lang_gnu89) Options.ImplicitInt = 1; else Options.ImplicitInt = 0; - + // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs // is specified, or -std is set to a conforming mode. Options.Trigraphs = !Options.GNUMode; @@ -783,14 +784,14 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, // However, blocks are not turned off when compiling Obj-C or Obj-C++ code. if (!Options.ObjC1 && !Options.GNUMode) Options.Blocks = 0; - + // Default to not accepting '$' in identifiers when preprocessing assembler, // but do accept when preprocessing C. FIXME: these defaults are right for // darwin, are they right everywhere? Options.DollarIdents = LK != langkind_asm_cpp; if (DollarsInIdents.getPosition()) // Explicit setting overrides default. Options.DollarIdents = DollarsInIdents; - + if (PascalStrings.getPosition()) Options.PascalStrings = PascalStrings; if (MSExtensions.getPosition()) @@ -809,18 +810,18 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, Options.NoBuiltin = 1; if (Freestanding) Options.Freestanding = Options.NoBuiltin = 1; - + if (EnableHeinousExtensions) Options.HeinousExtensions = 1; if (AccessControl) Options.AccessControl = 1; - + Options.ElideConstructors = !NoElideConstructors; - + // OpenCL and C++ both have bool, true, false keywords. Options.Bool = Options.OpenCL | Options.CPlusPlus; - + Options.MathErrno = MathErrno; Options.InstantiationDepth = TemplateDepth; @@ -838,14 +839,14 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, Options.ObjCNonFragileABI = 1; Options.ObjCSenderDispatch = ObjCSenderDispatch; - + if (EmitAllDecls) Options.EmitAllDecls = 1; // The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't // support. Options.OptimizeSize = 0; - + // -Os implies -O2 if (OptSize || OptLevel) Options.Optimize = 1; @@ -854,7 +855,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, Options.PICLevel = PICLevel; Options.GNUInline = !Options.C99; - // FIXME: This is affected by other options (-fno-inline). + // FIXME: This is affected by other options (-fno-inline). Options.NoInline = !OptSize && !OptLevel; Options.Static = StaticDefine; @@ -881,7 +882,7 @@ TargetTriple("triple", llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)")); static llvm::cl::opt<std::string> -MacOSVersionMin("mmacosx-version-min", +MacOSVersionMin("mmacosx-version-min", llvm::cl::desc("Specify target Mac OS X version (e.g. 10.5)")); // If -mmacosx-version-min=10.3.9 is specified, change the triple from being @@ -891,12 +892,12 @@ MacOSVersionMin("mmacosx-version-min", static void HandleMacOSVersionMin(std::string &Triple) { std::string::size_type DarwinDashIdx = Triple.find("-darwin"); if (DarwinDashIdx == std::string::npos) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min only valid for darwin (Mac OS X) targets\n"); exit(1); } unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin"); - + // Remove the number. Triple.resize(DarwinNumIdx); @@ -914,10 +915,10 @@ static void HandleMacOSVersionMin(std::string &Triple) { // The version number must be in the range 0-9. MacOSVersionMinIsInvalid = (unsigned)VersionNum > 9; - + // Turn MacOSVersionMin into a darwin number: e.g. 10.3.9 is 3 -> 7. Triple += llvm::itostr(VersionNum+4); - + if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 10.4.7 is ok. // Add the period piece (.7) to the end of the triple. This gives us // something like ...-darwin8.7 @@ -926,16 +927,16 @@ static void HandleMacOSVersionMin(std::string &Triple) { MacOSVersionMinIsInvalid = true; } } - + if (MacOSVersionMinIsInvalid) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min=%s is invalid, expected something like '10.4'.\n", MacOSVersionMin.c_str()); exit(1); } - else if (VersionNum <= 4 && + else if (VersionNum <= 4 && !strncmp(Triple.c_str(), "x86_64", strlen("x86_64"))) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min=%s is invalid with -arch x86_64.\n", MacOSVersionMin.c_str()); exit(1); @@ -944,7 +945,7 @@ static void HandleMacOSVersionMin(std::string &Triple) { } static llvm::cl::opt<std::string> -IPhoneOSVersionMin("miphoneos-version-min", +IPhoneOSVersionMin("miphoneos-version-min", llvm::cl::desc("Specify target iPhone OS version (e.g. 2.0)")); // If -miphoneos-version-min=2.2 is specified, change the triple from being @@ -956,15 +957,15 @@ IPhoneOSVersionMin("miphoneos-version-min", static void HandleIPhoneOSVersionMin(std::string &Triple) { std::string::size_type DarwinDashIdx = Triple.find("-darwin"); if (DarwinDashIdx == std::string::npos) { - fprintf(stderr, + fprintf(stderr, "-miphoneos-version-min only valid for darwin (Mac OS X) targets\n"); exit(1); } unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin"); - + // Remove the number. Triple.resize(DarwinNumIdx); - + // Validate that IPhoneOSVersionMin is a 'version number', starting with [2-9].[0-9] bool IPhoneOSVersionMinIsInvalid = false; int VersionNum = 0; @@ -975,13 +976,13 @@ static void HandleIPhoneOSVersionMin(std::string &Triple) { const char *Start = IPhoneOSVersionMin.c_str(); char *End = 0; VersionNum = (int)strtol(Start, &End, 10); - + // The version number must be in the range 0-9. IPhoneOSVersionMinIsInvalid = (unsigned)VersionNum > 9; - + // Turn IPhoneOSVersionMin into a darwin number: e.g. 2.0 is 2 -> 9.2. Triple += "9." + llvm::itostr(VersionNum); - + if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 2.2 is ok. // Add the period piece (.2) to the end of the triple. This gives us // something like ...-darwin9.2.2 @@ -990,9 +991,9 @@ static void HandleIPhoneOSVersionMin(std::string &Triple) { IPhoneOSVersionMinIsInvalid = true; } } - + if (IPhoneOSVersionMinIsInvalid) { - fprintf(stderr, + fprintf(stderr, "-miphoneos-version-min=%s is invalid, expected something like '2.0'.\n", IPhoneOSVersionMin.c_str()); exit(1); @@ -1014,7 +1015,7 @@ static std::string CreateTargetTriple() { HandleMacOSVersionMin(Triple); else if (!IPhoneOSVersionMin.empty()) HandleIPhoneOSVersionMin(Triple);; - + return Triple; } @@ -1030,14 +1031,14 @@ static bool InitializeSourceManager(Preprocessor &PP, if (EmptyInputOnly) { const char *EmptyStr = ""; - llvm::MemoryBuffer *SB = + llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<empty input>"); SourceMgr.createMainFileIDForMemBuffer(SB); } else if (InFile != "-") { const FileEntry *File = FileMgr.getFile(InFile); if (File) SourceMgr.createMainFileID(File, SourceLocation()); if (SourceMgr.getMainFileID().isInvalid()) { - PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading) + PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading) << InFile.c_str(); return true; } @@ -1053,7 +1054,7 @@ static bool InitializeSourceManager(Preprocessor &PP, SourceMgr.createMainFileIDForMemBuffer(SB); if (SourceMgr.getMainFileID().isInvalid()) { - PP.getDiagnostics().Report(FullSourceLoc(), + PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading_stdin); return true; } @@ -1094,7 +1095,7 @@ ImplicitIncludePTH("include-pth", llvm::cl::value_desc("file"), llvm::cl::desc("Include file before parsing")); static llvm::cl::opt<bool> -RelocatablePCH("relocatable-pch", +RelocatablePCH("relocatable-pch", llvm::cl::desc("Whether to build a relocatable precompiled " "header")); @@ -1105,7 +1106,7 @@ RelocatablePCH("relocatable-pch", // This tool exports a large number of command line options to control how the // preprocessor searches for header files. At root, however, the Preprocessor // object takes a very simple interface: a list of directories to search for -// +// // FIXME: -nostdinc++ // FIXME: -imultilib // @@ -1165,22 +1166,22 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers, ++Fidx; } } - + // Consume what's left from whatever list was longer. for (; Iidx != I_dirs.size(); ++Iidx) Init.AddPath(I_dirs[Iidx], InitHeaderSearch::Angled, false, true, false); for (; Fidx != F_dirs.size(); ++Fidx) Init.AddPath(F_dirs[Fidx], InitHeaderSearch::Angled, false, true, true); - + // Handle -idirafter... options. for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i) Init.AddPath(idirafter_dirs[i], InitHeaderSearch::After, false, true, false); - + // Handle -iquote... options. for (unsigned i = 0, e = iquote_dirs.size(); i != e; ++i) Init.AddPath(iquote_dirs[i], InitHeaderSearch::Quoted, false, true, false); - + // Handle -isystem... options. for (unsigned i = 0, e = isystem_dirs.size(); i != e; ++i) Init.AddPath(isystem_dirs[i], InitHeaderSearch::System, false, true, false); @@ -1198,28 +1199,28 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers, bool iwithprefixbefore_done = iwithprefixbefore_vals.empty(); while (!iprefix_done || !iwithprefix_done || !iwithprefixbefore_done) { if (!iprefix_done && - (iwithprefix_done || - iprefix_vals.getPosition(iprefix_idx) < + (iwithprefix_done || + iprefix_vals.getPosition(iprefix_idx) < iwithprefix_vals.getPosition(iwithprefix_idx)) && - (iwithprefixbefore_done || - iprefix_vals.getPosition(iprefix_idx) < + (iwithprefixbefore_done || + iprefix_vals.getPosition(iprefix_idx) < iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) { Prefix = iprefix_vals[iprefix_idx]; ++iprefix_idx; iprefix_done = iprefix_idx == iprefix_vals.size(); } else if (!iwithprefix_done && - (iwithprefixbefore_done || - iwithprefix_vals.getPosition(iwithprefix_idx) < + (iwithprefixbefore_done || + iwithprefix_vals.getPosition(iwithprefix_idx) < iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) { - Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx], + Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx], InitHeaderSearch::System, false, false, false); ++iwithprefix_idx; iwithprefix_done = iwithprefix_idx == iwithprefix_vals.size(); } else { - Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx], + Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx], InitHeaderSearch::Angled, false, false, false); ++iwithprefixbefore_idx; - iwithprefixbefore_done = + iwithprefixbefore_done = iwithprefixbefore_idx == iwithprefixbefore_vals.size(); } } @@ -1228,36 +1229,35 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers, Init.AddDefaultEnvVarPaths(Lang); // Add the clang headers, which are relative to the clang binary. - llvm::sys::Path MainExecutablePath = + llvm::sys::Path MainExecutablePath = llvm::sys::Path::GetMainExecutable(Argv0, (void*)(intptr_t)InitializeIncludePaths); if (!MainExecutablePath.isEmpty()) { MainExecutablePath.eraseComponent(); // Remove /clang from foo/bin/clang MainExecutablePath.eraseComponent(); // Remove /bin from foo/bin - // Get foo/lib/clang/<version>/include + // Get foo/lib/clang/<version>/include MainExecutablePath.appendComponent("lib"); MainExecutablePath.appendComponent("clang"); MainExecutablePath.appendComponent(CLANG_VERSION_STRING); MainExecutablePath.appendComponent("include"); - + // We pass true to ignore sysroot so that we *always* look for clang headers // relative to our executable, never relative to -isysroot. Init.AddPath(MainExecutablePath.c_str(), InitHeaderSearch::System, false, false, false, true /*ignore sysroot*/); } - - if (!nostdinc) + + if (!nostdinc) Init.AddDefaultSystemIncludePaths(Lang); // Now that we have collected all of the include paths, merge them all // together and tell the preprocessor about them. - + Init.Realize(); } -void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) -{ +void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) { // Add macros from the command line. unsigned d = 0, D = D_macros.size(); unsigned u = 0, U = U_macros.size(); @@ -1326,17 +1326,17 @@ class VISIBILITY_HIDDEN DriverPreprocessorFactory : public PreprocessorFactory { TargetInfo &Target; SourceManager &SourceMgr; HeaderSearch &HeaderInfo; - + public: DriverPreprocessorFactory(Diagnostic &diags, const LangOptions &opts, TargetInfo &target, SourceManager &SM, - HeaderSearch &Headers) + HeaderSearch &Headers) : Diags(diags), LangInfo(opts), Target(target), SourceMgr(SM), HeaderInfo(Headers) {} - - + + virtual ~DriverPreprocessorFactory() {} - + virtual Preprocessor* CreatePreprocessor() { llvm::OwningPtr<PTHManager> PTHMgr; @@ -1345,23 +1345,23 @@ public: "options\n"); exit(1); } - + // Use PTH? if (!TokenCache.empty() || !ImplicitIncludePTH.empty()) { const std::string& x = TokenCache.empty() ? ImplicitIncludePTH:TokenCache; - PTHMgr.reset(PTHManager::Create(x, &Diags, + PTHMgr.reset(PTHManager::Create(x, &Diags, TokenCache.empty() ? Diagnostic::Error : Diagnostic::Warning)); } - + if (Diags.hasErrorOccurred()) exit(1); - + // Create the Preprocessor. llvm::OwningPtr<Preprocessor> PP(new Preprocessor(Diags, LangInfo, Target, SourceMgr, HeaderInfo, PTHMgr.get())); - + // Note that this is different then passing PTHMgr to Preprocessor's ctor. // That argument is used as the IdentifierInfoLookup argument to // IdentifierTable's ctor. @@ -1387,7 +1387,7 @@ public: static void ParseFile(Preprocessor &PP, MinimalAction *PA) { Parser P(PP, *PA); PP.EnterMainSourceFile(); - + // Parsing the specified input file. P.ParseTranslationUnit(); delete PA; @@ -1424,24 +1424,24 @@ NoImplicitFloat("no-implicit-float", /// and feature list. static void ComputeFeatureMap(TargetInfo *Target, llvm::StringMap<bool> &Features) { - assert(Features.empty() && "invalid map"); + assert(Features.empty() && "invalid map"); // Initialize the feature map based on the target. Target->getDefaultFeatures(TargetCPU, Features); // Apply the user specified deltas. - for (llvm::cl::list<std::string>::iterator it = TargetFeatures.begin(), + for (llvm::cl::list<std::string>::iterator it = TargetFeatures.begin(), ie = TargetFeatures.end(); it != ie; ++it) { const char *Name = it->c_str(); - + // FIXME: Don't handle errors like this. if (Name[0] != '-' && Name[0] != '+') { - fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n", + fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n", Name); exit(1); } if (!Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) { - fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n", + fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n", Name + 1); exit(1); } @@ -1482,7 +1482,7 @@ static void InitializeCompileOptions(CompileOptions &Opts, Opts.CPU = TargetCPU; Opts.Features.clear(); - for (llvm::StringMap<bool>::const_iterator it = Features.begin(), + for (llvm::StringMap<bool>::const_iterator it = Features.begin(), ie = Features.end(); it != ie; ++it) { // FIXME: If we are completely confident that we have the right // set, we only need to pass the minuses. @@ -1490,9 +1490,9 @@ static void InitializeCompileOptions(CompileOptions &Opts, Name += it->first(); Opts.Features.push_back(Name); } - + Opts.NoCommon = NoCommon | LangOpts.CPlusPlus; - + // Handle -ftime-report. Opts.TimePasses = TimeReport; @@ -1579,7 +1579,7 @@ clEnumValN(NAME, CMDFLAG, DESC), #include "clang/Frontend/Analyses.def" clEnumValEnd)); -static llvm::cl::opt<AnalysisStores> +static llvm::cl::opt<AnalysisStores> AnalysisStoreOpt("analyzer-store", llvm::cl::desc("Source Code Analysis - Abstract Memory Store Models"), llvm::cl::init(BasicStoreModel), @@ -1589,7 +1589,7 @@ clEnumValN(NAME##Model, CMDFLAG, DESC), #include "clang/Frontend/Analyses.def" clEnumValEnd)); -static llvm::cl::opt<AnalysisConstraints> +static llvm::cl::opt<AnalysisConstraints> AnalysisConstraintsOpt("analyzer-constraints", llvm::cl::desc("Source Code Analysis - Symbolic Constraint Engines"), llvm::cl::init(RangeConstraintsModel), @@ -1681,7 +1681,7 @@ class LoggingDiagnosticClient : public DiagnosticClient { llvm::OwningPtr<DiagnosticClient> Chain1; llvm::OwningPtr<DiagnosticClient> Chain2; public: - + LoggingDiagnosticClient(DiagnosticClient *Normal) { // Output diags both where requested... Chain1.reset(Normal); @@ -1695,12 +1695,12 @@ public: !NoDiagnosticsFixIt, MessageLength)); } - + virtual void setLangOptions(const LangOptions *LO) { Chain1->setLangOptions(LO); Chain2->setLangOptions(LO); } - + virtual bool IncludeInDiagnosticCounts() const { return Chain1->IncludeInDiagnosticCounts(); } @@ -1715,11 +1715,11 @@ public: static void SetUpBuildDumpLog(unsigned argc, char **argv, llvm::OwningPtr<DiagnosticClient> &DiagClient) { - + std::string ErrorInfo; BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), ErrorInfo); - + if (!ErrorInfo.empty()) { llvm::errs() << "error opening -dump-build-information file '" << DumpBuildInformation << "', option ignored!\n"; @@ -1733,7 +1733,7 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv, for (unsigned i = 0; i != argc; ++i) (*BuildLogFile) << argv[i] << ' '; (*BuildLogFile) << '\n'; - + // LoggingDiagnosticClient - Insert a new logging diagnostic client in between // the diagnostic producers and the normal receiver. DiagClient.reset(new LoggingDiagnosticClient(DiagClient.take())); @@ -1772,7 +1772,7 @@ static llvm::raw_ostream *ComputeOutFile(const std::string &InFile, llvm::errs() << "ERROR: " << Error << "\n"; ::exit(1); } - + if (OutFile != "-") OutPath = OutFile; @@ -1802,7 +1802,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, OS.reset(ComputeOutFile(InFile, 0, false, OutPath)); Consumer.reset(CreateASTPrinter(OS.get())); break; - + case ASTPrintXML: OS.reset(ComputeOutFile(InFile, "xml", false, OutPath)); Consumer.reset(CreateASTPrinterXML(OS.get())); @@ -1831,7 +1831,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, case EmitAssembly: case EmitLLVM: - case EmitBC: + case EmitBC: case EmitLLVMOnly: { BackendAction Act; if (ProgAction == EmitAssembly) { @@ -1860,7 +1860,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, PP.Diag(SourceLocation(), diag::err_relocatable_without_without_isysroot); RelocatablePCH.setValue(false); } - + OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); if (RelocatablePCH.getValue()) Consumer.reset(CreatePCHGenerator(PP, OS.get(), isysroot.c_str())); @@ -1920,7 +1920,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, } case RunPreprocessorOnly: break; - + case GeneratePTH: { llvm::TimeRegion Timer(ClangFrontendTimer); if (OutputFile.empty() || OutputFile == "-") { @@ -1933,15 +1933,15 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, CacheTokens(PP, static_cast<llvm::raw_fd_ostream*>(OS.get())); ClearSourceMgr = true; break; - } + } case PrintPreprocessedInput: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); break; - + case ParseNoop: break; - + case ParsePrintCallbacks: { llvm::TimeRegion Timer(ClangFrontendTimer); OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); @@ -1955,13 +1955,13 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, Consumer.reset(new ASTConsumer()); break; } - + case RewriteMacros: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); RewriteMacrosInInput(PP, OS.get()); ClearSourceMgr = true; break; - + case RewriteTest: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); DoRewriteTest(PP, OS.get()); @@ -1987,7 +1987,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, PP.getLangOptions()); bool AddedFixitLocation = false; - for (unsigned Idx = 0, Last = FixItAtLocations.size(); + for (unsigned Idx = 0, Last = FixItAtLocations.size(); Idx != Last; ++Idx) { RequestedSourceLocation Requested; if (ResolveParsedLocation(FixItAtLocations[Idx], @@ -2017,19 +2017,19 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, PP.getBuiltinInfo(), /* FreeMemory = */ !DisableFree, /* size_reserve = */0)); - + llvm::OwningPtr<PCHReader> Reader; llvm::OwningPtr<ExternalASTSource> Source; - + if (!ImplicitIncludePCH.empty()) { // If the user specified -isysroot, it will be used for relocatable PCH // files. const char *isysrootPCH = 0; if (isysroot.getNumOccurrences() != 0) isysrootPCH = isysroot.c_str(); - + Reader.reset(new PCHReader(PP, ContextOwner.get(), isysrootPCH)); - + // The user has asked us to include a precompiled header. Load // the precompiled header into the AST context. switch (Reader->ReadPCH(ImplicitIncludePCH)) { @@ -2080,7 +2080,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, // If we have an ASTConsumer, run the parser with it. if (Consumer) - ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats, + ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats, CompleteTranslationUnit); if (PA == RunPreprocessorOnly) { // Just lex as fast as we can, no output. @@ -2106,7 +2106,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, DisableLineMarkers, DumpDefines); ClearSourceMgr = true; } - + if (FixItRewrite) FixItRewrite->WriteFixedFile(InFile, OutputFile); @@ -2116,7 +2116,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, Consumer.take(); else Consumer.reset(); - + // If in -disable-free mode, don't deallocate ASTContext. if (DisableFree) ContextOwner.take(); @@ -2136,7 +2136,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, fprintf(stderr, "\n"); } - // For a multi-file compilation, some things are ok with nuking the source + // For a multi-file compilation, some things are ok with nuking the source // manager tables, other require stable fileid/macroid's across multiple // files. if (ClearSourceMgr) @@ -2176,14 +2176,14 @@ int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv, "LLVM 'Clang' Compiler: http://clang.llvm.org\n"); - + if (TimeReport) ClangFrontendTimer = new llvm::Timer("Clang front-end time"); - + if (Verbose) llvm::errs() << "clang-cc version 1.0 based upon " << PACKAGE_STRING << " hosted on " << llvm::sys::getHostTriple() << "\n"; - + // If no input was specified, read from stdin. if (InputFilenames.empty()) InputFilenames.push_back("-"); @@ -2227,17 +2227,17 @@ int main(int argc, char **argv) { } else { DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag)); } - + if (!DumpBuildInformation.empty()) { if (!HTMLDiag.empty()) { fprintf(stderr, "-dump-build-information and -html-diags don't work together\n"); return 1; } - + SetUpBuildDumpLog(argc, argv, DiagClient); } - + // Configure our handling of diagnostics. Diagnostic Diags(DiagClient.get()); @@ -2253,7 +2253,7 @@ int main(int argc, char **argv) { // -I- is a deprecated GCC feature, scan for it and reject it. for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) { if (I_dirs[i] == "-") { - Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported); + Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported); I_dirs.erase(I_dirs.begin()+i); --i; } @@ -2262,18 +2262,18 @@ int main(int argc, char **argv) { // Get information about the target being compiled for. std::string Triple = CreateTargetTriple(); llvm::OwningPtr<TargetInfo> Target(TargetInfo::CreateTargetInfo(Triple)); - + if (Target == 0) { - Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple) + Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple) << Triple.c_str(); return 1; } - + if (!InheritanceViewCls.empty()) // C++ visualization? ProgAction = InheritanceView; - + llvm::OwningPtr<SourceManager> SourceMgr; - + // Create a file manager object to provide access to and cache the filesystem. FileManager FileMgr; @@ -2283,35 +2283,35 @@ int main(int argc, char **argv) { for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) { const std::string &InFile = InputFilenames[i]; - + /// Create a SourceManager object. This tracks and owns all the file /// buffers allocated to a translation unit. if (!SourceMgr) SourceMgr.reset(new SourceManager()); else SourceMgr->clearIDTables(); - + // Initialize language options, inferring file types from input filenames. LangOptions LangInfo; DiagClient->setLangOptions(&LangInfo); - + InitializeBaseLanguage(); LangKind LK = GetLanguage(InFile); InitializeLangOptions(LangInfo, LK); InitializeLanguageStandard(LangInfo, LK, Target.get(), Features); - + // Process the -I options and set them in the HeaderInfo. HeaderSearch HeaderInfo(FileMgr); - - + + InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo); - + // Set up the preprocessor with these options. DriverPreprocessorFactory PPFactory(Diags, LangInfo, *Target, *SourceMgr.get(), HeaderInfo); - + llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor()); - + if (!PP) continue; @@ -2342,7 +2342,7 @@ int main(int argc, char **argv) { if (ImplicitIncludePCH.empty()) { if (InitializeSourceManager(*PP.get(), InFile)) continue; - + // Initialize builtin info. PP->getBuiltinInfo().InitializeBuiltins(PP->getIdentifierTable(), PP->getLangOptions().NoBuiltin); @@ -2353,7 +2353,7 @@ int main(int argc, char **argv) { // Process the source file. ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features, Context); - + HeaderInfo.ClearFileInfo(); DiagClient->setLangOptions(0); } @@ -2362,7 +2362,7 @@ int main(int argc, char **argv) { if (unsigned NumDiagnostics = Diags.getNumDiagnostics()) fprintf(stderr, "%d diagnostic%s generated.\n", NumDiagnostics, (NumDiagnostics == 1 ? "" : "s")); - + if (Stats) { FileMgr.PrintStats(); fprintf(stderr, "\n"); @@ -2370,11 +2370,11 @@ int main(int argc, char **argv) { delete ClangFrontendTimer; delete BuildLogFile; - + // If verifying diagnostics and we reached here, all is well. if (VerifyDiagnostics) return 0; - + // Managed static deconstruction. Useful for making things like // -time-passes usable. llvm::llvm_shutdown(); |