Have clang_getCursorSource() return NULL when the source location is invalid or refers to a built-in buffer.  Implements <rdar://problem/7296243>.

llvm-svn: 89044
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index cf33d7d..493d4f2 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/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.