diff --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp --- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp +++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp @@ -333,6 +333,13 @@ else if (Arg.startswith("-x")) Lang = Arg.drop_front(2).trim(); } + // Downgrade objective-c++-header (used in clangd's fallback flags for .h + // files) to c++-header, as some drivers may fail to run the extraction + // command if it contains `-xobjective-c++-header` and objective-c++ support + // is not installed. + if (Lang == "objective-c++-header") { + Lang = "c++-header"; + } if (Lang.empty()) { llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.'); auto Type = driver::types::lookupTypeForExtension(Ext);