From: Richard Trieu Date: Thu, 9 Jun 2016 22:03:04 +0000 (+0000) Subject: Fix a crash in the AST dumper. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2486f3141fabe3242a40007893809c9c5bac2702;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272318 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 05d8da298c..da7e980c5a 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -2177,8 +2177,10 @@ void ASTDumper::VisitObjCMessageExpr(const ObjCMessageExpr *Node) { 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) { diff --git a/test/Misc/ast-dump-decl.mm b/test/Misc/ast-dump-decl.mm index 06ab515511..be245f7ef5 100644 --- a/test/Misc/ast-dump-decl.mm +++ b/test/Misc/ast-dump-decl.mm @@ -21,3 +21,13 @@ // CHECK-NEXT: CXXConstructExpr // CHECK-NEXT: ObjCIvarDecl{{.*}} X // CHECK-NEXT: ObjCMethodDecl{{.*}} foo + +// @() boxing expressions. +template +struct BoxingTest { + static id box(T value) { + return @(value); + } +}; + +// CHECK: ObjCBoxedExpr{{.*}} ''{{$}}