[clangd-dev] Fallback arguments

Sam Lunt via clangd-dev clangd-dev at lists.llvm.org
Sat Sep 7 13:08:07 PDT 2019


As far as I can tell, there doesn't seem to be a method to pass
default arguments for clangd to use when there is no compilation
database found or when no suitable entry for a given file can be found
in the database.

This is a bit inconvenient when writing short throw-away programs
(i.e. that don't require a Makefile or CMakeLists), especially since
the default C++ standard used is C++14, which leads to warnings about
new syntax. I was wondering how difficult it would be to support
passing some default arguments when clangd is started, e.g.:
    clangd -- -Wall -Wextra -Wpedantic -std=c++17

One issue with this is that it would possibly cause problems, since
when a C file was passed, it would see a flag "-std=c++17". However,
one solution could be to use the "-x" flag to set language specific
flags:
    clangd -- -Wall -x c -std=gnu99 -x c++ -std=c++17

That would lead to C files using the flags "-Wall -std=gnu99", while
C++ files would use the flags "-Wall -std=c++17". (Note that before
the first "-x" flag, all flags apply to every language).

Would this feature be feasible to add?


More information about the clangd-dev mailing list