[cfe-commits] r148703 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-member-access.m

Douglas Gregor dgregor at apple.com
Mon Jan 23 07:59:30 PST 2012


Author: dgregor
Date: Mon Jan 23 09:59:30 2012
New Revision: 148703

URL: http://llvm.org/viewvc/llvm-project?rev=148703&view=rev
Log:
Handle pseudo-object expressions (and any other placeholder
expression) when code-completing member access expressions. Fixes
<rdar://problem/10717172>.

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/complete-member-access.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=148703&r1=148702&r2=148703&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Jan 23 09:59:30 2012
@@ -3351,15 +3351,19 @@
   }
 }
 
-void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *BaseE,
+void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
                                            SourceLocation OpLoc,
                                            bool IsArrow) {
-  if (!BaseE || !CodeCompleter)
+  if (!Base || !CodeCompleter)
     return;
   
+  ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
+  if (ConvertedBase.isInvalid())
+    return;
+  Base = ConvertedBase.get();
+
   typedef CodeCompletionResult Result;
   
-  Expr *Base = static_cast<Expr *>(BaseE);
   QualType BaseType = Base->getType();
 
   if (IsArrow) {

Modified: cfe/trunk/test/Index/complete-member-access.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-member-access.m?rev=148703&r1=148702&r2=148703&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-member-access.m (original)
+++ cfe/trunk/test/Index/complete-member-access.m Mon Jan 23 09:59:30 2012
@@ -34,6 +34,14 @@
   return s.myOtherPropLikeThing;
 }
 
+ at interface Other
+ at property Sub *sub;
+ at end
+
+int test_two_levels(Other *other) {
+  return other.sub.myProp;
+}
+
 // RUN: c-index-test -code-completion-at=%s:21:7 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText prop1}
 // CHECK-CC1: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp}
@@ -59,4 +67,11 @@
 // CHECK-CC3-NEXT: Objective-C property access
 // CHECK-CC3-NEXT: Container Kind: ObjCInterfaceDecl
 // CHECK-CC3-NEXT: Container is complete
-// CHECK-CC3-NEXT: Container USR: c:objc(cs)Sub
\ No newline at end of file
+// CHECK-CC3-NEXT: Container USR: c:objc(cs)Sub
+
+// RUN: c-index-test -code-completion-at=%s:42:20 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText myOtherPropLikeThing} (37)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText myProp} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText prop1} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp} (35)
+





More information about the cfe-commits mailing list