forked from OSchip/llvm-project
[modules] If loading a .pcm file would cause us to run out of source locations, attempt to fail more gracefully. (No test; this requires >= 4GB of preprocessed input...)
llvm-svn: 244822
This commit is contained in:
parent
971dc3a82a
commit
78d81ecfc3
|
@ -484,10 +484,12 @@ std::pair<int, unsigned>
|
||||||
SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries,
|
SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries,
|
||||||
unsigned TotalSize) {
|
unsigned TotalSize) {
|
||||||
assert(ExternalSLocEntries && "Don't have an external sloc source");
|
assert(ExternalSLocEntries && "Don't have an external sloc source");
|
||||||
|
// Make sure we're not about to run out of source locations.
|
||||||
|
if (CurrentLoadedOffset - TotalSize < NextLocalOffset)
|
||||||
|
return std::make_pair(0, 0);
|
||||||
LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries);
|
LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries);
|
||||||
SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
|
SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
|
||||||
CurrentLoadedOffset -= TotalSize;
|
CurrentLoadedOffset -= TotalSize;
|
||||||
assert(CurrentLoadedOffset >= NextLocalOffset && "Out of source locations");
|
|
||||||
int ID = LoadedSLocEntryTable.size();
|
int ID = LoadedSLocEntryTable.size();
|
||||||
return std::make_pair(-ID - 1, CurrentLoadedOffset);
|
return std::make_pair(-ID - 1, CurrentLoadedOffset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2727,6 +2727,10 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
||||||
std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
|
std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
|
||||||
SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
|
SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
|
||||||
SLocSpaceSize);
|
SLocSpaceSize);
|
||||||
|
if (!F.SLocEntryBaseID) {
|
||||||
|
Error("ran out of source locations");
|
||||||
|
break;
|
||||||
|
}
|
||||||
// Make our entry in the range map. BaseID is negative and growing, so
|
// Make our entry in the range map. BaseID is negative and growing, so
|
||||||
// we invert it. Because we invert it, though, we need the other end of
|
// we invert it. Because we invert it, though, we need the other end of
|
||||||
// the range.
|
// the range.
|
||||||
|
|
Loading…
Reference in New Issue