[PATCH] D56841: [clangd] Filter out plugin related flags.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 17 03:44:55 PST 2019


ilya-biryukov added subscribers: sammccall, klimek.
ilya-biryukov added a comment.

LG, just a few comments. Supporting compiler plugins in clangd is non-trivial and we don't support them so far, so filtering out the options make sense.

It feels these helper belong in the Tooling library, that would allow to reuse code between clang-tidy, clangd, etc. Could even be the default behavior, since most of the tools won't handle compiler plugins well, unless compiled with the same exact version of the compiler.
I'd be interested in what other people think, @sammccall, @klimek?



================
Comment at: clangd/ClangdUnit.cpp:429
+  const auto &CommandLine = Inputs.CompileCommand.CommandLine;
+  for (size_t I = 0, E = CommandLine.size(); I != E; I++) {
+    // According to https://clang.llvm.org/docs/ClangPlugins.html
----------------
ioeric wrote:
> This doesn't seem to be clangd specific; clang-tidy seems to have the same issue. Could we share the filtering logic (e.g. in lib/Tooling/ArgumentsAdjusters.cpp)?
We need a comment mentioning that we are filtering out the plugin options and why we're doing that here


================
Comment at: clangd/ClangdUnit.cpp:433
+    // <arbitrary-argument>
+    if (I + 4 < E && CommandLine[I] == "-Xclang" &&
+        (CommandLine[I + 1] == "-load" || CommandLine[I + 1] == "-plugin" ||
----------------
Maybe move this code into `ClangdServer::getCompileCommand` to keep **all** argument adjustments that we do in clangd in one place.
We add `-resource-dir` there.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56841/new/

https://reviews.llvm.org/D56841





More information about the cfe-commits mailing list