sammccall created this revision. sammccall added a reviewer: ilya-biryukov. Herald added subscribers: cfe-commits, ioeric, jkorous-apple, klimek.
This makes C++/objC not totally broken, without hurting C files too much. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45442 Files: clangd/GlobalCompilationDatabase.cpp Index: clangd/GlobalCompilationDatabase.cpp =================================================================== --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -18,9 +18,15 @@ tooling::CompileCommand GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { + std::vector<std::string> 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=*/""); }
Index: clangd/GlobalCompilationDatabase.cpp =================================================================== --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -18,9 +18,15 @@ tooling::CompileCommand GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { + std::vector<std::string> 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=*/""); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits