clang-tools  14.0.0git
Public Attributes | List of all members
clang::clangd::config::Fragment::CompileFlagsBlock Struct Reference

Conditions in the CompileFlags block affect how a file is parsed. More...

#include <ConfigFragment.h>

Collaboration diagram for clang::clangd::config::Fragment::CompileFlagsBlock:
Collaboration graph
[legend]

Public Attributes

std::vector< Located< std::string > > Add
 List of flags to append to the compile command. More...
 
std::vector< Located< std::string > > Remove
 List of flags to remove from the compile command. More...
 
llvm::Optional< Located< std::string > > CompilationDatabase
 Directory to search for compilation database (compile_comands.json etc). More...
 

Detailed Description

Conditions in the CompileFlags block affect how a file is parsed.

clangd emulates how clang would interpret a file. By default, it behaves roughly like clang $FILENAME, but real projects usually require setting the include path (with the -I flag), defining preprocessor symbols, configuring warnings etc. Often, a compilation database specifies these compile commands. clangd searches for compile_commands.json in parents of the source file.

This section modifies how the compile command is constructed.

Definition at line 136 of file ConfigFragment.h.

Member Data Documentation

◆ Add

std::vector<Located<std::string> > clang::clangd::config::Fragment::CompileFlagsBlock::Add

List of flags to append to the compile command.

Definition at line 138 of file ConfigFragment.h.

◆ CompilationDatabase

llvm::Optional<Located<std::string> > clang::clangd::config::Fragment::CompileFlagsBlock::CompilationDatabase

Directory to search for compilation database (compile_comands.json etc).

Valid values are:

  • A single path to a directory (absolute, or relative to the fragment)
  • Ancestors: search all parent directories (the default)
  • None: do not use a compilation database, just default flags.

Definition at line 163 of file ConfigFragment.h.

◆ Remove

std::vector<Located<std::string> > clang::clangd::config::Fragment::CompileFlagsBlock::Remove

List of flags to remove from the compile command.

  • If the value is a recognized clang flag (like "-I") then it will be removed along with any arguments. Synonyms like –include-dir= will also be removed.
  • Otherwise, if the value ends in * (like "-DFOO=*") then any argument with the prefix will be removed.
  • Otherwise any argument exactly matching the value is removed.

In all cases, -Xclang is also removed where needed.

Example: Command: clang++ –include-directory=/usr/include -DFOO=42 foo.cc Remove: [-I, -DFOO=*] Result: clang++ foo.cc

Flags added by the same CompileFlags entry will not be removed.

Definition at line 156 of file ConfigFragment.h.


The documentation for this struct was generated from the following file: