Add initial USR support for macro definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100997 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndexUSRs.cpp b/tools/CIndex/CIndexUSRs.cpp
index a2cb040..a2be617 100644
--- a/tools/CIndex/CIndexUSRs.cpp
+++ b/tools/CIndex/CIndexUSRs.cpp
@@ -281,8 +281,18 @@
extern "C" {
CXString clang_getCursorUSR(CXCursor C) {
- if (clang_isDeclaration(clang_getCursorKind(C)))
+ const CXCursorKind &K = clang_getCursorKind(C);
+
+ if (clang_isDeclaration(K))
return getDeclCursorUSR(C);
+
+ if (K == CXCursor_MacroDefinition) {
+ StringUSRGenerator SUG;
+ SUG << "macro@"
+ << cxcursor::getCursorMacroDefinition(C)->getName()->getNameStart();
+ return createCXString(SUG.str(), true);
+ }
+
return createCXString("");
}