]> granicus.if.org Git - clang/commitdiff
Only serialize top-level decls that appear at the head of a decl chain.
authorTed Kremenek <kremenek@apple.com>
Thu, 29 Nov 2007 19:04:54 +0000 (19:04 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 29 Nov 2007 19:04:54 +0000 (19:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44438 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/SerializationTest.cpp

index b7d9b75bb5a48763b52c2731fb6f837a9a94619c..9beb92e130027b3c7bc665d69b97db7aff3ebe39 100644 (file)
@@ -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);
+      }
     }
   }