aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 03:56:54 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 03:56:54 +0000
commitd2fa67570b363843215f62395b795c1f70e6b85f (patch)
treed8a2c186fba1bf275c6ea6cfdd678dc5293dd624
parent80a033358d8da09d1f62b0b3ba98cee0346c0a49 (diff)
hoist TranslationUnit some more.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67905 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/TranslationUnit.h2
-rw-r--r--lib/AST/TranslationUnit.cpp4
-rw-r--r--tools/clang-cc/ASTConsumers.cpp4
-rw-r--r--tools/clang-cc/SerializationTest.cpp12
4 files changed, 12 insertions, 10 deletions
diff --git a/include/clang/AST/TranslationUnit.h b/include/clang/AST/TranslationUnit.h
index 40513e2019..2b22cf98e4 100644
--- a/include/clang/AST/TranslationUnit.h
+++ b/include/clang/AST/TranslationUnit.h
@@ -62,7 +62,7 @@ public:
};
/// 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.
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp
index 55ab1a7360..df135edf63 100644
--- a/lib/AST/TranslationUnit.cpp
+++ b/lib/AST/TranslationUnit.cpp
@@ -39,7 +39,7 @@ TranslationUnit::~TranslationUnit() {
}
}
-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 @@ bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU,
llvm::Serializer Sezr(Stream);
// Emit the translation unit.
- TU.getContext().EmitAll(Sezr);
+ Ctx.EmitAll(Sezr);
}
return true;
diff --git a/tools/clang-cc/ASTConsumers.cpp b/tools/clang-cc/ASTConsumers.cpp
index c040a54b44..288225d1e5 100644
--- a/tools/clang-cc/ASTConsumers.cpp
+++ b/tools/clang-cc/ASTConsumers.cpp
@@ -982,7 +982,7 @@ public:
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 @@ public:
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")) {
diff --git a/tools/clang-cc/SerializationTest.cpp b/tools/clang-cc/SerializationTest.cpp
index aa3163f556..770f9b3b87 100644
--- a/tools/clang-cc/SerializationTest.cpp
+++ b/tools/clang-cc/SerializationTest.cpp
@@ -46,7 +46,7 @@ public:
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 @@ clang::CreateSerializationTest(Diagnostic &Diags, FileManager& FMgr) {
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 @@ bool SerializationTest::Serialize(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=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 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename,
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 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
}
// 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.");