aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2014-03-28 22:21:26 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2014-03-28 22:21:26 +0000
commit7ac8837d4ab171d6bee0b9d0109d48f44830848d (patch)
treeec7540c60548f19290acfb45b5d3bb901ba54219 /tools
parentd60a851dd59b8888acbd9e1a917ac4e8802a4729 (diff)
downloadclang_35a-7ac8837d4ab171d6bee0b9d0109d48f44830848d.tar.gz
libclang/libIndex: USR generation: mangle source location into USRs for macros,
unless the macro comes from a system header git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/CIndexUSRs.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 2b43c5b375..25881c3ef0 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -14,8 +14,10 @@
#include "CIndexer.h"
#include "CXCursor.h"
#include "CXString.h"
+#include "CXTranslationUnit.h"
#include "clang/Index/USRGeneration.h"
#include "clang/Lex/PreprocessingRecord.h"
+#include "clang/Frontend/ASTUnit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
@@ -73,10 +75,16 @@ CXString clang_getCursorUSR(CXCursor C) {
if (!buf)
return cxstring::createEmpty();
- buf->Data += getUSRSpacePrefix();
- buf->Data += "macro@";
- buf->Data +=
- cxcursor::getCursorMacroDefinition(C)->getName()->getNameStart();
+ bool Ignore = generateUSRForMacro(cxcursor::getCursorMacroDefinition(C),
+ cxtu::getASTUnit(TU)->getSourceManager(),
+ buf->Data);
+ if (Ignore) {
+ buf->dispose();
+ return cxstring::createEmpty();
+ }
+
+ // Return the C-string, but don't make a copy since it is already in
+ // the string buffer.
buf->Data.push_back('\0');
return createCXString(buf);
}