diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-18 21:59:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-18 21:59:54 +0000 |
commit | c705d2520a51de1dc38d36efada8e9bc2d8b0d1f (patch) | |
tree | 745a84279b0b2e2389e87319b7c3b821ec1e6b29 | |
parent | fa43c97297d8d76b66c5cb1c37f7785db9e1ee17 (diff) |
[libclang] Make sure we do a correct invalid check in clang_getExpansionLocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142430 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/SourceManager.h | 4 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 985ddd6412..52b5c4512e 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -1213,6 +1213,10 @@ public: } const SrcMgr::SLocEntry &getSLocEntry(FileID FID, bool *Invalid = 0) const { + if (FID.ID == 0 || FID.ID == -1) { + if (Invalid) *Invalid = true; + return LocalSLocEntryTable[0]; + } return getSLocEntryByID(FID.ID); } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index e085a27c09..3130a029e7 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2814,7 +2814,7 @@ void clang_getExpansionLocation(CXSourceLocation location, FileID fileID = SM.getFileID(ExpansionLoc); bool Invalid = false; const SrcMgr::SLocEntry &sloc = SM.getSLocEntry(fileID, &Invalid); - if (!sloc.isFile() || Invalid) { + if (Invalid || !sloc.isFile()) { createNullLocation(file, line, column, offset); return; } |