clang-tools  14.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::tidy::ClangTidyOptions Struct Reference

Contains options for clang-tidy. More...

#include <ClangTidyOptions.h>

Collaboration diagram for clang::tidy::ClangTidyOptions:
Collaboration graph
[legend]

Classes

struct  ClangTidyValue
 Helper structure for storing option value with priority of the value. More...
 

Public Types

typedef std::pair< std::string, std::string > StringPair
 
typedef llvm::StringMap< ClangTidyValueOptionMap
 
typedef std::vector< std::string > ArgList
 

Public Member Functions

ClangTidyOptionsmergeWith (const ClangTidyOptions &Other, unsigned Order)
 Overwrites all fields in here by the fields of Other that have a value. More...
 
LLVM_NODISCARD ClangTidyOptions merge (const ClangTidyOptions &Other, unsigned Order) const
 Creates a new ClangTidyOptions instance combined from all fields of this instance overridden by the fields of Other that have a value. More...
 

Static Public Member Functions

static ClangTidyOptions getDefaults ()
 These options are used for all settings that haven't been overridden by the OptionsProvider. More...
 

Public Attributes

llvm::Optional< std::string > Checks
 Checks filter. More...
 
llvm::Optional< std::string > WarningsAsErrors
 WarningsAsErrors filter. More...
 
llvm::Optional< std::string > HeaderFilterRegex
 Output warnings from headers matching this filter. More...
 
llvm::Optional< bool > SystemHeaders
 Output warnings from system headers matching HeaderFilterRegex. More...
 
llvm::Optional< std::string > FormatStyle
 Format code around applied fixes with clang-format using this style. More...
 
llvm::Optional< std::string > User
 Specifies the name or e-mail of the user running clang-tidy. More...
 
OptionMap CheckOptions
 Key-value mapping used to store check-specific options. More...
 
llvm::Optional< ArgListExtraArgs
 Add extra compilation arguments to the end of the list. More...
 
llvm::Optional< ArgListExtraArgsBefore
 Add extra compilation arguments to the start of the list. More...
 
llvm::Optional< bool > InheritParentConfig
 Only used in the FileOptionsProvider and ConfigOptionsProvider. More...
 
llvm::Optional< bool > UseColor
 Use colors in diagnostics. If missing, it will be auto detected. More...
 

Detailed Description

Contains options for clang-tidy.

These options may be read from configuration files, and may be different for different translation units.

Definition at line 50 of file ClangTidyOptions.h.

Member Typedef Documentation

◆ ArgList

typedef std::vector<std::string> clang::tidy::ClangTidyOptions::ArgList

Definition at line 120 of file ClangTidyOptions.h.

◆ OptionMap

Definition at line 115 of file ClangTidyOptions.h.

◆ StringPair

typedef std::pair<std::string, std::string> clang::tidy::ClangTidyOptions::StringPair

Definition at line 114 of file ClangTidyOptions.h.

Member Function Documentation

◆ getDefaults()

ClangTidyOptions clang::tidy::ClangTidyOptions::getDefaults ( )
static

These options are used for all settings that haven't been overridden by the OptionsProvider.

Allow no checks and no headers by default. This method initializes check-specific options by calling ClangTidyModule::getModuleOptions() of each registered ClangTidyModule.

Definition at line 109 of file ClangTidyOptions.cpp.

References Checks, FormatStyle, HeaderFilterRegex, mergeWith(), SystemHeaders, User, and WarningsAsErrors.

Referenced by clang::tidy::ClangTidyContext::getOptionsForFile().

◆ merge()

ClangTidyOptions clang::tidy::ClangTidyOptions::merge ( const ClangTidyOptions Other,
unsigned  Order 
) const

Creates a new ClangTidyOptions instance combined from all fields of this instance overridden by the fields of Other that have a value.

Order specifies precedence of Other option.

Definition at line 166 of file ClangTidyOptions.cpp.

Referenced by clang::tidy::ClangTidyContext::getOptionsForFile().

◆ mergeWith()

ClangTidyOptions & clang::tidy::ClangTidyOptions::mergeWith ( const ClangTidyOptions Other,
unsigned  Order 
)

Overwrites all fields in here by the fields of Other that have a value.

Order specifies precedence of Other option.

Definition at line 145 of file ClangTidyOptions.cpp.

References CheckOptions, Checks, ExtraArgs, ExtraArgsBefore, FormatStyle, HeaderFilterRegex, clang::tidy::mergeCommaSeparatedLists(), clang::tidy::mergeVectors(), clang::tidy::overrideValue(), SystemHeaders, UseColor, User, and WarningsAsErrors.

Referenced by getDefaults().

Member Data Documentation

◆ CheckOptions

OptionMap clang::tidy::ClangTidyOptions::CheckOptions

Key-value mapping used to store check-specific options.

Definition at line 118 of file ClangTidyOptions.h.

Referenced by clang::tidy::llvm_check::LLVMModule::getModuleOptions(), llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ Checks

llvm::Optional<std::string> clang::tidy::ClangTidyOptions::Checks

◆ ExtraArgs

llvm::Optional<ArgList> clang::tidy::ClangTidyOptions::ExtraArgs

Add extra compilation arguments to the end of the list.

Definition at line 123 of file ClangTidyOptions.h.

Referenced by llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ ExtraArgsBefore

llvm::Optional<ArgList> clang::tidy::ClangTidyOptions::ExtraArgsBefore

Add extra compilation arguments to the start of the list.

Definition at line 126 of file ClangTidyOptions.h.

Referenced by llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ FormatStyle

llvm::Optional<std::string> clang::tidy::ClangTidyOptions::FormatStyle

Format code around applied fixes with clang-format using this style.

Can be one of:

  • 'none' - don't format code around applied fixes;
  • 'llvm', 'google', 'mozilla' or other predefined clang-format style names;
  • 'file' - use the .clang-format file in the closest parent directory of each source file;
  • '{inline-formatting-style-in-yaml-format}'.

See clang-format documentation for more about configuring format style.

Definition at line 94 of file ClangTidyOptions.h.

Referenced by getDefaults(), llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ HeaderFilterRegex

llvm::Optional<std::string> clang::tidy::ClangTidyOptions::HeaderFilterRegex

Output warnings from headers matching this filter.

Warnings from main files will always be displayed.

Definition at line 77 of file ClangTidyOptions.h.

Referenced by getDefaults(), llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ InheritParentConfig

llvm::Optional<bool> clang::tidy::ClangTidyOptions::InheritParentConfig

Only used in the FileOptionsProvider and ConfigOptionsProvider.

If true and using a FileOptionsProvider, it will take a configuration file in the parent directory (if any exists) and apply this config file on top of the parent one. IF true and using a ConfigOptionsProvider, it will apply this config on top of any configuation file it finds in the directory using the same logic as FileOptionsProvider. If false or missing, only this configuration file will be used.

Definition at line 135 of file ClangTidyOptions.h.

Referenced by clang::tidy::ConfigOptionsProvider::getRawOptions(), and llvm::yaml::MappingTraits< ClangTidyOptions >::mapping().

◆ SystemHeaders

llvm::Optional<bool> clang::tidy::ClangTidyOptions::SystemHeaders

Output warnings from system headers matching HeaderFilterRegex.

Definition at line 80 of file ClangTidyOptions.h.

Referenced by getDefaults(), and mergeWith().

◆ UseColor

llvm::Optional<bool> clang::tidy::ClangTidyOptions::UseColor

Use colors in diagnostics. If missing, it will be auto detected.

Definition at line 138 of file ClangTidyOptions.h.

Referenced by llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ User

llvm::Optional<std::string> clang::tidy::ClangTidyOptions::User

Specifies the name or e-mail of the user running clang-tidy.

This option is used, for example, to place the correct user name in TODO() comments in the relevant check.

Definition at line 100 of file ClangTidyOptions.h.

Referenced by getDefaults(), llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().

◆ WarningsAsErrors

llvm::Optional<std::string> clang::tidy::ClangTidyOptions::WarningsAsErrors

WarningsAsErrors filter.

Definition at line 73 of file ClangTidyOptions.h.

Referenced by getDefaults(), llvm::yaml::MappingTraits< ClangTidyOptions >::mapping(), and mergeWith().


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