[cfe-commits] r44429 - /cfe/trunk/Driver/SerializationTest.cpp
Ted Kremenek
kremenek at apple.com
Wed Nov 28 17:24:25 PST 2007
Author: kremenek
Date: Wed Nov 28 19:24:25 2007
New Revision: 44429
URL: http://llvm.org/viewvc/llvm-project?rev=44429&view=rev
Log:
Enhanced serialization testing by also pretty-printing CFGs constructed from ASTs
both before and after serialization/deserialization. If the CFGs between the pre-
and post- serialized/deserialized ASTs differ, the serialization has failed.
Modified:
cfe/trunk/Driver/SerializationTest.cpp
Modified: cfe/trunk/Driver/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/SerializationTest.cpp?rev=44429&r1=44428&r2=44429&view=diff
==============================================================================
--- cfe/trunk/Driver/SerializationTest.cpp (original)
+++ cfe/trunk/Driver/SerializationTest.cpp Wed Nov 28 19:24:25 2007
@@ -18,6 +18,7 @@
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/CFG.h"
#include "llvm/System/Path.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -130,6 +131,14 @@
Printer->HandleTopLevelDecl(*I);
FilePrinter->HandleTopLevelDecl(*I);
+ if (FunctionDecl* FD = dyn_cast<FunctionDecl>(*I))
+ if (FD->getBody()) {
+ // Construct and print a CFG.
+ Janitor<CFG> cfg(CFG::buildCFG(FD->getBody()));
+ cfg->print(DeclPP);
+ }
+
+ // Serialize the decl.
Sezr.EmitOwnedPtr(*I);
}
}
@@ -274,6 +283,13 @@
Decl* decl = Dezr.ReadOwnedPtr<Decl>();
Printer->HandleTopLevelDecl(decl);
FilePrinter->HandleTopLevelDecl(decl);
+
+ if (FunctionDecl* FD = dyn_cast<FunctionDecl>(decl))
+ if (FD->getBody()) {
+ // Construct and print a CFG.
+ Janitor<CFG> cfg(CFG::buildCFG(FD->getBody()));
+ cfg->print(DeclPP);
+ }
}
}
More information about the cfe-commits
mailing list