Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit a7af76c

Browse files
committed
[index] Add Swift symbol language and Swift-specific symbol subkinds.
1 parent 682298d commit a7af76c

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

include/clang/Index/IndexSymbol.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,36 @@ enum class SymbolLanguage {
5757
C,
5858
ObjC,
5959
CXX,
60+
Swift,
6061
};
6162

6263
/// Language specific sub-kinds.
6364
enum class SymbolSubKind {
6465
None,
6566
CXXCopyConstructor,
6667
CXXMoveConstructor,
68+
69+
// Swift sub-kinds
70+
71+
SwiftAccessorGetter,
72+
SwiftAccessorSetter,
73+
SwiftAccessorWillSet,
74+
SwiftAccessorDidSet,
75+
SwiftAccessorAddressor,
76+
SwiftAccessorMutableAddressor,
77+
78+
SwiftExtensionOfStruct,
79+
SwiftExtensionOfClass,
80+
SwiftExtensionOfEnum,
81+
SwiftExtensionOfProtocol,
82+
83+
SwiftPrefixOperator,
84+
SwiftPostfixOperator,
85+
SwiftInfixOperator,
86+
87+
SwiftSubscript,
88+
SwiftAssociatedType,
89+
SwiftGenericTypeParam,
6790
};
6891

6992
/// Set of properties that provide additional info about a symbol.

lib/Index/IndexSymbol.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,22 @@ StringRef index::getSymbolSubKindString(SymbolSubKind K) {
375375
case SymbolSubKind::None: return "<none>";
376376
case SymbolSubKind::CXXCopyConstructor: return "cxx-copy-ctor";
377377
case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
378+
case SymbolSubKind::SwiftAccessorGetter: return "acc-get";
379+
case SymbolSubKind::SwiftAccessorSetter: return "acc-set";
380+
case SymbolSubKind::SwiftAccessorWillSet: return "acc-willset";
381+
case SymbolSubKind::SwiftAccessorDidSet: return "acc-didset";
382+
case SymbolSubKind::SwiftAccessorAddressor: return "acc-addr";
383+
case SymbolSubKind::SwiftAccessorMutableAddressor: return "acc-mutaddr";
384+
case SymbolSubKind::SwiftExtensionOfStruct: return "ext-struct";
385+
case SymbolSubKind::SwiftExtensionOfClass: return "ext-class";
386+
case SymbolSubKind::SwiftExtensionOfEnum: return "ext-enum";
387+
case SymbolSubKind::SwiftExtensionOfProtocol: return "ext-protocol";
388+
case SymbolSubKind::SwiftPrefixOperator: return "prefix-operator";
389+
case SymbolSubKind::SwiftPostfixOperator: return "postfix-operator";
390+
case SymbolSubKind::SwiftInfixOperator: return "infix-operator";
391+
case SymbolSubKind::SwiftSubscript: return "subscript";
392+
case SymbolSubKind::SwiftAssociatedType: return "associated-type";
393+
case SymbolSubKind::SwiftGenericTypeParam: return "generic-type-param";
378394
}
379395
llvm_unreachable("invalid symbol subkind");
380396
}
@@ -384,6 +400,7 @@ StringRef index::getSymbolLanguageString(SymbolLanguage K) {
384400
case SymbolLanguage::C: return "C";
385401
case SymbolLanguage::ObjC: return "ObjC";
386402
case SymbolLanguage::CXX: return "C++";
403+
case SymbolLanguage::Swift: return "Swift";
387404
}
388405
llvm_unreachable("invalid symbol language kind");
389406
}

tools/libclang/CXIndexDataConsumer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ static CXIdxEntityLanguage getEntityLangFromSymbolLang(SymbolLanguage L) {
13131313
case SymbolLanguage::C: return CXIdxEntityLang_C;
13141314
case SymbolLanguage::ObjC: return CXIdxEntityLang_ObjC;
13151315
case SymbolLanguage::CXX: return CXIdxEntityLang_CXX;
1316+
case SymbolLanguage::Swift: llvm_unreachable("unexpected Swift symbol language");;
13161317
}
13171318
llvm_unreachable("invalid symbol language");
13181319
}

0 commit comments

Comments
 (0)