[clangd] IncludeCleaner: Stop crashing when included file is not found

This commit is contained in:
Kirill Bobyrev 2021-10-08 14:50:27 +02:00
parent 71fd5a735e
commit 6393c21d47

View File

@ -161,7 +161,10 @@ getUnused(const IncludeStructure &Structure,
std::vector<const Inclusion *> Unused;
for (const Inclusion &MFI : Structure.MainFileIncludes) {
// FIXME: Skip includes that are not self-contained.
assert(MFI.HeaderID);
if (!MFI.HeaderID) {
elog("File {0} not found.", MFI.Written);
continue;
}
auto IncludeID = static_cast<IncludeStructure::HeaderID>(*MFI.HeaderID);
if (!ReferencedFiles.contains(IncludeID)) {
Unused.push_back(&MFI);