diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 23:43:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 23:43:01 +0000 |
commit | c3b4575b77164fdf008cd4acc330884d56ca500f (patch) | |
tree | ab52bf4c7ac5bfc3fd6690e4f1269d8850a2f261 | |
parent | 3381a73dd77f3f84a6cdc8a0e3c4ec53b7df9651 (diff) |
Make sure SourceManager::getFileIDLoaded doesn't hang in release build because of invalid passed parameter.
rdar://10210140
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141048 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Basic/SourceManager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 96a526ad14..a540f3b945 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -732,6 +732,10 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) const { FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const { assert(SLocOffset >= CurrentLoadedOffset && "Bad function choice"); + // Sanity checking, otherwise a bug may lead to hanging in release build. + if (SLocOffset < CurrentLoadedOffset) + return FileID(); + // Essentially the same as the local case, but the loaded array is sorted // in the other direction. |