summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r--clang/tools/libclang/CIndex.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index f1a37d6906b..00141184c70 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2819,17 +2819,8 @@ void clang_getSpellingLocation(CXSourceLocation location,
unsigned *offset) {
SourceLocation Loc = SourceLocation::getFromRawEncoding(location.int_data);
- if (!location.ptr_data[0] || Loc.isInvalid()) {
- if (file)
- *file = 0;
- if (line)
- *line = 0;
- if (column)
- *column = 0;
- if (offset)
- *offset = 0;
- return;
- }
+ if (!location.ptr_data[0] || Loc.isInvalid())
+ return createNullLocation(file, line, column, offset);
const SourceManager &SM =
*static_cast<const SourceManager*>(location.ptr_data[0]);
@@ -2847,6 +2838,9 @@ void clang_getSpellingLocation(CXSourceLocation location,
FileID FID = LocInfo.first;
unsigned FileOffset = LocInfo.second;
+ if (FID.isInvalid())
+ return createNullLocation(file, line, column, offset);
+
if (file)
*file = (void *)SM.getFileEntryForID(FID);
if (line)
OpenPOWER on IntegriCloud