push more ASTContext goodness out through interfaces that use
TranslationUnit
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67913 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/ASTConsumers.cpp b/tools/clang-cc/ASTConsumers.cpp
index 18b4246..5b4287a 100644
--- a/tools/clang-cc/ASTConsumers.cpp
+++ b/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 @@
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 @@
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/tools/clang-cc/Backend.cpp b/tools/clang-cc/Backend.cpp
index ee2d0c5..0faabbe 100644
--- a/tools/clang-cc/Backend.cpp
+++ b/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/tools/clang-cc/SerializationTest.cpp b/tools/clang-cc/SerializationTest.cpp
index d12a0af..a39811f 100644
--- a/tools/clang-cc/SerializationTest.cpp
+++ b/tools/clang-cc/SerializationTest.cpp
@@ -81,7 +81,7 @@
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 @@
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 @@
if (!MBuffer)
return false;
- NewTU = ReadASTBitcodeBuffer(*MBuffer, FMgr);
+ NewCtx = ASTContext::ReadASTBitcodeBuffer(*MBuffer, FMgr);
}
- if (!NewTU)
+ if (!NewCtx)
return false;
{
@@ -120,11 +120,13 @@
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/tools/clang-cc/clang.cpp b/tools/clang-cc/clang.cpp
index 9ab1dd3..31a3958 100644
--- a/tools/clang-cc/clang.cpp
+++ b/tools/clang-cc/clang.cpp
@@ -1531,16 +1531,16 @@
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 @@
// 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 @@
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);
}