[PATCH] D57111: Make Clang not crash on calls to destructors on incomplete pointer types

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 05:53:00 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL352047: [Sema] Don't crash when recovering from a misspelled pseudo destructor call to… (authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57111?vs=183144&id=183292#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57111/new/

https://reviews.llvm.org/D57111

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/incomplete-call.cpp


Index: cfe/trunk/test/SemaCXX/incomplete-call.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp
@@ -48,6 +48,10 @@
   c(); // expected-error{{incomplete type in call to object of type}}
 }
 
+void test_incomplete_object_dtor(C *p) {
+  p.~C(); // expected-error{{member reference type 'C *' is a pointer; did you mean to use '->'?}}
+}
+
 namespace pr18542 {
   struct X {
     int count;
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6854,8 +6854,9 @@
                                                    QualType DestructedType) {
   // If this is a record type, check if its destructor is callable.
   if (auto *RD = DestructedType->getAsCXXRecordDecl()) {
-    if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
-      return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
+    if (RD->hasDefinition())
+      if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
+        return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
     return false;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57111.183292.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190124/e527f271/attachment.bin>


More information about the cfe-commits mailing list