r296956 - Handle null QualType better in Stmt::Profile

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 3 18:42:42 PST 2017


Author: rtrieu
Date: Fri Mar  3 20:42:41 2017
New Revision: 296956

URL: http://llvm.org/viewvc/llvm-project?rev=296956&view=rev
Log:
Handle null QualType better in Stmt::Profile

If the QualType is null, calling ASTContext::getCanonicalType on it will lead
to an assert.  This was found while testing a new use for Stmt::Profile, so
there is no test case for this.

Modified:
    cfe/trunk/lib/AST/StmtProfile.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=296956&r1=296955&r2=296956&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Mar  3 20:42:41 2017
@@ -128,7 +128,7 @@ namespace {
     }
 
     void VisitType(QualType T) override {
-      if (Canonical)
+      if (Canonical && !T.isNull())
         T = Context.getCanonicalType(T);
 
       ID.AddPointer(T.getAsOpaquePtr());




More information about the cfe-commits mailing list