aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/libclang/CIndex.cpp4
-rw-r--r--tools/libclang/CXSourceLocation.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index e19cd4214f..ce9357de33 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1417,9 +1417,7 @@ CXSourceLocation clang_getLocation(CXTranslationUnit tu,
static_cast<const FileEntry *>(file),
line, column);
- return SLoc.isInvalid() ?
- clang_getNullLocation() :
- cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
+ return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
}
CXSourceRange clang_getNullRange() {
diff --git a/tools/libclang/CXSourceLocation.h b/tools/libclang/CXSourceLocation.h
index 235f78c5a1..7a50205963 100644
--- a/tools/libclang/CXSourceLocation.h
+++ b/tools/libclang/CXSourceLocation.h
@@ -29,6 +29,9 @@ namespace cxloc {
static inline CXSourceLocation
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
SourceLocation Loc) {
+ if (Loc.isInvalid())
+ clang_getNullLocation();
+
CXSourceLocation Result = { { (void*) &SM, (void*) &LangOpts, },
Loc.getRawEncoding() };
return Result;