[cfe-commits] r67905 - in /cfe/trunk: include/clang/AST/TranslationUnit.h lib/AST/TranslationUnit.cpp tools/clang-cc/ASTConsumers.cpp tools/clang-cc/SerializationTest.cpp

Chris Lattner sabre at nondot.org
Fri Mar 27 20:56:54 PDT 2009


Author: lattner
Date: Fri Mar 27 22:56:54 2009
New Revision: 67905

URL: http://llvm.org/viewvc/llvm-project?rev=67905&view=rev
Log:
hoist TranslationUnit some more.

Modified:
    cfe/trunk/include/clang/AST/TranslationUnit.h
    cfe/trunk/lib/AST/TranslationUnit.cpp
    cfe/trunk/tools/clang-cc/ASTConsumers.cpp
    cfe/trunk/tools/clang-cc/SerializationTest.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/TranslationUnit.h (original)
+++ cfe/trunk/include/clang/AST/TranslationUnit.h Fri Mar 27 22:56:54 2009
@@ -62,7 +62,7 @@
 };
   
 /// EmitASTBitcodeBuffer - Emit a translation unit to a buffer.
-bool EmitASTBitcodeBuffer(const TranslationUnit& TU, 
+bool EmitASTBitcodeBuffer(const ASTContext &Ctx, 
                           std::vector<unsigned char>& Buffer);
 
 /// ReadASTBitcodeBuffer - Reconsitute a translation unit from a buffer.

Modified: cfe/trunk/lib/AST/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TranslationUnit.cpp?rev=67905&r1=67904&r2=67905&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/lib/AST/TranslationUnit.cpp Fri Mar 27 22:56:54 2009
@@ -39,7 +39,7 @@
   }  
 }
 
-bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU, 
+bool clang::EmitASTBitcodeBuffer(const ASTContext &Ctx, 
                                  std::vector<unsigned char>& Buffer) {
   // Create bitstream.
   llvm::BitstreamWriter Stream(Buffer);
@@ -58,7 +58,7 @@
     llvm::Serializer Sezr(Stream);  
     
     // Emit the translation unit.
-    TU.getContext().EmitAll(Sezr);
+    Ctx.EmitAll(Sezr);
   }
   
   return true;

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

==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.cpp (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.cpp Fri Mar 27 22:56:54 2009
@@ -982,7 +982,7 @@
     std::vector<unsigned char> Buffer;
     Buffer.reserve(256*1024);
     
-    EmitASTBitcodeBuffer(TU,Buffer);
+    EmitASTBitcodeBuffer(TU.getContext(), Buffer);
     
     // Write the bits to disk. 
     if (FILE* fp = fopen(FName.c_str(),"wb")) {
@@ -1033,7 +1033,7 @@
     std::vector<unsigned char> Buffer;
     Buffer.reserve(256*1024);
     
-    EmitASTBitcodeBuffer(TU,Buffer);
+    EmitASTBitcodeBuffer(TU.getContext(), Buffer);
     
     // Write the bits to disk. 
     if (FILE* fp = fopen(FName.c_str(),"wb")) {

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

==============================================================================
--- cfe/trunk/tools/clang-cc/SerializationTest.cpp (original)
+++ cfe/trunk/tools/clang-cc/SerializationTest.cpp Fri Mar 27 22:56:54 2009
@@ -46,7 +46,7 @@
   
 private:
   bool Serialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint,
-                 TranslationUnit& TU);
+                 ASTContext &Ctx);
   
   bool Deserialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint);
 };
@@ -61,7 +61,7 @@
 
 bool SerializationTest::Serialize(llvm::sys::Path& Filename,
                                   llvm::sys::Path& FNameDeclPrint,
-                                  TranslationUnit& TU) {
+                                  ASTContext &Ctx) {
   { 
     // Pretty-print the decls to a temp file.
     std::string Err;
@@ -69,7 +69,9 @@
     assert (Err.empty() && "Could not open file for printing out decls.");
     llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
     
-    for (TranslationUnit::iterator I=TU.begin(), E=TU.end(); I!=E; ++I)
+    TranslationUnitDecl *TUD = Ctx.getTranslationUnitDecl();
+    for (DeclContext::decl_iterator I = TUD->decls_begin(), E =TUD->decls_end();
+         I != E; ++I)
       FilePrinter->HandleTopLevelDecl(*I);
   }
   
@@ -79,7 +81,7 @@
   std::vector<unsigned char> Buffer;
   Buffer.reserve(256*1024);
   
-  EmitASTBitcodeBuffer(TU,Buffer);
+  EmitASTBitcodeBuffer(Ctx, Buffer);
   
   // Write the bits to disk. 
   if (FILE* fp = fopen(Filename.c_str(),"wb")) {
@@ -177,7 +179,7 @@
   }
   
   // Serialize and then deserialize the ASTs.
-  bool status = Serialize(ASTFilename, FNameDeclBefore, TU);
+  bool status = Serialize(ASTFilename, FNameDeclBefore, TU.getContext());
   assert (status && "Serialization failed.");  
   status = Deserialize(ASTFilename, FNameDeclAfter);
   assert (status && "Deserialization failed.");





More information about the cfe-commits mailing list