aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ExtractAPI/API.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/ExtractAPI/API.cpp')
-rw-r--r--clang/lib/ExtractAPI/API.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 8ab03a8..4832202 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -197,6 +197,39 @@ TypedefRecord *APISet::addTypedef(StringRef Name, StringRef USR,
Comment, Declaration, SubHeading, UnderlyingType);
}
+template <class RecordMap>
+static APIRecord *getSymbolInRecordMapForUSR(StringRef USR,
+ const RecordMap &Records) {
+ auto It = Records.find(USR);
+ return (It != Records.end() ? It->second.get() : nullptr);
+}
+
+APIRecord *APISet::getSymbolForUSR(StringRef USR) const {
+ if (USR.empty())
+ return nullptr;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCProtocols))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCInterfaces))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, Structs))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, Enums))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, Typedefs))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalFunctions))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalVariables))
+ return Record;
+ if (auto *Record = getSymbolInRecordMapForUSR(USR, Macros))
+ return Record;
+ return nullptr;
+}
+
StringRef APISet::recordUSR(const Decl *D) {
SmallString<128> USR;
index::generateUSRForDecl(D, USR);