diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-29 19:04:54 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-29 19:04:54 +0000 |
commit | 6127b12f1663323490fdbd08bbb73bd14df3e4e8 (patch) | |
tree | 72482aec1b5266d9c12f0f1def98c2849b5a4f22 /Driver/SerializationTest.cpp | |
parent | 016765e3453db2e302efe53905e99cdb25501234 (diff) |
Only serialize top-level decls that appear at the head of a decl chain.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/SerializationTest.cpp')
-rw-r--r-- | Driver/SerializationTest.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Driver/SerializationTest.cpp b/Driver/SerializationTest.cpp index b7d9b75bb5..9beb92e130 100644 --- a/Driver/SerializationTest.cpp +++ b/Driver/SerializationTest.cpp @@ -128,18 +128,23 @@ void SerializationTest::Serialize(llvm::sys::Path& Filename, for (std::list<Decl*>::iterator I=Decls.begin(), E=Decls.end(); I!=E; ++I) { llvm::cerr << "Serializing: Decl.\n"; - 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); + // Only serialize the head of a decl chain. The ASTConsumer interfaces + // provides us with each top-level decl, including those nested in + // a decl chain, so we may be passed decls that are already serialized. + if (!Sezr.isRegistered(*I)) { + 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); + } } } |