From: Chris Lattner Date: Thu, 13 Sep 2007 01:14:03 +0000 (+0000) Subject: make the sourcemgr available through ASTContext. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b800dc2d5e27ec60f567567b623cdc61152b8fb8;p=clang make the sourcemgr available through ASTContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41906 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/DeadStores.cpp b/Analysis/DeadStores.cpp index 91034e3894..e898f3ca57 100644 --- a/Analysis/DeadStores.cpp +++ b/Analysis/DeadStores.cpp @@ -29,7 +29,9 @@ class DeadStoreObserver : public LiveVariablesObserver { ASTContext Ctx; public: DeadStoreObserver(Preprocessor& pp) : - PP(pp), Ctx(PP.getTargetInfo(), PP.getIdentifierTable()) {} + PP(pp), Ctx(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()) { + } virtual ~DeadStoreObserver() {} diff --git a/Driver/ASTStreamers.cpp b/Driver/ASTStreamers.cpp index 6fe6fac411..342ee6b327 100644 --- a/Driver/ASTStreamers.cpp +++ b/Driver/ASTStreamers.cpp @@ -27,7 +27,8 @@ void clang::BuildASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) { Stmt::CollectingStats(true); } - ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable()); + ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()); ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID); while (ASTStreamer_ReadTopLevelDecl(Streamer)) @@ -106,7 +107,8 @@ static void PrintObjcInterfaceDecl(ObjcInterfaceDecl *OID) { } void clang::PrintASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) { - ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable()); + ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()); ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID); while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) { @@ -137,7 +139,8 @@ void clang::PrintASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) { } void clang::DumpASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) { - ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable()); + ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()); ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID); while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) { @@ -184,7 +187,8 @@ static void VisitCFGs(CFGVisitor& Visitor, Preprocessor& PP, unsigned MainFileID, bool Stats) { bool printFDecl = Visitor.printFuncDeclStart(); - ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable()); + ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()); ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID); while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) { diff --git a/Driver/LLVMCodegen.cpp b/Driver/LLVMCodegen.cpp index b969ff81ca..95d23f584e 100644 --- a/Driver/LLVMCodegen.cpp +++ b/Driver/LLVMCodegen.cpp @@ -29,7 +29,8 @@ void clang::EmitLLVMFromASTs(Preprocessor &PP, unsigned MainFileID, bool PrintStats) { Diagnostic &Diags = PP.getDiagnostics(); // Create the streamer to read the file. - ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable()); + ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(), + PP.getIdentifierTable()); ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID); // Create the module to codegen into. diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index f1e0959e0c..cc7ac8e0a9 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -40,6 +40,7 @@ class ASTContext { RecordDecl *CFConstantStringTypeDecl; llvm::StringMap SelectorNames; public: + SourceManager &SourceMgr; TargetInfo &Target; IdentifierTable &Idents; Builtin::Context BuiltinInfo; @@ -54,8 +55,8 @@ public: QualType FloatTy, DoubleTy, LongDoubleTy; QualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; - ASTContext(TargetInfo &t, IdentifierTable &idents) : - CFConstantStringTypeDecl(0), Target(t), Idents(idents) { + ASTContext(SourceManager &SM, TargetInfo &t, IdentifierTable &idents) : + CFConstantStringTypeDecl(0), SourceMgr(SM), Target(t), Idents(idents) { InitBuiltinTypes(); BuiltinInfo.InitializeBuiltins(idents, Target); }