r340696 - [index] Introduce 'ProtocolInterface' as part of SymbolPropertySet
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 25 23:27:24 PDT 2018
Author: akirtzidis
Date: Sat Aug 25 23:27:23 2018
New Revision: 340696
URL: http://llvm.org/viewvc/llvm-project?rev=340696&view=rev
Log:
[index] Introduce 'ProtocolInterface' as part of SymbolPropertySet
This is useful to directly infer that a method or property is from a protocol interface
at the point of the symbol occurrences.
Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/external-source-symbol-attr.m
cfe/trunk/test/Index/Core/index-source.m
Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=340696&r1=340695&r2=340696&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Sat Aug 25 23:27:23 2018
@@ -75,7 +75,7 @@ enum class SymbolSubKind : uint8_t {
UsingValue,
};
-typedef uint8_t SymbolPropertySet;
+typedef uint16_t SymbolPropertySet;
/// Set of properties that provide additional info about a symbol.
enum class SymbolProperty : SymbolPropertySet {
Generic = 1 << 0,
@@ -86,8 +86,10 @@ enum class SymbolProperty : SymbolProper
IBOutletCollection = 1 << 5,
GKInspectable = 1 << 6,
Local = 1 << 7,
+ /// Symbol is part of a protocol interface.
+ ProtocolInterface = 1 << 8,
};
-static const unsigned SymbolPropertyBitNum = 8;
+static const unsigned SymbolPropertyBitNum = 9;
/// 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=340696&r1=340695&r2=340696&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Sat Aug 25 23:27:23 2018
@@ -96,6 +96,9 @@ SymbolInfo index::getSymbolInfo(const De
if (isFunctionLocalSymbol(D)) {
Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
}
+ if (isa<ObjCProtocolDecl>(D->getDeclContext())) {
+ Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
+ }
if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
switch (TD->getTagKind()) {
@@ -519,6 +522,7 @@ void index::applyForEachSymbolProperty(S
APPLY_FOR_PROPERTY(IBOutletCollection);
APPLY_FOR_PROPERTY(GKInspectable);
APPLY_FOR_PROPERTY(Local);
+ APPLY_FOR_PROPERTY(ProtocolInterface);
#undef APPLY_FOR_PROPERTY
}
@@ -539,6 +543,7 @@ void index::printSymbolProperties(Symbol
case SymbolProperty::IBOutletCollection: OS << "IBColl"; break;
case SymbolProperty::GKInspectable: OS << "GKI"; break;
case SymbolProperty::Local: OS << "local"; break;
+ case SymbolProperty::ProtocolInterface: OS << "protocol"; break;
}
});
}
Modified: cfe/trunk/test/Index/Core/external-source-symbol-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/external-source-symbol-attr.m?rev=340696&r1=340695&r2=340696&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/external-source-symbol-attr.m (original)
+++ cfe/trunk/test/Index/Core/external-source-symbol-attr.m Sat Aug 25 23:27:23 2018
@@ -87,7 +87,7 @@ void test2(I3 *i3, id<ExtProt2> prot2, S
[i3 meth2];
// CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth2 | c:@CM at modname@objc(cs)I3(im)meth2 |
[prot2 meth];
- // CHECK: [[@LINE-1]]:10 | instance-method/Swift | meth | c:@M at modname@objc(pl)ExtProt2(im)meth |
+ // CHECK: [[@LINE-1]]:10 | instance-method(protocol)/Swift | meth | c:@M at modname@objc(pl)ExtProt2(im)meth |
some = SomeEnumFirst;
// CHECK: [[@LINE-1]]:10 | enumerator/Swift | SomeEnumFirst | c:@M at modname@E at SomeEnum@SomeEnumFirst |
}
Modified: cfe/trunk/test/Index/Core/index-source.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=340696&r1=340695&r2=340696&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Sat Aug 25 23:27:23 2018
@@ -474,12 +474,12 @@ void testImplicitProperties(ImplicitProp
@end
@protocol Prot3 // CHECK: [[@LINE]]:11 | protocol/ObjC | Prot3 | [[PROT3_USR:.*]] | <no-cgname> | Decl |
--(void)meth;
+-(void)meth; // CHECK: [[@LINE]]:8 | instance-method(protocol)/ObjC | meth | [[PROT3_meth_USR:.*]] | -[Prot3 meth] | Decl,Dyn,RelChild |
@end
void test_rec1() {
id<Prot3, Prot1> o1;
- [o1 meth]; // CHECK: [[@LINE]]:7 | instance-method/ObjC | meth | {{.*}} | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 3
+ [o1 meth]; // CHECK: [[@LINE]]:7 | instance-method(protocol)/ObjC | meth | [[PROT3_meth_USR]] | {{.*}} | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 3
// CHECK-NEXT: RelCall,RelCont | test_rec1 |
// CHECK-NEXT: RelRec | Prot3 | [[PROT3_USR]]
// CHECK-NEXT: RelRec | Prot1 | [[PROT1_USR]]
More information about the cfe-commits
mailing list