[modules] Guard against recursively re-entering diagnosing ODR violations while
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 13 Feb 2015 22:43:51 +0000 (22:43 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 13 Feb 2015 22:43:51 +0000 (22:43 +0000)
in the middle of emitting an ODR violation diagnostic. I don't yet have a
reduced testcase for this issue, working on it...

llvm-svn: 229167

clang/lib/Serialization/ASTReader.cpp

index 7c211e4..a0cb7b5 100644 (file)
@@ -8475,6 +8475,10 @@ void ASTReader::diagnoseOdrViolations() {
       // completed. We only really need to mark FieldDecls as invalid here.
       if (!isa<TagDecl>(D))
         D->setInvalidDecl();
+      
+      // Ensure we don't accidentally recursively enter deserialization while
+      // we're producing our diagnostic.
+      Deserializing RecursionGuard(this);
 
       std::string CanonDefModule =
           getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
@@ -8496,6 +8500,13 @@ void ASTReader::diagnoseOdrViolations() {
     }
   }
 
+  if (OdrMergeFailures.empty())
+    return;
+
+  // Ensure we don't accidentally recursively enter deserialization while
+  // we're producing our diagnostics.
+  Deserializing RecursionGuard(this);
+
   // Issue any pending ODR-failure diagnostics.
   for (auto &Merge : OdrMergeFailures) {
     // If we've already pointed out a specific problem with this class, don't