glevner created this revision.
glevner added reviewers: lhames, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
glevner requested review of this revision.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88949
Files:
clang/lib/Sema/UsedDeclVisitor.h
Index: clang/lib/Sema/UsedDeclVisitor.h
===
--- clang/lib/Sema/UsedDeclVisitor.h
+++ clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@
void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
if (E->getOperatorDelete())
asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
-QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
-if (const RecordType *DestroyedRec = Destroyed->getAs()) {
- CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
- asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+QualType DestroyedOrNull = E->getDestroyedType();
+if (!DestroyedOrNull.isNull()) {
+ QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
+ if (const RecordType *DestroyedRec = Destroyed->getAs()) {
+CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
+asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+ }
}
Inherited::VisitCXXDeleteExpr(E);
Index: clang/lib/Sema/UsedDeclVisitor.h
===
--- clang/lib/Sema/UsedDeclVisitor.h
+++ clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@
void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
if (E->getOperatorDelete())
asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
-QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
-if (const RecordType *DestroyedRec = Destroyed->getAs()) {
- CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
- asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+QualType DestroyedOrNull = E->getDestroyedType();
+if (!DestroyedOrNull.isNull()) {
+ QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
+ if (const RecordType *DestroyedRec = Destroyed->getAs()) {
+CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
+asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+ }
}
Inherited::VisitCXXDeleteExpr(E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits