From 870600d6256e92d0fa9cb9642c76f418a841be1e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 29 Nov 2007 19:04:54 +0000 Subject: [PATCH] Only serialize top-level decls that appear at the head of a decl chain. llvm-svn: 44438 --- clang/Driver/SerializationTest.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/clang/Driver/SerializationTest.cpp b/clang/Driver/SerializationTest.cpp index b7d9b75bb5a4..9beb92e13002 100644 --- a/clang/Driver/SerializationTest.cpp +++ b/clang/Driver/SerializationTest.cpp @@ -128,18 +128,23 @@ void SerializationTest::Serialize(llvm::sys::Path& Filename, for (std::list::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(*I)) - if (FD->getBody()) { - // Construct and print a CFG. - Janitor 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(*I)) + if (FD->getBody()) { + // Construct and print a CFG. + Janitor cfg(CFG::buildCFG(FD->getBody())); + cfg->print(DeclPP); + } + + // Serialize the decl. + Sezr.EmitOwnedPtr(*I); + } } }