forked from OSchip/llvm-project
In SourceManager::getFileIDLoaded(), add some sanity checks to make sure we don't enter an infinite loop.
rdar://13120919 llvm-svn: 176331
This commit is contained in:
parent
e9e588dd72
commit
7dc4f33c77
|
|
@ -840,10 +840,17 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const {
|
|||
++NumProbes;
|
||||
unsigned MiddleIndex = (LessIndex - GreaterIndex) / 2 + GreaterIndex;
|
||||
const SrcMgr::SLocEntry &E = getLoadedSLocEntry(MiddleIndex);
|
||||
if (E.getOffset() == 0)
|
||||
return FileID(); // invalid entry.
|
||||
|
||||
++NumProbes;
|
||||
|
||||
if (E.getOffset() > SLocOffset) {
|
||||
// Sanity checking, otherwise a bug may lead to hanging in release build.
|
||||
if (GreaterIndex == MiddleIndex) {
|
||||
assert(0 && "binary search missed the entry");
|
||||
return FileID();
|
||||
}
|
||||
GreaterIndex = MiddleIndex;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue