r267118 - [index] Add SymbolSubKinds for ObjC IB annotations.
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 22 00:21:17 PDT 2016
Author: akirtzidis
Date: Fri Apr 22 02:21:16 2016
New Revision: 267118
URL: http://llvm.org/viewvc/llvm-project?rev=267118&view=rev
Log:
[index] Add SymbolSubKinds for ObjC IB annotations.
Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-subkinds.m
Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=267118&r1=267117&r2=267118&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Fri Apr 22 02:21:16 2016
@@ -64,8 +64,10 @@ enum class SymbolSubKind : uint8_t {
TemplatePartialSpecialization = 1 << 1,
TemplateSpecialization = 1 << 2,
UnitTest = 1 << 3,
+ IBAnnotated = 1 << 4,
+ IBOutletCollection = 1 << 5,
};
-static const unsigned SymbolSubKindBitNum = 4;
+static const unsigned SymbolSubKindBitNum = 6;
typedef unsigned SymbolSubKindSet;
/// Set of roles that are attributed to symbol occurrences.
Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=267118&r1=267117&r2=267118&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri Apr 22 02:21:16 2016
@@ -40,6 +40,15 @@ static bool isUnitTest(const ObjCMethodD
return isUnitTestCase(D->getClassInterface());
}
+static void checkForIBOutlets(const Decl *D, SymbolSubKindSet &SubKindSet) {
+ if (D->hasAttr<IBOutletAttr>()) {
+ SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
+ } else if (D->hasAttr<IBOutletCollectionAttr>()) {
+ SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
+ SubKindSet |= (unsigned)SymbolSubKind::IBOutletCollection;
+ }
+}
+
SymbolInfo index::getSymbolInfo(const Decl *D) {
assert(D);
SymbolInfo Info;
@@ -135,14 +144,18 @@ SymbolInfo index::getSymbolInfo(const De
Info.Lang = SymbolLanguage::ObjC;
if (isUnitTest(cast<ObjCMethodDecl>(D)))
Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
+ if (D->hasAttr<IBActionAttr>())
+ Info.SubKinds |= (unsigned)SymbolSubKind::IBAnnotated;
break;
case Decl::ObjCProperty:
Info.Kind = SymbolKind::InstanceProperty;
Info.Lang = SymbolLanguage::ObjC;
+ checkForIBOutlets(D, Info.SubKinds);
break;
case Decl::ObjCIvar:
Info.Kind = SymbolKind::Field;
Info.Lang = SymbolLanguage::ObjC;
+ checkForIBOutlets(D, Info.SubKinds);
break;
case Decl::Namespace:
Info.Kind = SymbolKind::Namespace;
@@ -347,6 +360,8 @@ void index::applyForEachSymbolSubKind(Sy
APPLY_FOR_SUBKIND(TemplatePartialSpecialization);
APPLY_FOR_SUBKIND(TemplateSpecialization);
APPLY_FOR_SUBKIND(UnitTest);
+ APPLY_FOR_SUBKIND(IBAnnotated);
+ APPLY_FOR_SUBKIND(IBOutletCollection);
#undef APPLY_FOR_SUBKIND
}
@@ -363,6 +378,8 @@ void index::printSymbolSubKinds(SymbolSu
case SymbolSubKind::TemplatePartialSpecialization: OS << "TPS"; break;
case SymbolSubKind::TemplateSpecialization: OS << "TS"; break;
case SymbolSubKind::UnitTest: OS << "test"; break;
+ case SymbolSubKind::IBAnnotated: OS << "IB"; break;
+ case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break;
}
});
}
Modified: cfe/trunk/test/Index/Core/index-subkinds.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-subkinds.m?rev=267118&r1=267117&r2=267118&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-subkinds.m (original)
+++ cfe/trunk/test/Index/Core/index-subkinds.m Fri Apr 22 02:21:16 2016
@@ -34,3 +34,15 @@
// CHECK: [[@LINE+1]]:1 | instance-method(test)/ObjC | testInCat | c:objc(cs)MyTestCase(im)testInCat | -[MyTestCase(cat) testInCat] | Def,Dyn,RelChild | rel: 1
- (void)testInCat {}
@end
+
+
+ at class NSButton;
+ at interface IBCls
+// CHECK: [[@LINE+2]]:34 | instance-method/ObjC | prop | c:objc(cs)IBCls(im)prop | -[IBCls prop] | Decl,Dyn,RelChild | rel: 1
+// CHECK: [[@LINE+1]]:34 | instance-property(IB)/ObjC | prop | c:objc(cs)IBCls(py)prop | <no-cgname> | Decl,RelChild | rel: 1
+ at property (readonly) IBOutlet id prop;
+// CHECK: [[@LINE+1]]:54 | instance-property(IB,IBColl)/ObjC | propColl | c:objc(cs)IBCls(py)propColl | <no-cgname> | Decl,RelChild | rel: 1
+ at property (readonly) IBOutletCollection(NSButton) id propColl;
+// CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
+-(IBAction)doIt;
+ at end
More information about the cfe-commits
mailing list