Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
12 #include "llvm/ADT/IntrusiveRefCntPtr.h"
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/ErrorOr.h"
17 #include "llvm/Support/VirtualFileSystem.h"
21 #include <system_error>
63 unsigned Order)
const;
96 llvm::Optional<std::string>
User;
111 typedef std::map<std::string, ClangTidyValue>
OptionMap;
161 virtual std::vector<OptionsSource>
175 : GlobalOptions(GlobalOptions), DefaultOptions(Options) {}
177 return GlobalOptions;
190 typedef std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions>(
217 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS =
nullptr);
226 std::vector<OptionsSource> &CurOptions);
235 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS;
247 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS =
nullptr);
278 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS =
nullptr);
319 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
ConfigOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &ConfigOptions, const ClangTidyOptions &OverrideOptions, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS=nullptr)
std::vector< OptionsSource > getRawOptions(llvm::StringRef FileName) override
Returns an ordered vector of OptionsSources, in order of increasing priority.
Implementation of the ClangTidyOptionsProvider interface, which returns the same options for all file...
llvm::Optional< std::string > Checks
Checks filter.
unsigned Priority
Priority stores relative precedence of the value loaded from config files to disambigute local vs glo...
ConfigFileHandlers ConfigHandlers
DefaultOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &Options)
Abstract interface for retrieving various ClangTidy options.
std::error_code parseLineFilter(StringRef LineFilter, clang::tidy::ClangTidyGlobalOptions &Options)
Parses -line-filter option and stores it to the Options.
ClangTidyValue(llvm::StringRef Value, unsigned Priority=0)
std::vector< std::string > ArgList
static const char OptionsSourceTypeCheckCommandLineOption[]
void addRawFileOptions(llvm::StringRef AbsolutePath, std::vector< OptionsSource > &CurOptions)
Helper structure for storing option value with priority of the value.
Contains a list of line ranges in a single file.
llvm::Optional< ArgList > ExtraArgsBefore
Add extra compilation arguments to the start of the list.
std::vector< LineRange > LineRanges
A list of line ranges in this file, for which we show warnings.
llvm::Optional< std::string > User
Specifies the name or e-mail of the user running clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
Contains options for clang-tidy.
static const char OptionsSourceTypeDefaultBinary[]
llvm::Optional< bool > InheritParentConfig
Only used in the FileOptionsProvider and ConfigOptionsProvider.
const ClangTidyGlobalOptions & getGlobalOptions() override
Returns global options, which are independent of the file.
llvm::Optional< std::string > FormatStyle
Format code around applied fixes with clang-format using this style.
llvm::Optional< bool > UseColor
Use colors in diagnostics. If missing, it will be auto detected.
Implementation of the ClangTidyOptionsProvider interface, which tries to find a configuration file in...
std::pair< ClangTidyOptions, std::string > OptionsSource
ClangTidyOptions and its source.
llvm::Optional< std::string > HeaderFilterRegex
Output warnings from headers matching this filter.
llvm::Optional< bool > SystemHeaders
Output warnings from system headers matching HeaderFilterRegex.
FileOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &OverrideOptions, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS=nullptr)
Initializes the FileOptionsProvider instance.
std::vector< FileFilter > LineFilter
Output warnings from certain line ranges of certain files only.
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS
std::vector< OptionsSource > getRawOptions(llvm::StringRef FileName) override
Returns an ordered vector of OptionsSources, in order of increasing priority.
llvm::ErrorOr< ClangTidyOptions > parseConfiguration(StringRef Config)
llvm::StringRef Directory
virtual const ClangTidyGlobalOptions & getGlobalOptions()=0
Returns global options, which are independent of the file.
llvm::StringMap< OptionsSource > CachedOptions
std::string configurationAsText(const ClangTidyOptions &Options)
Serializes configuration to a YAML-encoded string.
llvm::Optional< OptionsSource > tryReadConfigFile(llvm::StringRef Directory)
Try to read configuration files from Directory using registered ConfigHandlers.
static const char OptionsSourceTypeConfigCommandLineOption[]
FileOptionsBaseProvider(const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &OverrideOptions, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS=nullptr)
static cl::opt< std::string > Config("config", cl::desc(R"(
Specifies a configuration in YAML/JSON format:
-config="{Checks:' *', CheckOptions:[{key:x, value:y}]}"
When the value is empty, clang-tidy will
attempt to find a file named .clang-tidy for
each source file in its parent directories.
)"), cl::init(""), cl::cat(ClangTidyCategory))
llvm::Optional< std::string > WarningsAsErrors
WarningsAsErrors filter.
Implementation of ClangTidyOptions interface, which is used for '-config' command-line option.
std::string Name
File name.
ClangTidyOptions getOptions(llvm::StringRef FileName)
Returns options applying to a specific translation unit with the specified FileName.
std::vector< ConfigFileHandler > ConfigFileHandlers
Configuration file handlers listed in the order of priority.
std::pair< std::string, std::function< llvm::ErrorOr< ClangTidyOptions > llvm::StringRef)> > ConfigFileHandler
static cl::opt< std::string > LineFilter("line-filter", cl::desc(R"(
List of files with line ranges to filter the
warnings. Can be used together with
-header-filter. The format of the list is a
JSON array of objects:
[
{"name":"file1.cpp","lines":[[1,3],[5,7]]},
{"name":"file2.h"}
]
)"), cl::init(""), cl::cat(ClangTidyCategory))
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::pair< unsigned, unsigned > LineRange
LineRange is a pair<start, end> (inclusive).
virtual std::vector< OptionsSource > getRawOptions(llvm::StringRef FileName)=0
Returns an ordered vector of OptionsSources, in order of increasing priority.
ClangTidyOptions OverrideOptions
virtual ~ClangTidyOptionsProvider()
ClangTidyOptions mergeWith(const ClangTidyOptions &Other, unsigned Order) const
Creates a new ClangTidyOptions instance combined from all fields of this instance overridden by the f...
ClangTidyValue(const char *Value)
static ClangTidyOptions getDefaults()
These options are used for all settings that haven't been overridden by the OptionsProvider.
std::vector< OptionsSource > getRawOptions(llvm::StringRef FileName) override
Returns an ordered vector of OptionsSources, in order of increasing priority.
llvm::Optional< ArgList > ExtraArgs
Add extra compilation arguments to the end of the list.
std::pair< std::string, std::string > StringPair
std::map< std::string, ClangTidyValue > OptionMap