[index] Add SymbolSubKind for the GKInspectable annotation.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 10 Nov 2016 23:27:11 +0000 (23:27 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 10 Nov 2016 23:27:11 +0000 (23:27 +0000)
llvm-svn: 286518

clang/include/clang/Index/IndexSymbol.h
clang/lib/Index/IndexSymbol.cpp
clang/test/Index/Core/index-subkinds.m

index d539b49..2b383ac 100644 (file)
@@ -66,8 +66,9 @@ enum class SymbolSubKind : uint8_t {
   UnitTest                      = 1 << 3,
   IBAnnotated                   = 1 << 4,
   IBOutletCollection            = 1 << 5,
+  GKInspectable                 = 1 << 6,
 };
-static const unsigned SymbolSubKindBitNum = 6;
+static const unsigned SymbolSubKindBitNum = 7;
 typedef unsigned SymbolSubKindSet;
 
 /// Set of roles that are attributed to symbol occurrences.
index 4126bb6..f5153fb 100644 (file)
@@ -165,6 +165,10 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
       Info.Kind = SymbolKind::InstanceProperty;
       Info.Lang = SymbolLanguage::ObjC;
       checkForIBOutlets(D, Info.SubKinds);
+      if (auto *Annot = D->getAttr<AnnotateAttr>()) {
+        if (Annot->getAnnotation() == "gk_inspectable")
+          Info.SubKinds |= (unsigned)SymbolSubKind::GKInspectable;
+      }
       break;
     case Decl::ObjCIvar:
       Info.Kind = SymbolKind::Field;
@@ -380,6 +384,7 @@ void index::applyForEachSymbolSubKind(SymbolSubKindSet SubKinds,
   APPLY_FOR_SUBKIND(UnitTest);
   APPLY_FOR_SUBKIND(IBAnnotated);
   APPLY_FOR_SUBKIND(IBOutletCollection);
+  APPLY_FOR_SUBKIND(GKInspectable);
 
 #undef APPLY_FOR_SUBKIND
 }
@@ -398,6 +403,7 @@ void index::printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS) {
     case SymbolSubKind::UnitTest: OS << "test"; break;
     case SymbolSubKind::IBAnnotated: OS << "IB"; break;
     case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break;
+    case SymbolSubKind::GKInspectable: OS << "GKI"; break;
     }
   });
 }
index a83da03..38be73b 100644 (file)
 // CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
 -(IBAction)doIt;
 @end
+
+
+#define GKInspectable __attribute__((annotate("gk_inspectable")))
+
+@interface GKI
+// CHECK: [[@LINE+1]]:40 | instance-property(GKI)/ObjC | gkIntProp | c:objc(cs)GKI(py)gkIntProp | <no-cgname> | Decl,RelChild | rel: 1
+@property (readonly) GKInspectable int gkIntProp;
+@end