diff options
Diffstat (limited to 'lib/Frontend')
33 files changed, 1862 insertions, 1944 deletions
diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp index 178f1bf8e1..954ebd6997 100644 --- a/lib/Frontend/ASTConsumers.cpp +++ b/lib/Frontend/ASTConsumers.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/ASTConsumers.h" -#include "clang/Frontend/DocumentXML.h" +#include "clang/Frontend/DocumentXML.h" #include "clang/Frontend/PathDiagnosticClients.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" @@ -37,11 +37,11 @@ namespace { class ASTPrinter : public ASTConsumer { llvm::raw_ostream &Out; bool Dump; - + public: - ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false) + ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false) : Out(o? *o : llvm::errs()), Dump(Dump) { } - + virtual void HandleTranslationUnit(ASTContext &Context) { PrintingPolicy Policy = Context.PrintingPolicy; Policy.Dump = Dump; @@ -63,21 +63,19 @@ namespace { public: ASTPrinterXML(llvm::raw_ostream& o) : Doc("CLANG_XML", o) {} - + void Initialize(ASTContext &Context) { Doc.initialize(Context); } virtual void HandleTranslationUnit(ASTContext &Ctx) { Doc.addSubNode("TranslationUnit"); - for (DeclContext::decl_iterator + for (DeclContext::decl_iterator D = Ctx.getTranslationUnitDecl()->decls_begin(), DEnd = Ctx.getTranslationUnitDecl()->decls_end(); - D != DEnd; + D != DEnd; ++D) - { Doc.PrintDecl(*D); - } Doc.toParent(); Doc.finalize(); } @@ -88,9 +86,9 @@ namespace { ASTConsumer *clang::CreateASTPrinterXML(llvm::raw_ostream* out) { return new ASTPrinterXML(out ? *out : llvm::outs()); } - -ASTConsumer *clang::CreateASTDumper() { - return new ASTPrinter(0, true); + +ASTConsumer *clang::CreateASTDumper() { + return new ASTPrinter(0, true); } //===----------------------------------------------------------------------===// @@ -108,7 +106,7 @@ namespace { for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) HandleTopLevelSingleDecl(*I); } - + void HandleTopLevelSingleDecl(Decl *D); }; } @@ -116,7 +114,7 @@ namespace { void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { FD->print(llvm::errs()); - + if (FD->getBodyIfAvailable()) { llvm::errs() << '\n'; FD->getBodyIfAvailable()->viewAST(); @@ -124,10 +122,10 @@ void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { } return; } - + if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { MD->print(llvm::errs()); - + if (MD->getBody()) { llvm::errs() << '\n'; MD->getBody()->viewAST(); @@ -157,7 +155,7 @@ public: }; } // end anonymous namespace -void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, +void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, unsigned Indentation) { // Print DeclContext name. switch (DC->getDeclKind()) { @@ -231,7 +229,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, // Print the parameters. Out << "("; bool PrintComma = false; - for (FunctionDecl::param_const_iterator I = FD->param_begin(), + for (FunctionDecl::param_const_iterator I = FD->param_begin(), E = FD->param_end(); I != E; ++I) { if (PrintComma) Out << ", "; @@ -254,7 +252,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, // Print the parameters. Out << "("; bool PrintComma = false; - for (FunctionDecl::param_const_iterator I = D->param_begin(), + for (FunctionDecl::param_const_iterator I = D->param_begin(), E = D->param_end(); I != E; ++I) { if (PrintComma) Out << ", "; @@ -284,7 +282,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, // Print the parameters. Out << "("; bool PrintComma = false; - for (FunctionDecl::param_const_iterator I = D->param_begin(), + for (FunctionDecl::param_const_iterator I = D->param_begin(), E = D->param_end(); I != E; ++I) { if (PrintComma) Out << ", "; @@ -354,7 +352,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, case Decl::CXXRecord: case Decl::ObjCMethod: case Decl::ObjCInterface: - case Decl::ObjCCategory: + case Decl::ObjCCategory: case Decl::ObjCProtocol: case Decl::ObjCImplementation: case Decl::ObjCCategoryImpl: @@ -416,8 +414,8 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, } } } -ASTConsumer *clang::CreateDeclContextPrinter() { - return new DeclContextPrinter(); +ASTConsumer *clang::CreateDeclContextPrinter() { + return new DeclContextPrinter(); } //===----------------------------------------------------------------------===// @@ -428,7 +426,7 @@ class InheritanceViewer : public ASTConsumer { const std::string clsname; public: InheritanceViewer(const std::string& cname) : clsname(cname) {} - + void HandleTranslationUnit(ASTContext &C) { for (ASTContext::type_iterator I=C.types_begin(),E=C.types_end(); I!=E; ++I) if (RecordType *T = dyn_cast<RecordType>(*I)) { @@ -436,12 +434,12 @@ public: // FIXME: This lookup needs to be generalized to handle namespaces and // (when we support them) templates. if (D->getNameAsString() == clsname) { - D->viewInheritance(C); + D->viewInheritance(C); } } } } -}; +}; } ASTConsumer *clang::CreateInheritanceViewer(const std::string& clsname) { diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 4cd92808f5..609889aad9 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -38,38 +38,38 @@ class VISIBILITY_HIDDEN PCHInfoCollector : public PCHReaderListener { std::string &TargetTriple; std::string &Predefines; unsigned &Counter; - + unsigned NumHeaderInfos; - + public: PCHInfoCollector(LangOptions &LangOpt, HeaderSearch &HSI, std::string &TargetTriple, std::string &Predefines, unsigned &Counter) : LangOpt(LangOpt), HSI(HSI), TargetTriple(TargetTriple), Predefines(Predefines), Counter(Counter), NumHeaderInfos(0) {} - + virtual bool ReadLanguageOptions(const LangOptions &LangOpts) { LangOpt = LangOpts; return false; } - + virtual bool ReadTargetTriple(const std::string &Triple) { TargetTriple = Triple; return false; } - - virtual bool ReadPredefinesBuffer(const char *PCHPredef, + + virtual bool ReadPredefinesBuffer(const char *PCHPredef, unsigned PCHPredefLen, FileID PCHBufferID, std::string &SuggestedPredefines) { Predefines = PCHPredef; return false; } - + virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI) { HSI.setHeaderFileInfoForUID(HFI, NumHeaderInfos++); } - + virtual void ReadCounter(unsigned Value) { Counter = Value; } @@ -88,7 +88,7 @@ FileManager &ASTUnit::getFileManager() { ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, FileManager &FileMgr, std::string *ErrMsg) { - + llvm::OwningPtr<ASTUnit> AST(new ASTUnit()); AST->DiagClient.reset(new TextDiagnosticBuffer()); @@ -96,12 +96,12 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, AST->HeaderInfo.reset(new HeaderSearch(FileMgr)); AST->SourceMgr.reset(new SourceManager()); - + Diagnostic &Diags = *AST->Diags.get(); SourceManager &SourceMgr = *AST->SourceMgr.get(); // Gather Info for preprocessor construction later on. - + LangOptions LangInfo; HeaderSearch &HeaderInfo = *AST->HeaderInfo.get(); std::string TargetTriple; @@ -118,16 +118,16 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, switch (Reader->ReadPCH(Filename)) { case PCHReader::Success: break; - + case PCHReader::Failure: case PCHReader::IgnorePCH: if (ErrMsg) *ErrMsg = "Could not load PCH file"; return NULL; } - + // PCH loaded successfully. Now create the preprocessor. - + // Get information about the target being compiled for. AST->Target.reset(TargetInfo::CreateTargetInfo(TargetTriple)); AST->PP.reset(new Preprocessor(Diags, LangInfo, *AST->Target.get(), @@ -137,7 +137,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, PP.setPredefines(Predefines); PP.setCounterValue(Counter); Reader->setPreprocessor(PP); - + // Create and initialize the ASTContext. AST->Ctx.reset(new ASTContext(LangInfo, @@ -149,14 +149,14 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, /* FreeMemory = */ true, /* size_reserve = */0)); ASTContext &Context = *AST->Ctx.get(); - + Reader->InitializeContext(Context); - + // Attach the PCH reader to the AST context as an external AST // source, so that declarations will be deserialized from the // PCH file as needed. Source.reset(Reader.take()); Context.setExternalSource(Source); - return AST.take(); + return AST.take(); } diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index a633a62df2..2d07d89e04 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -44,7 +44,7 @@ static ExplodedNode::Auditor* CreateUbiViz(); // Basic type definitions. //===----------------------------------------------------------------------===// -namespace { +namespace { typedef void (*CodeAction)(AnalysisManager& Mgr); } // end anonymous namespace @@ -55,8 +55,8 @@ namespace { static PathDiagnosticClient* CreatePlistHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP, PreprocessorFactory* PPF) { - llvm::sys::Path F(prefix); - PathDiagnosticClientFactory *PF = + llvm::sys::Path F(prefix); + PathDiagnosticClientFactory *PF = CreateHTMLDiagnosticClientFactory(F.getDirname(), PP, PPF); return CreatePlistDiagnosticClient(prefix, PP, PPF, PF); } @@ -73,9 +73,9 @@ namespace { Actions ObjCMethodActions; Actions ObjCImplementationActions; Actions TranslationUnitActions; - + public: - const LangOptions& LOpts; + const LangOptions& LOpts; Diagnostic &Diags; ASTContext* Ctx; Preprocessor* PP; @@ -127,7 +127,7 @@ namespace { #include "clang/Frontend/Analyses.def" } } - + if (ManagerRegistry::ConstraintMgrCreator != 0) CreateConstraintMgr = ManagerRegistry::ConstraintMgrCreator; else { @@ -140,42 +140,42 @@ namespace { } } } - + void addCodeAction(CodeAction action) { FunctionActions.push_back(action); ObjCMethodActions.push_back(action); } - + void addObjCImplementationAction(CodeAction action) { ObjCImplementationActions.push_back(action); } - + void addTranslationUnitAction(CodeAction action) { TranslationUnitActions.push_back(action); } - + virtual void Initialize(ASTContext &Context) { Ctx = &Context; - Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD, + Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD, CreateStoreMgr, CreateConstraintMgr, - Opts.AnalyzerDisplayProgress, - Opts.VisualizeEGDot, Opts.VisualizeEGUbi, + Opts.AnalyzerDisplayProgress, + Opts.VisualizeEGDot, Opts.VisualizeEGUbi, Opts.PurgeDead, Opts.EagerlyAssume, Opts.TrimGraph)); } - + virtual void HandleTopLevelDecl(DeclGroupRef D) { for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) HandleTopLevelSingleDecl(*I); } - + void HandleTopLevelSingleDecl(Decl *D); virtual void HandleTranslationUnit(ASTContext &C); - + void HandleCode(Decl* D, Stmt* Body, Actions& actions); }; - - + + } // end anonymous namespace @@ -184,54 +184,54 @@ namespace llvm { static inline void Profile(CodeAction X, FoldingSetNodeID& ID) { ID.AddPointer(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(X))); } - }; + }; } //===----------------------------------------------------------------------===// // AnalysisConsumer implementation. //===----------------------------------------------------------------------===// -void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { +void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { switch (D->getKind()) { case Decl::Function: { FunctionDecl* FD = cast<FunctionDecl>(D); - if (Opts.AnalyzeSpecificFunction.size() > 0 && + if (Opts.AnalyzeSpecificFunction.size() > 0 && Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName()) break; - + Stmt* Body = FD->getBody(); if (Body) HandleCode(FD, Body, FunctionActions); break; } - + case Decl::ObjCMethod: { ObjCMethodDecl* MD = cast<ObjCMethodDecl>(D); - + if (Opts.AnalyzeSpecificFunction.size() > 0 && Opts.AnalyzeSpecificFunction != MD->getSelector().getAsString()) return; - + Stmt* Body = MD->getBody(); if (Body) HandleCode(MD, Body, ObjCMethodActions); break; } - + default: break; } } void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { - if(!TranslationUnitActions.empty()) { - for (Actions::iterator I = TranslationUnitActions.begin(), + if (!TranslationUnitActions.empty()) { + for (Actions::iterator I = TranslationUnitActions.begin(), E = TranslationUnitActions.end(); I != E; ++I) - (*I)(*Mgr); + (*I)(*Mgr); } if (!ObjCImplementationActions.empty()) { TranslationUnitDecl *TUD = C.getTranslationUnitDecl(); - + for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end(); I != E; ++I) @@ -246,7 +246,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { } void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) { - + // Don't run the actions if an error has occured with parsing the file. if (Diags.hasErrorOccurred()) return; @@ -255,13 +255,13 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) { // otherwise specified. if (!Opts.AnalyzeAll && !Ctx->getSourceManager().isFromMainFile(D->getLocation())) - return; + return; Mgr->setEntryContext(D); - - // Dispatch on the actions. + + // Dispatch on the actions. for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I) - (*I)(*Mgr); + (*I)(*Mgr); } //===----------------------------------------------------------------------===// @@ -283,8 +283,8 @@ static void ActionWarnUninitVals(AnalysisManager& mgr) { static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, bool StandardWarnings = true) { - - + + llvm::OwningPtr<GRTransferFuncs> TF(tf); // Display progress. @@ -297,7 +297,7 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, GRExprEngine Eng(mgr); Eng.setTransferFunctions(tf); - + if (StandardWarnings) { Eng.RegisterInternalChecks(); RegisterAppleChecks(Eng, *mgr.getCodeDecl()); @@ -309,10 +309,10 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, Auditor.reset(CreateUbiViz()); ExplodedNode::SetAuditor(Auditor.get()); } - + // Execute the worklist algorithm. Eng.ExecuteWorkList(mgr.getEntryStackFrame()); - + // Release the auditor (if any) so that it doesn't monitor the graph // created BugReporter. ExplodedNode::SetAuditor(0); @@ -320,34 +320,34 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, // Visualize the exploded graph. if (mgr.shouldVisualizeGraphviz()) Eng.ViewGraph(mgr.shouldTrimGraph()); - + // Display warnings. Eng.getBugReporter().FlushReports(); } static void ActionCheckerCFRefAux(AnalysisManager& mgr, bool GCEnabled, bool StandardWarnings) { - + GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getASTContext(), GCEnabled, mgr.getLangOptions()); - + ActionGRExprEngine(mgr, TF, StandardWarnings); } static void ActionCheckerCFRef(AnalysisManager& mgr) { - + switch (mgr.getLangOptions().getGCMode()) { default: assert (false && "Invalid GC mode."); case LangOptions::NonGC: ActionCheckerCFRefAux(mgr, false, true); break; - + case LangOptions::GCOnly: ActionCheckerCFRefAux(mgr, true, true); break; - + case LangOptions::HybridGC: ActionCheckerCFRefAux(mgr, false, true); ActionCheckerCFRefAux(mgr, true, false); @@ -357,7 +357,7 @@ static void ActionCheckerCFRef(AnalysisManager& mgr) { static void ActionDisplayLiveVariables(AnalysisManager& mgr) { if (LiveVariables* L = mgr.getLiveVariables()) { - mgr.DisplayFunction(); + mgr.DisplayFunction(); L->dumpBlockLiveness(mgr.getSourceManager()); } } @@ -377,28 +377,28 @@ static void ActionCFGView(AnalysisManager& mgr) { } static void ActionSecuritySyntacticChecks(AnalysisManager &mgr) { - BugReporter BR(mgr); + BugReporter BR(mgr); CheckSecuritySyntaxOnly(mgr.getCodeDecl(), BR); } static void ActionWarnObjCDealloc(AnalysisManager& mgr) { if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly) return; - + BugReporter BR(mgr); - - CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), - mgr.getLangOptions(), BR); + + CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), + mgr.getLangOptions(), BR); } static void ActionWarnObjCUnusedIvars(AnalysisManager& mgr) { BugReporter BR(mgr); - CheckObjCUnusedIvar(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR); + CheckObjCUnusedIvar(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR); } static void ActionWarnObjCMethSigs(AnalysisManager& mgr) { BugReporter BR(mgr); - + CheckObjCInstMethSignature(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR); } @@ -426,7 +426,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp, #include "clang/Frontend/Analyses.def" default: break; } - + // Last, disable the effects of '-Werror' when using the AnalysisConsumer. diags.setWarningsAsErrors(false); @@ -438,7 +438,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp, //===----------------------------------------------------------------------===// namespace { - + class UbigraphViz : public ExplodedNode::Auditor { llvm::OwningPtr<llvm::raw_ostream> Out; llvm::sys::Path Dir, Filename; @@ -446,21 +446,21 @@ class UbigraphViz : public ExplodedNode::Auditor { typedef llvm::DenseMap<void*,unsigned> VMap; VMap M; - + public: UbigraphViz(llvm::raw_ostream* out, llvm::sys::Path& dir, llvm::sys::Path& filename); - + ~UbigraphViz(); - - virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst); + + virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst); }; - + } // end anonymous namespace static ExplodedNode::Auditor* CreateUbiViz() { std::string ErrMsg; - + llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg); if (!ErrMsg.empty()) return 0; @@ -473,31 +473,31 @@ static ExplodedNode::Auditor* CreateUbiViz() { return 0; llvm::errs() << "Writing '" << Filename.str() << "'.\n"; - + llvm::OwningPtr<llvm::raw_fd_ostream> Stream; Stream.reset(new llvm::raw_fd_ostream(Filename.c_str(), ErrMsg)); if (!ErrMsg.empty()) return 0; - + return new UbigraphViz(Stream.take(), Dir, Filename); } void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) { - + assert (Src != Dst && "Self-edges are not allowed."); - + // Lookup the Src. If it is a new node, it's a root. VMap::iterator SrcI= M.find(Src); unsigned SrcID; - + if (SrcI == M.end()) { M[Src] = SrcID = Cntr++; *Out << "('vertex', " << SrcID << ", ('color','#00ff00'))\n"; } else SrcID = SrcI->second; - + // Lookup the Dst. VMap::iterator DstI= M.find(Dst); unsigned DstID; @@ -513,7 +513,7 @@ void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) { } // Add the edge. - *Out << "('edge', " << SrcID << ", " << DstID + *Out << "('edge', " << SrcID << ", " << DstID << ", ('arrow','true'), ('oriented', 'true'))\n"; } @@ -535,11 +535,11 @@ UbigraphViz::~UbigraphViz() { args.push_back(Ubiviz.c_str()); args.push_back(Filename.c_str()); args.push_back(0); - + if (llvm::sys::Program::ExecuteAndWait(Ubiviz, &args[0],0,0,0,0,&ErrMsg)) { llvm::errs() << "Error viewing graph: " << ErrMsg << "\n"; } - + // Delete the directory. - Dir.eraseFromDisk(true); + Dir.eraseFromDisk(true); } diff --git a/lib/Frontend/Backend.cpp b/lib/Frontend/Backend.cpp index 964b4700fe..d7097b7f06 100644 --- a/lib/Frontend/Backend.cpp +++ b/lib/Frontend/Backend.cpp @@ -47,9 +47,9 @@ namespace { Timer LLVMIRGeneration; Timer CodeGenerationTime; - + llvm::OwningPtr<CodeGenerator> Gen; - + llvm::Module *TheModule; llvm::TargetData *TheTargetData; @@ -72,13 +72,13 @@ namespace { bool AddEmitPasses(std::string &Error); void EmitAssembly(); - - public: - BackendConsumer(BackendAction action, Diagnostic &Diags, + + public: + BackendConsumer(BackendAction action, Diagnostic &Diags, const LangOptions &langopts, const CompileOptions &compopts, const std::string &infile, llvm::raw_ostream* OS, LLVMContext& C) : - Action(action), + Action(action), CompileOpts(compopts), AsmOutStream(OS), LLVMIRGeneration("LLVM IR Generation Time"), @@ -86,11 +86,11 @@ namespace { Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)), TheModule(0), TheTargetData(0), ModuleProvider(0), CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) { - + if (AsmOutStream) FormattedOutStream.setStream(*AsmOutStream, formatted_raw_ostream::PRESERVE_STREAM); - + // Enable -time-passes if -ftime-report is enabled. llvm::TimePassesIsEnabled = CompileOpts.TimePasses; } @@ -105,25 +105,25 @@ namespace { virtual void Initialize(ASTContext &Ctx) { Context = &Ctx; - + if (CompileOpts.TimePasses) LLVMIRGeneration.startTimer(); - + Gen->Initialize(Ctx); TheModule = Gen->GetModule(); ModuleProvider = new ExistingModuleProvider(TheModule); TheTargetData = new llvm::TargetData(Ctx.Target.getTargetDescription()); - + if (CompileOpts.TimePasses) LLVMIRGeneration.stopTimer(); } - + virtual void HandleTopLevelDecl(DeclGroupRef D) { PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(), Context->getSourceManager(), "LLVM IR generation of declaration"); - + if (CompileOpts.TimePasses) LLVMIRGeneration.startTimer(); @@ -132,7 +132,7 @@ namespace { if (CompileOpts.TimePasses) LLVMIRGeneration.stopTimer(); } - + virtual void HandleTranslationUnit(ASTContext &C) { { PrettyStackTraceString CrashInfo("Per-file LLVM IR generation"); @@ -147,12 +147,12 @@ namespace { // EmitAssembly times and registers crash info itself. EmitAssembly(); - + // Force a flush here in case we never get released. if (AsmOutStream) FormattedOutStream.flush(); } - + virtual void HandleTagDeclDefinition(TagDecl *D) { PrettyStackTraceDecl CrashInfo(D, SourceLocation(), Context->getSourceManager(), @@ -163,7 +163,7 @@ namespace { virtual void CompleteTentativeDefinition(VarDecl *D) { Gen->CompleteTentativeDefinition(D); } - }; + }; } FunctionPassManager *BackendConsumer::getCodeGenPasses() const { @@ -216,18 +216,18 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) { if (CompileOpts.CPU.size() || CompileOpts.Features.size()) { SubtargetFeatures Features; Features.setCPU(CompileOpts.CPU); - for (std::vector<std::string>::iterator + for (std::vector<std::string>::iterator it = CompileOpts.Features.begin(), ie = CompileOpts.Features.end(); it != ie; ++it) Features.AddFeature(*it); FeaturesStr = Features.getString(); } TargetMachine *TM = TheTarget->createTargetMachine(Triple, FeaturesStr); - + // Set register scheduler & allocation policy. RegisterScheduler::setDefault(createDefaultScheduler); - RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator : - createLinearScanRegisterAllocator); + RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator : + |