clang-tools  14.0.0git
Protected Types | Protected Member Functions | Protected Attributes | List of all members
clang::tidy::FileOptionsBaseProvider Class Reference

#include <ClangTidyOptions.h>

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

Protected Types

typedef std::pair< std::string, std::function< llvm::ErrorOr< ClangTidyOptions > llvm::MemoryBufferRef)> > ConfigFileHandler
 
typedef std::vector< ConfigFileHandlerConfigFileHandlers
 Configuration file handlers listed in the order of priority. More...
 

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::Optional< OptionsSourcetryReadConfigFile (llvm::StringRef Directory)
 Try to read configuration files from Directory using registered ConfigHandlers. More...
 

Protected Attributes

llvm::StringMap< OptionsSourceCachedOptions
 
ClangTidyOptions OverrideOptions
 
ConfigFileHandlers ConfigHandlers
 
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS
 

Additional Inherited Members

- Public Types inherited from clang::tidy::ClangTidyOptionsProvider
typedef std::pair< ClangTidyOptions, std::string > OptionsSource
 ClangTidyOptions and its source. More...
 
- 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. More...
 
std::vector< OptionsSourcegetRawOptions (llvm::StringRef FileName) override
 Returns an ordered vector of OptionsSources, in order of increasing priority. More...
 
- 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. More...
 
- 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 191 of file ClangTidyOptions.h.

Member Typedef Documentation

◆ ConfigFileHandler

typedef std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions> llvm::MemoryBufferRef)> > clang::tidy::FileOptionsBaseProvider::ConfigFileHandler
protected

Definition at line 197 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);

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 216 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

Definition at line 228 of file ClangTidyOptions.cpp.

◆ FileOptionsBaseProvider() [2/2]

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

Definition at line 240 of file ClangTidyOptions.cpp.

Member Function Documentation

◆ addRawFileOptions()

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

◆ tryReadConfigFile()

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

Try to read configuration files from Directory using registered ConfigHandlers.

Definition at line 329 of file ClangTidyOptions.cpp.

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

Member Data Documentation

◆ CachedOptions

llvm::StringMap<OptionsSource> clang::tidy::FileOptionsBaseProvider::CachedOptions
protected

Definition at line 236 of file ClangTidyOptions.h.

◆ ConfigHandlers

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

Definition at line 238 of file ClangTidyOptions.h.

Referenced by tryReadConfigFile().

◆ FS

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

◆ OverrideOptions

ClangTidyOptions clang::tidy::FileOptionsBaseProvider::OverrideOptions
protected

The documentation for this class was generated from the following files:
clang::tidy::parseConfiguration
llvm::ErrorOr< ClangTidyOptions > parseConfiguration(llvm::MemoryBufferRef Config)
Parses configuration from JSON and returns ClangTidyOptions or an error.
Definition: ClangTidyOptions.cpp:384
clang::tidy::FileOptionsBaseProvider::ConfigHandlers
ConfigFileHandlers ConfigHandlers
Definition: ClangTidyOptions.h:238
clang::tidy::FileOptionsBaseProvider::ConfigFileHandlers
std::vector< ConfigFileHandler > ConfigFileHandlers
Configuration file handlers listed in the order of priority.
Definition: ClangTidyOptions.h:216
clang::tidy::FileOptionsBaseProvider::OverrideOptions
ClangTidyOptions OverrideOptions
Definition: ClangTidyOptions.h:237