clang-tools
3.8.0
|
Implementation of the ClangTidyOptionsProvider
interface, which tries to find a configuration file in the closest parent directory of each source file.
More...
#include <ClangTidyOptions.h>
Public Types | |
typedef std::pair< std::string, std::function< llvm::ErrorOr < ClangTidyOptions > llvm::StringRef)> > | ConfigFileHandler |
typedef std::vector < ConfigFileHandler > | ConfigFileHandlers |
Configuration file handlers listed in the order of priority. More... | |
Public Member Functions | |
FileOptionsProvider (const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &OverrideOptions) | |
Initializes the FileOptionsProvider instance. More... | |
FileOptionsProvider (const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &OverrideOptions, const ConfigFileHandlers &ConfigHandlers) | |
Initializes the FileOptionsProvider instance with a custom set of configuration file handlers. More... | |
ClangTidyOptions | getOptions (llvm::StringRef FileName) override |
Returns options applying to a specific translation unit with the specified FileName . More... | |
![]() | |
DefaultOptionsProvider (const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &Options) | |
const ClangTidyGlobalOptions & | getGlobalOptions () override |
Returns global options, which are independent of the file. More... | |
![]() | |
virtual | ~ClangTidyOptionsProvider () |
Protected Member Functions | |
llvm::Optional< ClangTidyOptions > | TryReadConfigFile (llvm::StringRef Directory) |
Try to read configuration files from Directory using registered ConfigHandlers . More... | |
Protected Attributes | |
llvm::StringMap< ClangTidyOptions > | CachedOptions |
ClangTidyOptions | OverrideOptions |
ConfigFileHandlers | ConfigHandlers |
Implementation of the ClangTidyOptionsProvider
interface, which tries to find a configuration file in the closest parent directory of each source file.
By default, files named ".clang-tidy" will be considered, and the clang::tidy::parseConfiguration
function will be used for parsing, but a custom set of configuration file names and parsing functions can be specified using the appropriate constructor.
Definition at line 136 of file ClangTidyOptions.h.
typedef std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions> llvm::StringRef)> > clang::tidy::FileOptionsProvider::ConfigFileHandler |
Definition at line 141 of file ClangTidyOptions.h.
typedef std::vector<ConfigFileHandler> clang::tidy::FileOptionsProvider::ConfigFileHandlers |
Configuration file handlers listed in the order of priority.
Custom configuration file formats can be supported by constructing the list of handlers and passing it to the appropriate FileOptionsProvider
constructor. E.g. initialization of a FileOptionsProvider
with support of a custom configuration file format for files named ".my-tidy-config" could look similar to this:
With the order of handlers shown above, the ".my-tidy-config" file would take precedence over ".clang-tidy" if both reside in the same directory.
Definition at line 160 of file ClangTidyOptions.h.
clang::tidy::FileOptionsProvider::FileOptionsProvider | ( | const ClangTidyGlobalOptions & | GlobalOptions, |
const ClangTidyOptions & | DefaultOptions, | ||
const ClangTidyOptions & | OverrideOptions | ||
) |
Initializes the FileOptionsProvider
instance.
GlobalOptions | are just stored and returned to the caller of getGlobalOptions . |
DefaultOptions | are used for all settings not specified in a configuration file. |
If any of the
OverrideOptions | fields are set, they will override whatever options are read from the configuration file. |
Definition at line 146 of file ClangTidyOptions.cpp.
References CachedOptions, ConfigHandlers, clang::tidy::ClangTidyOptions::mergeWith(), and clang::tidy::parseConfiguration().
clang::tidy::FileOptionsProvider::FileOptionsProvider | ( | const ClangTidyGlobalOptions & | GlobalOptions, |
const ClangTidyOptions & | DefaultOptions, | ||
const ClangTidyOptions & | OverrideOptions, | ||
const ConfigFileHandlers & | ConfigHandlers | ||
) |
Initializes the FileOptionsProvider
instance with a custom set of configuration file handlers.
GlobalOptions | are just stored and returned to the caller of getGlobalOptions . |
DefaultOptions | are used for all settings not specified in a configuration file. |
If any of the
OverrideOptions | fields are set, they will override whatever options are read from the configuration file. |
ConfigHandlers | specifies a custom set of configuration file handlers. Each handler is a pair of configuration file name and a function that can parse configuration from this file type. The configuration files in each directory are searched for in the order of appearance in ConfigHandlers . |
Definition at line 156 of file ClangTidyOptions.cpp.
References CachedOptions, and clang::tidy::ClangTidyOptions::mergeWith().
|
overridevirtual |
Returns options applying to a specific translation unit with the specified FileName
.
Reimplemented from clang::tidy::DefaultOptionsProvider.
Definition at line 169 of file ClangTidyOptions.cpp.
References CachedOptions, Path, Result, and TryReadConfigFile().
|
protected |
Try to read configuration files from Directory
using registered ConfigHandlers
.
Definition at line 209 of file ClangTidyOptions.cpp.
References ConfigHandlers, clang::tidy::DefaultOptionsProvider::getOptions(), clang::tidy::ClangTidyOptions::mergeWith(), and OverrideOptions.
Referenced by getOptions().
|
protected |
Definition at line 205 of file ClangTidyOptions.h.
Referenced by FileOptionsProvider(), and getOptions().
|
protected |
Definition at line 207 of file ClangTidyOptions.h.
Referenced by FileOptionsProvider(), and TryReadConfigFile().
|
protected |
Definition at line 206 of file ClangTidyOptions.h.
Referenced by TryReadConfigFile().