I have a utility that uses Clang's LibTooling framework to parse the AST and perform static code analysis. I am using LLVM and Clang v10.0.
Recently I observed that the utility never finishes parsing the AST of a particular file. On debugging, I observed that the SourceManager.cpp calls an abort due to failed assertion. The exact place is here:
FileID SourceManager::createFileID(const ContentCache *File,
SourceLocation IncludePos,
SrcMgr::CharacteristicKind FileCharacter,
int LoadedID, unsigned LoadedOffset) {
...
...
assert(NextLocalOffset + FileSize + 1 > NextLocalOffset &&
NextLocalOffset + FileSize + 1 <= CurrentLoadedOffset &&
"Ran out of source locations!");
...
...
...
}
The values of the variables when the assertion fails are: NextLocalOffset=2147335549, FileSize=303516, CurrentLoadedOffset=2147483648 and (NextLocalOffset + FileSize)=2147639065.
The source file is automatically generated and is around 28,268,746 bytes (~27MB) and contains several include directives (~7000) for memory mapping different code blocks.
Is there a limit to the source files size Clang can process?