From 1ca73445064ac0c9b41d814cc7635b19c57bb703 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 1 Mar 2013 03:43:33 +0000 Subject: [PATCH] Add one more sanity check in SourceManager::getFileIDLoaded(). llvm-svn: 176333 --- clang/lib/Basic/SourceManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 8fa648c..1b8383b 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -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; } } -- 2.7.4