]> granicus.if.org Git - clang/commitdiff
Add one more sanity check in SourceManager::getFileIDLoaded().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Mar 2013 03:43:33 +0000 (03:43 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Mar 2013 03:43:33 +0000 (03:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 8fa648c730b996676c71b1fe6a97d5e7af0176c0..1b8383bc426128546ba83bf986e3c8415f9bfde1 100644 (file)
@@ -863,6 +863,11 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const {
       return Res;
     }
 
+    // Sanity checking, otherwise a bug may lead to hanging in release build.
+    if (LessIndex == MiddleIndex) {
+      assert(0 && "binary search missed the entry");
+      return FileID();
+    }
     LessIndex = MiddleIndex;
   }
 }