clang-tools 22.0.0git
clang::tidy::FileOptionsProvider Class Reference

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>

Inheritance diagram for clang::tidy::FileOptionsProvider:
[legend]

Public Member Functions

 FileOptionsProvider (ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions, ClangTidyOptions OverrideOptions, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS=nullptr)
 Initializes the FileOptionsProvider instance.
 FileOptionsProvider (ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions, ClangTidyOptions OverrideOptions, ConfigFileHandlers ConfigHandlers)
 Initializes the FileOptionsProvider instance with a custom set of configuration file handlers.
std::vector< OptionsSourcegetRawOptions (llvm::StringRef FileName) override
 Returns an ordered vector of OptionsSources, in order of increasing priority.
Public Member Functions inherited from clang::tidy::DefaultOptionsProvider
 DefaultOptionsProvider (ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions Options)
const ClangTidyGlobalOptionsgetGlobalOptions () override
 Returns global options, which are independent of the file.
Public Member Functions inherited from clang::tidy::ClangTidyOptionsProvider
virtual ~ClangTidyOptionsProvider ()
ClangTidyOptions getOptions (llvm::StringRef FileName)
 Returns options applying to a specific translation unit with the specified FileName.

Additional Inherited Members

Public Types inherited from clang::tidy::ClangTidyOptionsProvider
using OptionsSource = std::pair<ClangTidyOptions, std::string>
 ClangTidyOptions and its source.
Static Public Attributes inherited from clang::tidy::ClangTidyOptionsProvider
static const char OptionsSourceTypeDefaultBinary []
static const char OptionsSourceTypeCheckCommandLineOption []
static const char OptionsSourceTypeConfigCommandLineOption []
Protected Types inherited from clang::tidy::FileOptionsBaseProvider
using ConfigFileHandler
using ConfigFileHandlers = std::vector<ConfigFileHandler>
 Configuration file handlers listed in the order of priority.
Protected Member Functions inherited from clang::tidy::FileOptionsBaseProvider
 FileOptionsBaseProvider (ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions, ClangTidyOptions OverrideOptions, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS)
 FileOptionsBaseProvider (ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions, ClangTidyOptions OverrideOptions, ConfigFileHandlers ConfigHandlers)
void addRawFileOptions (llvm::StringRef AbsolutePath, std::vector< OptionsSource > &CurOptions)
llvm::ErrorOr< llvm::SmallString< 128 > > getNormalizedAbsolutePath (llvm::StringRef AbsolutePath)
std::optional< OptionsSourcetryReadConfigFile (llvm::StringRef Directory)
 Try to read configuration files from Directory using registered ConfigHandlers.
Protected Attributes inherited from clang::tidy::FileOptionsBaseProvider
struct clang::tidy::FileOptionsBaseProvider::OptionsCache CachedOptions
ClangTidyOptions OverrideOptions
ConfigFileHandlers ConfigHandlers
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS

Detailed Description

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 295 of file ClangTidyOptions.h.

Constructor & Destructor Documentation

◆ FileOptionsProvider() [1/2]

clang::tidy::FileOptionsProvider::FileOptionsProvider ( ClangTidyGlobalOptions GlobalOptions,
ClangTidyOptions DefaultOptions,
ClangTidyOptions OverrideOptions,
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS = nullptr )

Initializes the FileOptionsProvider instance.

Parameters
GlobalOptionsare just stored and returned to the caller of getGlobalOptions.
DefaultOptionsare used for all settings not specified in a configuration file.

If any of the

Parameters
OverrideOptionsfields are set, they will override whatever options are read from the configuration file.

Definition at line 440 of file ClangTidyOptions.cpp.

References clang::tidy::FileOptionsBaseProvider::FileOptionsBaseProvider(), and clang::tidy::FileOptionsBaseProvider::OverrideOptions.

◆ FileOptionsProvider() [2/2]

clang::tidy::FileOptionsProvider::FileOptionsProvider ( ClangTidyGlobalOptions GlobalOptions,
ClangTidyOptions DefaultOptions,
ClangTidyOptions OverrideOptions,
FileOptionsBaseProvider::ConfigFileHandlers ConfigHandlers )

Initializes the FileOptionsProvider instance with a custom set of configuration file handlers.

Parameters
GlobalOptionsare just stored and returned to the caller of getGlobalOptions.
DefaultOptionsare used for all settings not specified in a configuration file.

If any of the

Parameters
OverrideOptionsfields are set, they will override whatever options are read from the configuration file.
ConfigHandlersspecifies 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 448 of file ClangTidyOptions.cpp.

References clang::tidy::FileOptionsBaseProvider::ConfigHandlers, clang::tidy::FileOptionsBaseProvider::FileOptionsBaseProvider(), and clang::tidy::FileOptionsBaseProvider::OverrideOptions.

Member Function Documentation

◆ getRawOptions()

std::vector< OptionsSource > clang::tidy::FileOptionsProvider::getRawOptions ( llvm::StringRef FileName)
overridevirtual

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