r200953 - Fixes PR18762, stop the StmtPrinter for ObjCPropertyRefExpr from crashing on

Richard Trieu rtrieu at google.com
Thu Feb 6 15:26:23 PST 2014


Author: rtrieu
Date: Thu Feb  6 17:26:23 2014
New Revision: 200953

URL: http://llvm.org/viewvc/llvm-project?rev=200953&view=rev
Log:
Fixes PR18762, stop the StmtPrinter for ObjCPropertyRefExpr from crashing on
certain receiver types.

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/test/Misc/ast-dump-decl.m

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=200953&r1=200952&r2=200953&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Feb  6 17:26:23 2014
@@ -716,9 +716,11 @@ void StmtPrinter::VisitObjCIvarRefExpr(O
 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())

Modified: cfe/trunk/test/Misc/ast-dump-decl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-decl.m?rev=200953&r1=200952&r2=200953&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-decl.m (original)
+++ cfe/trunk/test/Misc/ast-dump-decl.m Thu Feb  6 17:26:23 2014
@@ -134,3 +134,12 @@ void TestBlockDecl(int x) {
 // CHECK-NEXT:   ...
 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
 // CHECK-NEXT:   CompoundStmt
+
+ at interface B
++ (int) foo;
+ at end
+
+void f() {
+  __typeof__(B.foo) Test;
+}
+// CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'





More information about the cfe-commits mailing list