[PATCH] D88949: DeferredDiagnosticsEmitter crashes
Geoff Levner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 01:30:01 PDT 2020
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<RecordType>()) {
- CXXRecordDecl *Record = cast<CXXRecordDecl>(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<RecordType>()) {
+ CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
+ asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+ }
}
Inherited::VisitCXXDeleteExpr(E);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88949.296616.patch
Type: text/x-patch
Size: 1125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201007/343bba9c/attachment.bin>
More information about the cfe-commits
mailing list