[cfe-commits] r127030 - /cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Douglas Gregor dgregor at apple.com
Fri Mar 4 12:42:52 PST 2011


Author: dgregor
Date: Fri Mar  4 14:42:52 2011
New Revision: 127030

URL: http://llvm.org/viewvc/llvm-project?rev=127030&view=rev
Log:
After an error of any kind has occurred, don't assert when attempting
to find the instantiated declaration within a template instantiation
fails to do so. It's likely that the original instantiation got
dropped due to instantiation failures, which doesn't actually break
the invariants of the AST. This eliminates a number of
crash-on-invalid failures, e.g., PR9300.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=127030&r1=127029&r2=127030&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Mar  4 14:42:52 2011
@@ -3031,9 +3031,11 @@
     }
 
     // UsingShadowDecls can instantiate to nothing because of using hiding.
-    assert((Result || isa<UsingShadowDecl>(D) || D->isInvalidDecl() ||
-            cast<Decl>(ParentDC)->isInvalidDecl())
-           && "Unable to find instantiation of declaration!");
+    // Note: this assertion end up firing in invalid code even when none of the 
+    // AST invariants have been broken, so we explicitly check whether any
+    // errors have been emitted
+    assert((Result || isa<UsingShadowDecl>(D) || Diags.hasErrorOccurred()) &&
+           "Unable to find instantiation of declaration!");
 
     D = Result;
   }





More information about the cfe-commits mailing list