Have clang_getCursorSource() return NULL when the source location is invalid or refers to a built-in buffer. Implements <rdar://problem/7296243>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89044 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index cf33d7d..493d4f2 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -980,8 +980,11 @@
SourceManager &SourceMgr = ND->getASTContext().getSourceManager();
SourceLocation SLoc = getLocationFromCursor(C, SourceMgr, ND);
- if (SLoc.isFileID())
- return SourceMgr.getBufferName(SLoc);
+
+ if (SLoc.isFileID()) {
+ const char *bufferName = SourceMgr.getBufferName(SLoc);
+ return bufferName[0] == '<' ? NULL : bufferName;
+ }
// Retrieve the file in which the macro was instantiated, then provide that
// buffer name.