[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 9 08:33:10 PDT 2018
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=*/"");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45442.141662.patch
Type: text/x-patch
Size: 915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180409/c21a390b/attachment.bin>
More information about the cfe-commits
mailing list