[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-07 Thread Geoff Levner via Phabricator via cfe-commits
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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-07 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

See https://bugs.llvm.org/show_bug.cgi?id=47742


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88949/new/

https://reviews.llvm.org/D88949

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-07 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

I'm sorry, but I don't know how to reproduce the problem in isolation. We are 
JIT-compiling fairly complex C++ code, and the crash //sometimes// occurs when, 
for example, an included header file is not found...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88949/new/

https://reviews.llvm.org/D88949

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

Great. I don't have commit access though. If I did, I would love to commit it 
to the release branch, which is what we use...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88949/new/

https://reviews.llvm.org/D88949

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

Good enough for us... Thanks, @hans and @yaxunl!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88949/new/

https://reviews.llvm.org/D88949

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits