r190353 - Fix a crash introduced in r189828.

Matt Beaumont-Gay matthewbg at google.com
Mon Sep 9 14:07:58 PDT 2013


Author: matthewbg
Date: Mon Sep  9 16:07:58 2013
New Revision: 190353

URL: http://llvm.org/viewvc/llvm-project?rev=190353&view=rev
Log:
Fix a crash introduced in r189828.

The predicates in CXXRecordDecl which test various properties of special
members can't be called on incomplete decls.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp
    cfe/trunk/test/Analysis/dtor.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon Sep  9 16:07:58 2013
@@ -3133,7 +3133,7 @@ CFGBlock *CFGBuilder::VisitCXXDeleteExpr
   DTy = DTy.getNonReferenceType();
   CXXRecordDecl *RD = Context->getBaseElementType(DTy)->getAsCXXRecordDecl();
   if (RD) {
-    if (!RD->hasTrivialDestructor())
+    if (RD->isCompleteDefinition() && !RD->hasTrivialDestructor())
       appendDeleteDtor(Block, RD, DE);
   }
 

Modified: cfe/trunk/test/Analysis/dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dtor.cpp?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dtor.cpp (original)
+++ cfe/trunk/test/Analysis/dtor.cpp Mon Sep  9 16:07:58 2013
@@ -431,3 +431,8 @@ namespace PseudoDtor {
     clang_analyzer_eval(true); // expected-warning{{TRUE}}
   }
 }
+
+namespace Incomplete {
+  class Foo; // expected-note{{forward declaration}}
+  void f(Foo *foo) { delete foo; } // expected-warning{{deleting pointer to incomplete type}}
+}





More information about the cfe-commits mailing list