aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-04-11 22:20:26 +0000
committerTed Kremenek <kremenek@apple.com>2010-04-11 22:20:26 +0000
commitc3ef91d784a08efbda6fac063215a163552a8e75 (patch)
tree9524df1f0ab34be9013bc258edf6f075ca536967
parent718d06995662ab5ea34c52988bde3813f4ef25cc (diff)
Augment clang_getCursorUSR() to not always expect that clang_getCursorDecl() does the right
thing if the cursor is not a decl (such as in the case of macros). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100996 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/CIndex/CIndexUSRs.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/CIndex/CIndexUSRs.cpp b/tools/CIndex/CIndexUSRs.cpp
index e90d965a1c..a2cb040282 100644
--- a/tools/CIndex/CIndexUSRs.cpp
+++ b/tools/CIndex/CIndexUSRs.cpp
@@ -263,23 +263,29 @@ static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) {
return s.startswith("c:") ? s.substr(2) : "";
}
-extern "C" {
-
-CXString clang_getCursorUSR(CXCursor C) {
+static CXString getDeclCursorUSR(const CXCursor &C) {
Decl *D = cxcursor::getCursorDecl(C);
if (!D)
return createCXString(NULL);
StringUSRGenerator SUG;
- SUG->Visit(static_cast<Decl*>(D));
+ SUG->Visit(D);
if (SUG->ignoreResults())
return createCXString("");
- // Return a copy of the string that must be disposed by the caller.
+ // Return a copy of the string that must be disposed by the caller.
return createCXString(SUG.str(), true);
}
+extern "C" {
+
+CXString clang_getCursorUSR(CXCursor C) {
+ if (clang_isDeclaration(clang_getCursorKind(C)))
+ return getDeclCursorUSR(C);
+ return createCXString("");
+}
+
CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) {
StringUSRGenerator SUG;
SUG << extractUSRSuffix(clang_getCString(classUSR));