r272318 - Fix a crash in the AST dumper.
Richard Trieu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 15:03:04 PDT 2016
Author: rtrieu
Date: Thu Jun 9 17:03:04 2016
New Revision: 272318
URL: http://llvm.org/viewvc/llvm-project?rev=272318&view=rev
Log:
Fix a crash in the AST dumper.
Boxed expressions in a template context may have a null method decl. If so,
don't try to access the selector.
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/Misc/ast-dump-decl.mm
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=272318&r1=272317&r2=272318&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Jun 9 17:03:04 2016
@@ -2177,8 +2177,10 @@ void ASTDumper::VisitObjCMessageExpr(con
void ASTDumper::VisitObjCBoxedExpr(const ObjCBoxedExpr *Node) {
VisitExpr(Node);
- OS << " selector=";
- Node->getBoxingMethod()->getSelector().print(OS);
+ if (auto *BoxingMethod = Node->getBoxingMethod()) {
+ OS << " selector=";
+ BoxingMethod->getSelector().print(OS);
+ }
}
void ASTDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
Modified: cfe/trunk/test/Misc/ast-dump-decl.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-decl.mm?rev=272318&r1=272317&r2=272318&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-decl.mm (original)
+++ cfe/trunk/test/Misc/ast-dump-decl.mm Thu Jun 9 17:03:04 2016
@@ -21,3 +21,13 @@
// CHECK-NEXT: CXXConstructExpr
// CHECK-NEXT: ObjCIvarDecl{{.*}} X
// CHECK-NEXT: ObjCMethodDecl{{.*}} foo
+
+// @() boxing expressions.
+template <typename T>
+struct BoxingTest {
+ static id box(T value) {
+ return @(value);
+ }
+};
+
+// CHECK: ObjCBoxedExpr{{.*}} '<dependent type>'{{$}}
More information about the cfe-commits
mailing list