[clangd-dev] Fallback arguments

Sam McCall via clangd-dev clangd-dev at lists.llvm.org
Sun Sep 8 08:51:19 PDT 2019


For simple projects, you can create a file "compile_flags.txt" in the
project root, with one arg on each line.

https://clangd.github.io/installation.html

clangd will parse files with the command "clang $FLAGS $FILE".
This database isn't enumerable though, so you won't get background indexing.

Does this help?
Other approaches are also possible, but not implemented, happy to discuss


On Sun, Sep 8, 2019, 5:45 PM Sam Lunt via clangd-dev <
clangd-dev at lists.llvm.org> wrote:

> 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?
> _______________________________________________
> clangd-dev mailing list
> clangd-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20190908/91b792bf/attachment.html>


More information about the clangd-dev mailing list