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

#include <ClangTidyOptions.h>

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

Classes

struct  OptionsCache

Protected Types

using ConfigFileHandler
using ConfigFileHandlers = std::vector<ConfigFileHandler>
 Configuration file handlers listed in the order of priority.

Protected Member Functions

 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

struct clang::tidy::FileOptionsBaseProvider::OptionsCache CachedOptions
ClangTidyOptions OverrideOptions
ConfigFileHandlers ConfigHandlers
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS

Additional Inherited Members

Public Types inherited from clang::tidy::ClangTidyOptionsProvider
using OptionsSource = std::pair<ClangTidyOptions, std::string>
 ClangTidyOptions and its source.
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.
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::ClangTidyOptionsProvider
virtual ~ClangTidyOptionsProvider ()
ClangTidyOptions getOptions (llvm::StringRef FileName)
 Returns options applying to a specific translation unit with the specified FileName.
Static Public Attributes inherited from clang::tidy::ClangTidyOptionsProvider
static const char OptionsSourceTypeDefaultBinary []
static const char OptionsSourceTypeCheckCommandLineOption []
static const char OptionsSourceTypeConfigCommandLineOption []

Detailed Description

Definition at line 217 of file ClangTidyOptions.h.

Member Typedef Documentation

◆ ConfigFileHandler

Initial value:
std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions>(
llvm::MemoryBufferRef)>>

Definition at line 221 of file ClangTidyOptions.h.

◆ 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:

ConfigHandlers.emplace_back(".my-tidy-config", parseMyConfigFormat);
ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration);
return std::make_unique<FileOptionsProvider>(
GlobalOptions, DefaultOptions, OverrideOptions, ConfigHandlers);
std::vector< ConfigFileHandler > ConfigFileHandlers
Configuration file handlers listed in the order of priority.
llvm::ErrorOr< ClangTidyOptions > parseConfiguration(llvm::MemoryBufferRef Config)
Parses configuration from JSON and returns ClangTidyOptions or an error.

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

Constructor & Destructor Documentation

◆ FileOptionsBaseProvider() [1/2]

clang::tidy::FileOptionsBaseProvider::FileOptionsBaseProvider ( ClangTidyGlobalOptions GlobalOptions,
ClangTidyOptions DefaultOptions,
ClangTidyOptions OverrideOptions,
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS )
protected

◆ FileOptionsBaseProvider() [2/2]

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

Member Function Documentation

◆ addRawFileOptions()

void clang::tidy::FileOptionsBaseProvider::addRawFileOptions ( llvm::StringRef AbsolutePath,
std::vector< OptionsSource > & CurOptions )
protected

◆ getNormalizedAbsolutePath()

llvm::ErrorOr< llvm::SmallString< 128 > > clang::tidy::FileOptionsBaseProvider::getNormalizedAbsolutePath ( llvm::StringRef AbsolutePath)
protected

◆ tryReadConfigFile()

std::optional< OptionsSource > clang::tidy::FileOptionsBaseProvider::tryReadConfigFile ( llvm::StringRef Directory)
protected

Try to read configuration files from Directory using registered ConfigHandlers.

Definition at line 480 of file ClangTidyOptions.cpp.

References ConfigFile(), ConfigHandlers, Directory(), and FS.

Referenced by addRawFileOptions().

Member Data Documentation

◆ CachedOptions

struct clang::tidy::FileOptionsBaseProvider::OptionsCache clang::tidy::FileOptionsBaseProvider::CachedOptions
protected

Referenced by addRawFileOptions().

◆ ConfigHandlers

ConfigFileHandlers clang::tidy::FileOptionsBaseProvider::ConfigHandlers
protected

◆ FS

llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> clang::tidy::FileOptionsBaseProvider::FS
protected

◆ OverrideOptions


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