From 78ae2481b650a67e243569609fa681d11daf741f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Mar 2010 18:23:03 +0000 Subject: Explicitly link macro instantiations to macro definitions in the preprocessing record. Use that link with clang_getCursorReferenced() and clang_getCursorDefinition() to match instantiations of a macro to the definition of the macro. llvm-svn: 98842 --- clang/tools/CIndex/CIndex.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/tools/CIndex/CIndex.cpp') diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index ce2188550bd..47d156c6ceb 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -1765,6 +1765,11 @@ CXCursor clang_getCursorReferenced(CXCursor C) { return clang_getNullCursor(); } + if (C.kind == CXCursor_MacroInstantiation) { + if (MacroDefinition *Def = getCursorMacroInstantiation(C)->getDefinition()) + return MakeMacroDefinitionCursor(Def, CXXUnit); + } + if (!clang_isReference(C.kind)) return clang_getNullCursor(); @@ -1803,6 +1808,9 @@ CXCursor clang_getCursorDefinition(CXCursor C) { WasReference = true; } + if (C.kind == CXCursor_MacroInstantiation) + return clang_getCursorReferenced(C); + if (!clang_isDeclaration(C.kind)) return clang_getNullCursor(); -- cgit v1.2.3