Skip to content

Commit 3c68767

Browse files
glevnertstellar
authored andcommitted
DeferredDiagnosticsEmitter crashes
Patch VisitCXXDeleteExpr() in clang::UsedDeclVisitor to avoid it crashing when the expression's destroyed type is null. According to the comments in CXXDeleteExpr::getDestroyedType(), this can happen when the type to delete is a dependent type. Patch by Geoff Levner. Differential Revision: https://reviews.llvm.org/D88949 (cherry picked from commit b922554)
1 parent 701addf commit 3c68767

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clang/lib/Sema/UsedDeclVisitor.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ class UsedDeclVisitor : public EvaluatedExprVisitor<Derived> {
6767
void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
6868
if (E->getOperatorDelete())
6969
asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
70-
QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
71-
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
72-
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
73-
asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
70+
QualType DestroyedOrNull = E->getDestroyedType();
71+
if (!DestroyedOrNull.isNull()) {
72+
QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
73+
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
74+
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
75+
asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
76+
}
7477
}
7578

7679
Inherited::VisitCXXDeleteExpr(E);

0 commit comments

Comments
 (0)