Return a proper null CXSourceLocation from clang_getLocation() when the SourceLocation is invalid. Fixes <rdar://problem/8056640>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105392 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 21396ad..ae12667 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1416,7 +1416,9 @@
static_cast<const FileEntry *>(file),
line, column);
- return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
+ return SLoc.isInvalid() ?
+ clang_getNullLocation() :
+ cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
}
CXSourceRange clang_getNullRange() {