Index: clangd/GlobalCompilationDatabase.cpp =================================================================== --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -18,9 +18,15 @@ tooling::CompileCommand GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { + std::vector Argv = {"clang"}; + // Clang treats .h files as C by default, resulting in unhelpful diagnostics. + // Parsing as Objective C++ is friendly to more cases. + if (llvm::sys::path::extension(File) == ".h") + Argv.push_back("-xobjective-c++-header"); + Argv.push_back(File); return tooling::CompileCommand(llvm::sys::path::parent_path(File), llvm::sys::path::filename(File), - {"clang", File.str()}, + std::move(Argv), /*Output=*/""); }