[clang-tools-extra] 6393c21 - [clangd] IncludeCleaner: Stop crashing when included file is not found
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 8 05:51:20 PDT 2021
Author: Kirill Bobyrev
Date: 2021-10-08T14:51:11+02:00
New Revision: 6393c21d476de2584b3ac010aace6a9b26d5bbec
URL: https://github.com/llvm/llvm-project/commit/6393c21d476de2584b3ac010aace6a9b26d5bbec
DIFF: https://github.com/llvm/llvm-project/commit/6393c21d476de2584b3ac010aace6a9b26d5bbec.diff
LOG: [clangd] IncludeCleaner: Stop crashing when included file is not found
Added:
Modified:
clang-tools-extra/clangd/IncludeCleaner.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp b/clang-tools-extra/clangd/IncludeCleaner.cpp
index d9bf600a04b86..91db8bfb8bc3c 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -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);
More information about the cfe-commits
mailing list