]> granicus.if.org Git - clang/commitdiff
Make sure SourceManager::getFileIDLoaded doesn't hang in release build because of...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Oct 2011 23:43:01 +0000 (23:43 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Oct 2011 23:43:01 +0000 (23:43 +0000)
rdar://10210140

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141048 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 96a526ad141d6bea2ab8976193957d1b599bd3f1..a540f3b9450fafbc3579b2540748e6ef399dd42b 100644 (file)
@@ -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.