[cfe-commits] r159279 - in /cfe/trunk: lib/AST/DeclCXX.cpp lib/Sema/SemaExpr.cpp test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

Rafael Espindola rafael.espindola at gmail.com
Wed Jun 27 10:44:39 PDT 2012


Author: rafael
Date: Wed Jun 27 12:44:39 2012
New Revision: 159279

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

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=159279&r1=159278&r2=159279&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Wed Jun 27 12:44:39 2012
@@ -1290,7 +1290,7 @@
   // Lookup doesn't work for destructors, so handle them separately.
   if (isa<CXXDestructorDecl>(this)) {
     CXXMethodDecl *MD = RD->getDestructor();
-    if (recursivelyOverrides(MD, this))
+    if (MD && recursivelyOverrides(MD, this))
       return MD;
     return NULL;
   }

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=159279&r1=159278&r2=159279&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun 27 12:44:39 2012
@@ -10859,6 +10859,8 @@
   if (!MostDerivedClassDecl)
     return;
   CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl);
+  if (!DM)
+    return;
   SemaRef.MarkAnyDeclReferenced(Loc, DM);
 } 
 

Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=159279&r1=159278&r2=159279&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Wed Jun 27 12:44:39 2012
@@ -71,3 +71,15 @@
     b->foo::~foo();
   }
 }
+
+namespace test3 {
+  // Test that we don't crash in this case.
+  struct B {
+  };
+  struct D : public B {
+  };
+  void f(D d) {
+    // CHECK: define void @_ZN5test31fENS_1DE
+    d.B::~B();
+  }
+}





More information about the cfe-commits mailing list