[cfe-commits] r100996 - /cfe/trunk/tools/CIndex/CIndexUSRs.cpp
Ted Kremenek
kremenek at apple.com
Sun Apr 11 15:20:26 PDT 2010
Author: kremenek
Date: Sun Apr 11 17:20:26 2010
New Revision: 100996
URL: http://llvm.org/viewvc/llvm-project?rev=100996&view=rev
Log:
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).
Modified:
cfe/trunk/tools/CIndex/CIndexUSRs.cpp
Modified: cfe/trunk/tools/CIndex/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexUSRs.cpp?rev=100996&r1=100995&r2=100996&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexUSRs.cpp Sun Apr 11 17:20:26 2010
@@ -263,23 +263,29 @@
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));
More information about the cfe-commits
mailing list