diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-29 01:24:25 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-29 01:24:25 +0000 |
commit | 5656b782561f6a434fabec3c057cdbb63b55a1c8 (patch) | |
tree | 2fce23140b8192cb39a3ccf012c2a477ca64a129 /Driver/SerializationTest.cpp | |
parent | b594a4058941d6c71c9deeef60a1d8a68c56335a (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/SerializationTest.cpp')
-rw-r--r-- | Driver/SerializationTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Driver/SerializationTest.cpp b/Driver/SerializationTest.cpp index 9f756136bd..b7d9b75bb5 100644 --- a/Driver/SerializationTest.cpp +++ b/Driver/SerializationTest.cpp @@ -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 @@ void SerializationTest::Serialize(llvm::sys::Path& Filename, 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 @@ void SerializationTest::Deserialize(llvm::sys::Path& Filename, 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); + } } } |