[cfe-commits] r54513 - in /cfe/trunk/Driver: RewriteObjC.cpp SerializationTest.cpp
Ted Kremenek
kremenek at apple.com
Thu Aug 7 21:15:53 PDT 2008
Author: kremenek
Date: Thu Aug 7 23:15:52 2008
New Revision: 54513
URL: http://llvm.org/viewvc/llvm-project?rev=54513&view=rev
Log:
Unbreak SerializationTest and the Rewriter by doing the work in HandleTranslationUnit instead of the destructor.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/Driver/SerializationTest.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=54513&r1=54512&r2=54513&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Thu Aug 7 23:15:52 2008
@@ -108,7 +108,10 @@
void HandleDeclInMainFile(Decl *D);
RewriteObjC(std::string inFile, std::string outFile,
Diagnostic &D, const LangOptions &LOpts);
- ~RewriteObjC();
+
+ ~RewriteObjC() {}
+
+ virtual void HandleTranslationUnit(TranslationUnit& TU);
void ReplaceStmt(Stmt *Old, Stmt *New) {
// If replacement succeeded or warning disabled return with no warning.
@@ -439,7 +442,7 @@
// Nothing yet.
}
-RewriteObjC::~RewriteObjC() {
+void RewriteObjC::HandleTranslationUnit(TranslationUnit& TU) {
// Get the top-level buffer that this corresponds to.
// Rewrite tabs if we care.
Modified: cfe/trunk/Driver/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/SerializationTest.cpp?rev=54513&r1=54512&r2=54513&view=diff
==============================================================================
--- cfe/trunk/Driver/SerializationTest.cpp (original)
+++ cfe/trunk/Driver/SerializationTest.cpp Thu Aug 7 23:15:52 2008
@@ -33,19 +33,20 @@
namespace {
class SerializationTest : public ASTConsumer {
- TranslationUnit* TU;
Diagnostic &Diags;
FileManager &FMgr;
public:
SerializationTest(Diagnostic &d, FileManager& fmgr)
- : TU(0), Diags(d), FMgr(fmgr) {}
+ : Diags(d), FMgr(fmgr) {}
- ~SerializationTest();
-
- virtual void InitializeTU(TranslationUnit& tu) { TU = &tu; }
+ ~SerializationTest() {}
+
+ virtual void HandleTranslationUnit(TranslationUnit& TU);
private:
- bool Serialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint);
+ bool Serialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint,
+ TranslationUnit& TU);
+
bool Deserialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint);
};
@@ -58,19 +59,20 @@
bool SerializationTest::Serialize(llvm::sys::Path& Filename,
- llvm::sys::Path& FNameDeclPrint) {
+ llvm::sys::Path& FNameDeclPrint,
+ TranslationUnit& TU) {
{
// Pretty-print the decls to a temp file.
std::ofstream DeclPP(FNameDeclPrint.c_str());
assert (DeclPP && "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)
+ for (TranslationUnit::iterator I=TU.begin(), E=TU.end(); I!=E; ++I)
FilePrinter->HandleTopLevelDecl(*I);
}
// Serialize the translation unit.
- return EmitASTBitcodeFile(*TU,Filename);
+ return EmitASTBitcodeFile(TU,Filename);
}
bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
@@ -82,7 +84,7 @@
if (!NewTU)
return false;
- {
+ {
// Pretty-print the deserialized decls to a temp file.
std::ofstream DeclPP(FNameDeclPrint.c_str());
assert (DeclPP && "Could not open file for printing out decls.");
@@ -110,7 +112,7 @@
};
}
-SerializationTest::~SerializationTest() {
+void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
std::string ErrMsg;
llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg);
@@ -147,7 +149,7 @@
}
// Serialize and then deserialize the ASTs.
- bool status = Serialize(ASTFilename, FNameDeclBefore);
+ bool status = Serialize(ASTFilename, FNameDeclBefore, TU);
assert (status && "Serialization failed.");
status = Deserialize(ASTFilename, FNameDeclAfter);
assert (status && "Deserialization failed.");
More information about the cfe-commits
mailing list