[llvm-branch-commits] [clang] 3c68767 - DeferredDiagnosticsEmitter crashes
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 2 21:04:25 PST 2020
Author: Geoff Levner
Date: 2020-11-03T00:03:20-05:00
New Revision: 3c687677678c382e8d13d6583c3f8cdf3fd301dd
URL: https://github.com/llvm/llvm-project/commit/3c687677678c382e8d13d6583c3f8cdf3fd301dd
DIFF: https://github.com/llvm/llvm-project/commit/3c687677678c382e8d13d6583c3f8cdf3fd301dd.diff
LOG: 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 b9225543e844bee5091aa16108e0c54bd2abe485)
Added:
Modified:
clang/lib/Sema/UsedDeclVisitor.h
Removed:
################################################################################
diff --git a/clang/lib/Sema/UsedDeclVisitor.h b/clang/lib/Sema/UsedDeclVisitor.h
index d207e07f451a..c33d30478e2a 100644
--- a/clang/lib/Sema/UsedDeclVisitor.h
+++ b/clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@ class UsedDeclVisitor : public EvaluatedExprVisitor<Derived> {
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);
More information about the llvm-branch-commits
mailing list