diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2019-01-24 13:52:47 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2019-01-24 13:52:47 +0000 |
commit | 76252b07cbbbaff6e4c84033a940f08b35f55cd5 (patch) | |
tree | b0d157aba68ca7d41e304f34edfc1871209eca06 /lib | |
parent | a7ee181aaa8a79b1fece474c733c4f571f0d4ef2 (diff) | |
download | clang-76252b07cbbbaff6e4c84033a940f08b35f55cd5.tar.gz |
[Sema] Don't crash when recovering from a misspelled pseudo destructor call to an incomplete type.
When attempting to correct a misspelled pseudo destructor call as in:
struct Foo;
void foo(Foo *p) {
p.~Foo();
}
a call is made in canRecoverDotPseudoDestructorCallsOnPointerObjects
to LookupDestructor without checking that the record has a definition.
This causes an assertion later in LookupSpecialMember which assumes that
the record has a definition.
Patch By Roman Zhikharevich!
Differential Revision: https://reviews.llvm.org/D57111
Reviewed By: riccibruno
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index d54696bbef..5ac248d36b 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -6854,8 +6854,9 @@ canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema &SemaRef, 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; } |