diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 545192c4f698..70daebf19706 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -16,7 +16,6 @@ namespace clang { class ASTContext; - class TranslationUnit; class Decl; class TagDecl; class HandleTagDeclDefinition; @@ -40,7 +39,7 @@ public: /// HandleTranslationUnit - This method is called when the ASTs for entire /// translation unit have been parsed. - virtual void HandleTranslationUnit(TranslationUnit& TU) {} + virtual void HandleTranslationUnit(ASTContext &Ctx) {} /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl /// (e.g. struct, union, enum, class) is completed. This allows the client to diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 6c0b68b5dd0d..d41f1339b098 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -74,7 +74,7 @@ namespace { Builder->UpdateCompletedType(D); } - virtual void HandleTranslationUnit(TranslationUnit& TU) { + virtual void HandleTranslationUnit(ASTContext &Ctx) { if (Diags.hasErrorOccurred()) { M.reset(); return; diff --git a/clang/lib/Sema/ParseAST.cpp b/clang/lib/Sema/ParseAST.cpp index bbca5515216c..756a398b4c14 100644 --- a/clang/lib/Sema/ParseAST.cpp +++ b/clang/lib/Sema/ParseAST.cpp @@ -56,7 +56,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, } }; - Consumer->HandleTranslationUnit(TU); + Consumer->HandleTranslationUnit(TU.getContext()); if (PrintStats) { fprintf(stderr, "\nSTATISTICS:\n"); diff --git a/clang/tools/clang-cc/ASTConsumers.cpp b/clang/tools/clang-cc/ASTConsumers.cpp index 288225d1e587..18b4246cb6c5 100644 --- a/clang/tools/clang-cc/ASTConsumers.cpp +++ b/clang/tools/clang-cc/ASTConsumers.cpp @@ -658,8 +658,8 @@ class DeclContextPrinter : public ASTConsumer { public: DeclContextPrinter() : Out(llvm::errs()) {} - void HandleTranslationUnit(TranslationUnit& TU) { - PrintDeclContext(TU.getContext().getTranslationUnitDecl(), 4); + void HandleTranslationUnit(ASTContext &C) { + PrintDeclContext(C.getTranslationUnitDecl(), 4); } void PrintDeclContext(const DeclContext* DC, unsigned Indentation); @@ -935,8 +935,7 @@ class InheritanceViewer : public ASTConsumer { public: InheritanceViewer(const std::string& cname) : clsname(cname) {} - void HandleTranslationUnit(TranslationUnit& TU) { - ASTContext& C = TU.getContext(); + void HandleTranslationUnit(ASTContext &C) { for (ASTContext::type_iterator I=C.types_begin(),E=C.types_end(); I!=E; ++I) if (RecordType *T = dyn_cast(*I)) { if (CXXRecordDecl *D = dyn_cast(T->getDecl())) { @@ -974,7 +973,7 @@ public: SingleFileSerializer(const llvm::sys::Path& F, Diagnostic& diags) : ASTSerializer(diags), FName(F) {} - virtual void HandleTranslationUnit(TranslationUnit& TU) { + virtual void HandleTranslationUnit(ASTContext &Ctx) { if (Diags.hasErrorOccurred()) return; @@ -982,7 +981,7 @@ public: std::vector Buffer; Buffer.reserve(256*1024); - EmitASTBitcodeBuffer(TU.getContext(), Buffer); + EmitASTBitcodeBuffer(Ctx, Buffer); // Write the bits to disk. if (FILE* fp = fopen(FName.c_str(),"wb")) { @@ -998,11 +997,11 @@ public: BuildSerializer(const llvm::sys::Path& dir, Diagnostic& diags) : ASTSerializer(diags), EmitDir(dir) {} - virtual void HandleTranslationUnit(TranslationUnit& TU) { + virtual void HandleTranslationUnit(ASTContext &Ctx) { if (Diags.hasErrorOccurred()) return; - SourceManager& SourceMgr = TU.getContext().getSourceManager(); + SourceManager& SourceMgr = Ctx.getSourceManager(); FileID ID = SourceMgr.getMainFileID(); assert(!ID.isInvalid() && "MainFileID not set!"); const FileEntry* FE = SourceMgr.getFileEntryForID(ID); @@ -1033,7 +1032,7 @@ public: std::vector Buffer; Buffer.reserve(256*1024); - EmitASTBitcodeBuffer(TU.getContext(), Buffer); + EmitASTBitcodeBuffer(Ctx, Buffer); // Write the bits to disk. if (FILE* fp = fopen(FName.c_str(),"wb")) { diff --git a/clang/tools/clang-cc/AnalysisConsumer.cpp b/clang/tools/clang-cc/AnalysisConsumer.cpp index bda3df09759e..03e7ecc8af4d 100644 --- a/clang/tools/clang-cc/AnalysisConsumer.cpp +++ b/clang/tools/clang-cc/AnalysisConsumer.cpp @@ -223,7 +223,7 @@ namespace { } virtual void HandleTopLevelDecl(Decl *D); - virtual void HandleTranslationUnit(TranslationUnit &TU); + virtual void HandleTranslationUnit(ASTContext &C); void HandleCode(Decl* D, Stmt* Body, Actions& actions); }; @@ -444,7 +444,7 @@ void AnalysisConsumer::HandleTopLevelDecl(Decl *D) { } } -void AnalysisConsumer::HandleTranslationUnit(TranslationUnit& TU) { +void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { if(!TranslationUnitActions.empty()) { AnalysisManager mgr(*this, AnalyzerDisplayProgress); @@ -454,7 +454,7 @@ void AnalysisConsumer::HandleTranslationUnit(TranslationUnit& TU) { } if (!ObjCImplementationActions.empty()) { - TranslationUnitDecl *TUD = TU.getContext().getTranslationUnitDecl(); + TranslationUnitDecl *TUD = C.getTranslationUnitDecl(); for (DeclContext::decl_iterator I = TUD->decls_begin(),E = TUD->decls_end(); I != E; ++I) diff --git a/clang/tools/clang-cc/Backend.cpp b/clang/tools/clang-cc/Backend.cpp index 39d5c905f826..ee2d0c56b268 100644 --- a/clang/tools/clang-cc/Backend.cpp +++ b/clang/tools/clang-cc/Backend.cpp @@ -131,13 +131,13 @@ namespace { LLVMIRGeneration.stopTimer(); } - virtual void HandleTranslationUnit(TranslationUnit& TU) { + virtual void HandleTranslationUnit(ASTContext &C) { { PrettyStackTraceString CrashInfo("Per-file LLVM IR generation"); if (CompileOpts.TimePasses) LLVMIRGeneration.startTimer(); - Gen->HandleTranslationUnit(TU); + Gen->HandleTranslationUnit(C); if (CompileOpts.TimePasses) LLVMIRGeneration.stopTimer(); diff --git a/clang/tools/clang-cc/RewriteObjC.cpp b/clang/tools/clang-cc/RewriteObjC.cpp index 2a3460492c50..ee2334ba8ba3 100644 --- a/clang/tools/clang-cc/RewriteObjC.cpp +++ b/clang/tools/clang-cc/RewriteObjC.cpp @@ -15,7 +15,6 @@ #include "clang/Rewrite/Rewriter.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" -#include "clang/AST/TranslationUnit.h" #include "clang/AST/ParentMap.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/IdentifierTable.h" @@ -134,7 +133,7 @@ namespace { ~RewriteObjC() {} - virtual void HandleTranslationUnit(TranslationUnit& TU); + virtual void HandleTranslationUnit(ASTContext &C); void ReplaceStmt(Stmt *Old, Stmt *New) { Stmt *ReplacingStmt = ReplacedNodes[Old]; @@ -4516,7 +4515,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) { // Nothing yet. } -void RewriteObjC::HandleTranslationUnit(TranslationUnit& TU) { +void RewriteObjC::HandleTranslationUnit(ASTContext &C) { // Get the top-level buffer that this corresponds to. // Rewrite tabs if we care. diff --git a/clang/tools/clang-cc/SerializationTest.cpp b/clang/tools/clang-cc/SerializationTest.cpp index 770f9b3b877b..d12a0af306b4 100644 --- a/clang/tools/clang-cc/SerializationTest.cpp +++ b/clang/tools/clang-cc/SerializationTest.cpp @@ -42,7 +42,7 @@ public: ~SerializationTest() {} - virtual void HandleTranslationUnit(TranslationUnit& TU); + virtual void HandleTranslationUnit(ASTContext &C); private: bool Serialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint, @@ -142,7 +142,7 @@ namespace { }; } -void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) { +void SerializationTest::HandleTranslationUnit(ASTContext &Ctx) { std::string ErrMsg; llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg); @@ -157,7 +157,7 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) { llvm::sys::Path FNameDeclBefore = Dir; FNameDeclBefore.appendComponent("test.decl_before.txt"); - if (FNameDeclBefore.makeUnique(true,&ErrMsg)) { + if (FNameDeclBefore.makeUnique(true, &ErrMsg)) { llvm::cerr << "Error: " << ErrMsg << "\n"; return; } @@ -165,7 +165,7 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) { llvm::sys::Path FNameDeclAfter = Dir; FNameDeclAfter.appendComponent("test.decl_after.txt"); - if (FNameDeclAfter.makeUnique(true,&ErrMsg)) { + if (FNameDeclAfter.makeUnique(true, &ErrMsg)) { llvm::cerr << "Error: " << ErrMsg << "\n"; return; } @@ -173,13 +173,13 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) { llvm::sys::Path ASTFilename = Dir; ASTFilename.appendComponent("test.ast"); - if (ASTFilename.makeUnique(true,&ErrMsg)) { + if (ASTFilename.makeUnique(true, &ErrMsg)) { llvm::cerr << "Error: " << ErrMsg << "\n"; return; } // Serialize and then deserialize the ASTs. - bool status = Serialize(ASTFilename, FNameDeclBefore, TU.getContext()); + bool status = Serialize(ASTFilename, FNameDeclBefore, Ctx); assert (status && "Serialization failed."); status = Deserialize(ASTFilename, FNameDeclAfter); assert (status && "Deserialization failed.");