summaryrefslogtreecommitdiff
path: root/clang/lib/Sema/UsedDeclVisitor.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/UsedDeclVisitor.h')
-rw-r--r--clang/lib/Sema/UsedDeclVisitor.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/Sema/UsedDeclVisitor.h b/clang/lib/Sema/UsedDeclVisitor.h
index ad475ab0f42a..546b3a9e66e2 100644
--- a/clang/lib/Sema/UsedDeclVisitor.h
+++ b/clang/lib/Sema/UsedDeclVisitor.h
@@ -70,12 +70,10 @@ public:
QualType DestroyedOrNull = E->getDestroyedType();
if (!DestroyedOrNull.isNull()) {
QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
- if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
- CXXRecordDecl *Record =
- cast<CXXRecordDecl>(DestroyedRec->getOriginalDecl());
- if (auto *Def = Record->getDefinition())
- asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Def));
- }
+ if (auto *Record = Destroyed->getAsCXXRecordDecl();
+ Record &&
+ (Record->isBeingDefined() || Record->isCompleteDefinition()))
+ asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
}
Inherited::VisitCXXDeleteExpr(E);