[cfe-commits] r67910 - in /cfe/trunk: include/clang/AST/ASTConsumer.h lib/CodeGen/ModuleBuilder.cpp lib/Sema/ParseAST.cpp tools/clang-cc/ASTConsumers.cpp tools/clang-cc/AnalysisConsumer.cpp tools/clang-cc/Backend.cpp tools/clang-cc/RewriteObjC.cpp tools/clang-cc/SerializationTest.cpp

Chris Lattner sabre at nondot.org
Fri Mar 27 21:11:33 PDT 2009


Author: lattner
Date: Fri Mar 27 23:11:33 2009
New Revision: 67910

URL: http://llvm.org/viewvc/llvm-project?rev=67910&view=rev
Log:
change HandleTranslationUnit to take an ASTContext instead of TranslationUnit

Modified:
    cfe/trunk/include/clang/AST/ASTConsumer.h
    cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
    cfe/trunk/lib/Sema/ParseAST.cpp
    cfe/trunk/tools/clang-cc/ASTConsumers.cpp
    cfe/trunk/tools/clang-cc/AnalysisConsumer.cpp
    cfe/trunk/tools/clang-cc/Backend.cpp
    cfe/trunk/tools/clang-cc/RewriteObjC.cpp
    cfe/trunk/tools/clang-cc/SerializationTest.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Fri Mar 27 23:11:33 2009
@@ -16,7 +16,6 @@
 
 namespace clang {
   class ASTContext;
-  class TranslationUnit;
   class Decl;
   class TagDecl;
   class HandleTagDeclDefinition;
@@ -40,7 +39,7 @@
   
   /// 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

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Fri Mar 27 23:11:33 2009
@@ -74,7 +74,7 @@
       Builder->UpdateCompletedType(D);
     }
 
-    virtual void HandleTranslationUnit(TranslationUnit& TU) {
+    virtual void HandleTranslationUnit(ASTContext &Ctx) {
       if (Diags.hasErrorOccurred()) {
         M.reset();
         return;

Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Fri Mar 27 23:11:33 2009
@@ -56,7 +56,7 @@
     }
   };
   
-  Consumer->HandleTranslationUnit(TU);
+  Consumer->HandleTranslationUnit(TU.getContext());
 
   if (PrintStats) {
     fprintf(stderr, "\nSTATISTICS:\n");

Modified: cfe/trunk/tools/clang-cc/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/ASTConsumers.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.cpp (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.cpp Fri Mar 27 23:11:33 2009
@@ -658,8 +658,8 @@
 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 @@
 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<RecordType>(*I)) {
         if (CXXRecordDecl *D = dyn_cast<CXXRecordDecl>(T->getDecl())) {
@@ -974,7 +973,7 @@
   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 @@
     std::vector<unsigned char> 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 @@
   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 @@
     std::vector<unsigned char> 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")) {

Modified: cfe/trunk/tools/clang-cc/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/AnalysisConsumer.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/AnalysisConsumer.cpp (original)
+++ cfe/trunk/tools/clang-cc/AnalysisConsumer.cpp Fri Mar 27 23:11:33 2009
@@ -223,7 +223,7 @@
     }
     
     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::HandleTranslationUnit(TranslationUnit& TU) {
+void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
 
   if(!TranslationUnitActions.empty()) {
     AnalysisManager mgr(*this, AnalyzerDisplayProgress);
@@ -454,7 +454,7 @@
   }
 
   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)

Modified: cfe/trunk/tools/clang-cc/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Backend.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/Backend.cpp (original)
+++ cfe/trunk/tools/clang-cc/Backend.cpp Fri Mar 27 23:11:33 2009
@@ -131,13 +131,13 @@
         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();

Modified: cfe/trunk/tools/clang-cc/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/RewriteObjC.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/RewriteObjC.cpp (original)
+++ cfe/trunk/tools/clang-cc/RewriteObjC.cpp Fri Mar 27 23:11:33 2009
@@ -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 @@
 
     ~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 @@
   // 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.

Modified: cfe/trunk/tools/clang-cc/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/SerializationTest.cpp?rev=67910&r1=67909&r2=67910&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/SerializationTest.cpp (original)
+++ cfe/trunk/tools/clang-cc/SerializationTest.cpp Fri Mar 27 23:11:33 2009
@@ -42,7 +42,7 @@
   
   ~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 @@
   };
 }
 
-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 @@
   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 @@
   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 @@
   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.");





More information about the cfe-commits mailing list