]> granicus.if.org Git - clang/commitdiff
Fixes PR18762, stop the StmtPrinter for ObjCPropertyRefExpr from crashing on
authorRichard Trieu <rtrieu@google.com>
Thu, 6 Feb 2014 23:26:23 +0000 (23:26 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 6 Feb 2014 23:26:23 +0000 (23:26 +0000)
certain receiver types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200953 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp
test/Misc/ast-dump-decl.m

index 6ece8af95837844bc4e00c98ac91d87d79be01a0..f008a120757dd750a4f614cde19459f6e16f84b4 100644 (file)
@@ -716,9 +716,11 @@ void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
   if (Node->isSuperReceiver())
     OS << "super.";
-  else if (Node->getBase()) {
+  else if (Node->isObjectReceiver() && Node->getBase()) {
     PrintExpr(Node->getBase());
     OS << ".";
+  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
+    OS << Node->getClassReceiver()->getName() << ".";
   }
 
   if (Node->isImplicitProperty())
index f8a5e5a263d6a446738505b68adf8e741e01624c..539923b2e36a97a4b4fe90b058f5bc216a8d8e9a 100644 (file)
@@ -134,3 +134,12 @@ void TestBlockDecl(int x) {
 // CHECK-NEXT:   ...
 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
 // CHECK-NEXT:   CompoundStmt
+
+@interface B
++ (int) foo;
+@end
+
+void f() {
+  __typeof__(B.foo) Test;
+}
+// CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'