diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-28 04:27:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-28 04:27:18 +0000 |
commit | a5adead17bb94f8517cd85f28aad57de785feaa1 (patch) | |
tree | e571e82231ded04af224d354792c264ad0d89d94 /clang/tools | |
parent | 72f307a26e85109dacc68887807734a1b72ad6a7 (diff) | |
download | bcm5719-llvm-a5adead17bb94f8517cd85f28aad57de785feaa1.tar.gz bcm5719-llvm-a5adead17bb94f8517cd85f28aad57de785feaa1.zip |
push more ASTContext goodness out through interfaces that use
TranslationUnit
llvm-svn: 67913
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/clang-cc/ASTConsumers.cpp | 8 | ||||
-rw-r--r-- | clang/tools/clang-cc/Backend.cpp | 1 | ||||
-rw-r--r-- | clang/tools/clang-cc/SerializationTest.cpp | 14 | ||||
-rw-r--r-- | clang/tools/clang-cc/clang.cpp | 14 |
4 files changed, 20 insertions, 17 deletions
diff --git a/clang/tools/clang-cc/ASTConsumers.cpp b/clang/tools/clang-cc/ASTConsumers.cpp index 18b4246cb6c..5b4287a2bd1 100644 --- a/clang/tools/clang-cc/ASTConsumers.cpp +++ b/clang/tools/clang-cc/ASTConsumers.cpp @@ -13,18 +13,18 @@ #include "ASTConsumers.h" #include "clang/Frontend/PathDiagnosticClients.h" -#include "clang/AST/TranslationUnit.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" #include "clang/CodeGen/ModuleBuilder.h" #include "llvm/Module.h" #include "llvm/Support/Streams.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" - +#include "llvm/System/Path.h" using namespace clang; //===----------------------------------------------------------------------===// @@ -981,7 +981,7 @@ public: std::vector<unsigned char> Buffer; Buffer.reserve(256*1024); - EmitASTBitcodeBuffer(Ctx, Buffer); + Ctx.EmitASTBitcodeBuffer(Buffer); // Write the bits to disk. if (FILE* fp = fopen(FName.c_str(),"wb")) { @@ -1032,7 +1032,7 @@ public: std::vector<unsigned char> Buffer; Buffer.reserve(256*1024); - EmitASTBitcodeBuffer(Ctx, Buffer); + Ctx.EmitASTBitcodeBuffer(Buffer); // Write the bits to disk. if (FILE* fp = fopen(FName.c_str(),"wb")) { diff --git a/clang/tools/clang-cc/Backend.cpp b/clang/tools/clang-cc/Backend.cpp index ee2d0c56b26..0faabbe8d58 100644 --- a/clang/tools/clang-cc/Backend.cpp +++ b/clang/tools/clang-cc/Backend.cpp @@ -10,7 +10,6 @@ #include "ASTConsumers.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTConsumer.h" -#include "clang/AST/TranslationUnit.h" #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/ModuleBuilder.h" #include "clang/Frontend/CompileOptions.h" diff --git a/clang/tools/clang-cc/SerializationTest.cpp b/clang/tools/clang-cc/SerializationTest.cpp index d12a0af306b..a39811fd90e 100644 --- a/clang/tools/clang-cc/SerializationTest.cpp +++ b/clang/tools/clang-cc/SerializationTest.cpp @@ -81,7 +81,7 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename, std::vector<unsigned char> Buffer; Buffer.reserve(256*1024); - EmitASTBitcodeBuffer(Ctx, Buffer); + Ctx.EmitASTBitcodeBuffer(Buffer); // Write the bits to disk. if (FILE* fp = fopen(Filename.c_str(),"wb")) { @@ -97,7 +97,7 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint) { // Deserialize the translation unit. - TranslationUnit* NewTU; + ASTContext *NewCtx; { // Create the memory buffer that contains the contents of the file. @@ -107,10 +107,10 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename, if (!MBuffer) return false; - NewTU = ReadASTBitcodeBuffer(*MBuffer, FMgr); + NewCtx = ASTContext::ReadASTBitcodeBuffer(*MBuffer, FMgr); } - if (!NewTU) + if (!NewCtx) return false; { @@ -120,11 +120,13 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename, assert (Err.empty() && "Could not open file for printing out decls."); llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP)); - for (TranslationUnit::iterator I=NewTU->begin(), E=NewTU->end(); I!=E; ++I) + TranslationUnitDecl *TUD = NewCtx->getTranslationUnitDecl(); + for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end(); + I != E; ++I) FilePrinter->HandleTopLevelDecl(*I); } - delete NewTU; + delete NewCtx; return true; } diff --git a/clang/tools/clang-cc/clang.cpp b/clang/tools/clang-cc/clang.cpp index 9ab1dd39a46..31a39587662 100644 --- a/clang/tools/clang-cc/clang.cpp +++ b/clang/tools/clang-cc/clang.cpp @@ -1531,16 +1531,16 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag, exit (1); } - llvm::OwningPtr<TranslationUnit> TU; + llvm::OwningPtr<ASTContext> Ctx; // Create the memory buffer that contains the contents of the file. llvm::OwningPtr<llvm::MemoryBuffer> MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str())); if (MBuffer) - TU.reset(ReadASTBitcodeBuffer(*MBuffer, FileMgr)); + Ctx.reset(ASTContext::ReadASTBitcodeBuffer(*MBuffer, FileMgr)); - if (!TU) { + if (!Ctx) { fprintf(stderr, "error: file '%s' could not be deserialized\n", InFile.c_str()); exit (1); @@ -1549,7 +1549,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag, // Observe that we use the source file name stored in the deserialized // translation unit, rather than InFile. llvm::OwningPtr<ASTConsumer> - Consumer(CreateASTConsumer(InFile, Diag, FileMgr, TU->getLangOptions(), + Consumer(CreateASTConsumer(InFile, Diag, FileMgr, Ctx->getLangOptions(), 0, 0)); if (!Consumer) { @@ -1557,10 +1557,12 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag, exit (1); } - Consumer->Initialize(TU->getContext()); + Consumer->Initialize(*Ctx); // FIXME: We need to inform Consumer about completed TagDecls as well. - 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) Consumer->HandleTopLevelDecl(*I); } |