]> granicus.if.org Git - clang/commitdiff
[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)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286518 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d539b4903b7900ea5f55aea934e7bf46e0793705..2b383ac8fd6145753dfc4b1ff3c303daeaa8b876 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 4126bb6a971fe7ac724260e0ed61429f955ca474..f5153fb61d015e586bbf8145be06f998c5a25e1b 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 a83da03c3de82eb1fc6b4d24b75c470c84c7a454..38be73b31e91a862a6a04f1b6e1c6a992dcc42d6 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