]> granicus.if.org Git - clang/commitdiff
[libclang] In clang::getCursorKindForDecl() don't return "UnexposedDecl"
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 24 Jan 2012 21:39:26 +0000 (21:39 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 24 Jan 2012 21:39:26 +0000 (21:39 +0000)
for forward references of classes and protocols, this breaks libclang API usage.

rdar://10747438.

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

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

index 623e68b8a5a31bf1647c25d777e0aa19c91aec9d..4fdbfdb8362191620b717d5fbf71805f77525407 100644 (file)
@@ -2782,13 +2782,7 @@ CXCursorKind clang::getCursorKindForDecl(Decl *D) {
     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 @@ CXCursorKind clang::getCursorKindForDecl(Decl *D) {
     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;
index 2abc39d78c295e8a9d4952229ab6c006d28bcbf2..038353b11dd65faa8448018ed2ff8aa5b8c7adc9 100644 (file)
@@ -16,7 +16,7 @@ void function(Foo * arg)
 }
 
 // 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
index b37f5ff937c333b0ead1f20f98d122a04be1084c..2f32d33c7082a7b587fc344cc73b44c0f766acb9 100644 (file)
@@ -13,7 +13,7 @@ void function(Foo * arg)
 }
 
 // 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)
index c0e39e10e3394a1229956ffd04baf8736b5e4d8a..f9ddc655c2ff0d6fc444f4c91bda79cc36354be7 100644 (file)
@@ -452,8 +452,8 @@ static Rdar8595462_A * Rdar8595462_staticVar;
 // 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
index 3f9d33687a54f84cf9bb861005d2843ced14735d..583826700de459a5bbf241e339c96a44e4e6c2e2 100644 (file)
@@ -43,8 +43,11 @@ void test2(Sub *s, id<Prot1> p) {
 
 // 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]
index 96706d2aeb9fd7fe24bb6dc8fd770ee547664c8f..87830a7af1d18508f56492a01a91fdc76bb2b657 100644 (file)
@@ -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]
index fe4e373e8ac5b9d8335240aedad94ede0f20e7ed..f49d6f6cccd689ae98491f9615856d9af4dcd155 100644 (file)
@@ -3922,9 +3922,7 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
       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 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
       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: