]> granicus.if.org Git - clang/commitdiff
Fix a crash in the AST dumper.
authorRichard Trieu <rtrieu@google.com>
Thu, 9 Jun 2016 22:03:04 +0000 (22:03 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 9 Jun 2016 22:03:04 +0000 (22:03 +0000)
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

lib/AST/ASTDumper.cpp
test/Misc/ast-dump-decl.mm

index 05d8da298cd2c13dd58025ad982bff7edb49e373..da7e980c5a4d3908d9e5239b1ed30231818fe857 100644 (file)
@@ -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) {
index 06ab5155110c4be9027745eb27a97d777abfa9af..be245f7ef5cdff74dfbf734f629427887ad4b60d 100644 (file)
 // 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>'{{$}}