[cfe-commits] r148861 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/TestClassDecl.m test/Index/TestClassForwardDecl.m test/Index/annotate-tokens.m test/Index/file-refs.m test/Index/properties-class-extensions.m tools/libclang/CIndex.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 24 13:39:26 PST 2012


Author: akirtzidis
Date: Tue Jan 24 15:39:26 2012
New Revision: 148861

URL: http://llvm.org/viewvc/llvm-project?rev=148861&view=rev
Log:
[libclang] In clang::getCursorKindForDecl() don't return "UnexposedDecl"
for forward references of classes and protocols, this breaks libclang API usage.

rdar://10747438.

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/TestClassDecl.m
    cfe/trunk/test/Index/TestClassForwardDecl.m
    cfe/trunk/test/Index/annotate-tokens.m
    cfe/trunk/test/Index/file-refs.m
    cfe/trunk/test/Index/properties-class-extensions.m
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Jan 24 15:39:26 2012
@@ -2782,13 +2782,7 @@
     case Decl::ObjCCategoryImpl:   return CXCursor_ObjCCategoryImplDecl;
     case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl;
 
-    case Decl::ObjCInterface:
-      if (cast<ObjCInterfaceDecl>(D)->isThisDeclarationADefinition())
-        return CXCursor_ObjCInterfaceDecl;
-      
-      // Forward declarations are not directly exposed.
-      return CXCursor_UnexposedDecl;
-
+    case Decl::ObjCInterface:      return CXCursor_ObjCInterfaceDecl;
     case Decl::ObjCIvar:           return CXCursor_ObjCIvarDecl; 
     case Decl::ObjCMethod:
       return cast<ObjCMethodDecl>(D)->isInstanceMethod()
@@ -2798,12 +2792,7 @@
     case Decl::CXXDestructor:      return CXCursor_Destructor;
     case Decl::CXXConversion:      return CXCursor_ConversionFunction;
     case Decl::ObjCProperty:       return CXCursor_ObjCPropertyDecl;
-    case Decl::ObjCProtocol:       
-      if (cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition())
-        return CXCursor_ObjCProtocolDecl;
-      
-      return CXCursor_UnexposedDecl;
-      
+    case Decl::ObjCProtocol:       return CXCursor_ObjCProtocolDecl;
     case Decl::ParmVar:            return CXCursor_ParmDecl;
     case Decl::Typedef:            return CXCursor_TypedefDecl;
     case Decl::TypeAlias:          return CXCursor_TypeAliasDecl;

Modified: cfe/trunk/test/Index/TestClassDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/TestClassDecl.m?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/test/Index/TestClassDecl.m (original)
+++ cfe/trunk/test/Index/TestClassDecl.m Tue Jan 24 15:39:26 2012
@@ -16,7 +16,7 @@
 }
 
 // CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=Foo:8:8
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
 // CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:10:12
 // CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
 // CHECK-scan: [10:1 - 11:5] ObjCInterfaceDecl=Foo:10:12

Modified: cfe/trunk/test/Index/TestClassForwardDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/TestClassForwardDecl.m?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/test/Index/TestClassForwardDecl.m (original)
+++ cfe/trunk/test/Index/TestClassForwardDecl.m Tue Jan 24 15:39:26 2012
@@ -13,7 +13,7 @@
 }
 
 // CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=Foo:8:8
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
 // CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:8:8
 // CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
 // CHECK-scan: [10:1 - 10:15] FunctionDecl=function:10:6 (Definition)

Modified: cfe/trunk/test/Index/annotate-tokens.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.m?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens.m (original)
+++ cfe/trunk/test/Index/annotate-tokens.m Tue Jan 24 15:39:26 2012
@@ -452,8 +452,8 @@
 // CHECK: Punctuation: ")" [88:24 - 88:25] ObjCProtocolExpr=Proto:85:1
 // CHECK: Punctuation: ";" [88:25 - 88:26] CompoundStmt=
 // CHECK: Punctuation: "}" [89:1 - 89:2] CompoundStmt=
-// CHECK: Punctuation: "@" [93:1 - 93:2] UnexposedDecl=Rdar8595462_A:93:8
-// CHECK: Keyword: "class" [93:2 - 93:7] UnexposedDecl=Rdar8595462_A:93:8
+// CHECK: Punctuation: "@" [93:1 - 93:2] ObjCInterfaceDecl=Rdar8595462_A:93:8
+// CHECK: Keyword: "class" [93:2 - 93:7] ObjCInterfaceDecl=Rdar8595462_A:93:8
 // CHECK: Identifier: "Rdar8595462_A" [93:8 - 93:21] ObjCClassRef=Rdar8595462_A:93:8
 // CHECK: Punctuation: ";" [93:21 - 93:22]
 // CHECK: Punctuation: "@" [94:1 - 94:2] ObjCInterfaceDecl=Rdar8595462_B:94:12

Modified: cfe/trunk/test/Index/file-refs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/file-refs.m?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/test/Index/file-refs.m (original)
+++ cfe/trunk/test/Index/file-refs.m Tue Jan 24 15:39:26 2012
@@ -43,8 +43,11 @@
 
 // RUN:  -file-refs-at=%s:7:18 \
 // CHECK:      ObjCImplementationDecl=Foo:7:17 (Definition)
-// CHECK-NEXT: UnexposedDecl=Foo:1:8 =[1:8 - 1:11]
+
+// FIXME: There should not be 2 for the same range.
+// CHECK-NEXT: ObjCInterfaceDecl=Foo:1:8 =[1:8 - 1:11]
 // CHECK-NEXT: ObjCClassRef=Foo:3:12 =[1:8 - 1:11]
+
 // CHECK-NEXT: ObjCInterfaceDecl=Foo:3:12 =[3:12 - 3:15]
 // CHECK-NEXT: ObjCImplementationDecl=Foo:7:17 (Definition) =[7:17 - 7:20]
 // CHECK-NEXT: ObjCClassRef=Foo:3:12 =[13:11 - 13:14]

Modified: cfe/trunk/test/Index/properties-class-extensions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/properties-class-extensions.m?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/test/Index/properties-class-extensions.m (original)
+++ cfe/trunk/test/Index/properties-class-extensions.m Tue Jan 24 15:39:26 2012
@@ -70,7 +70,7 @@
 // CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
 // CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
 // CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29]
-// CHECK: properties-class-extensions.m:24:8: UnexposedDecl=Rdar8467189_Bar:24:8
+// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
 // CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
 // CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
 // CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 Extent=[26:1 - 26:54]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=148861&r1=148860&r2=148861&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jan 24 15:39:26 2012
@@ -3922,9 +3922,7 @@
       if (ObjCProtocolDecl *Def = Prot->getDefinition())
         return MakeCXCursor(Def, tu);
 
-      CXCursor C = MakeCXCursor(Prot, tu);
-      C.kind = CXCursor_ObjCProtocolDecl; // override "Unexposed".
-      return C;
+      return MakeCXCursor(Prot, tu);
     }
 
     case CXCursor_ObjCClassRef: {
@@ -3932,9 +3930,7 @@
       if (ObjCInterfaceDecl *Def = Class->getDefinition())
         return MakeCXCursor(Def, tu);
 
-      CXCursor C = MakeCXCursor(Class, tu);
-      C.kind = CXCursor_ObjCInterfaceDecl; // override "Unexposed".
-      return C;
+      return MakeCXCursor(Class, tu);
     }
 
     case CXCursor_TypeRef:





More information about the cfe-commits mailing list