clang-tools 20.0.0git
|
Produces fixes to insert specified includes to source files, if not yet present. More...
#include <IncludeInserter.h>
Public Member Functions | |
IncludeInserter (IncludeSorter::IncludeStyle Style, bool SelfContainedDiags) | |
Initializes the IncludeInserter using the IncludeStyle Style . | |
void | registerPreprocessor (Preprocessor *PP) |
Registers this with the Preprocessor PP , must be called before this class is used. | |
std::optional< FixItHint > | createIncludeInsertion (FileID FileID, llvm::StringRef Header) |
Creates a Header inclusion directive fixit in the File FileID . | |
std::optional< FixItHint > | createMainFileIncludeInsertion (llvm::StringRef Header) |
Creates a Header inclusion directive fixit in the main file. | |
IncludeSorter::IncludeStyle | getStyle () const |
Friends | |
class | IncludeInserterCallback |
Produces fixes to insert specified includes to source files, if not yet present.
IncludeInserter
can be used in clang-tidy checks in the following way:
Definition at line 55 of file IncludeInserter.h.
|
explicit |
Initializes the IncludeInserter using the IncludeStyle Style
.
In most cases the Style
will be retrieved from the ClangTidyOptions using
Definition at line 39 of file IncludeInserter.cpp.
std::optional< FixItHint > clang::tidy::utils::IncludeInserter::createIncludeInsertion | ( | FileID | FileID, |
llvm::StringRef | Header | ||
) |
Creates a Header
inclusion directive fixit in the File FileID
.
When Header
is enclosed in angle brackets, uses angle brackets in the inclusion directive, otherwise uses quotes. Returns std::nullopt
on error or if the inclusion directive already exists.
Definition at line 71 of file IncludeInserter.cpp.
References clang::tidy::utils::IncludeSorter::createIncludeInsertion(), and IsAngled.
Referenced by clang::tidy::modernize::MinMaxUseInitializerListCheck::check(), clang::tidy::utils::TransformerClangTidyCheck::check(), clang::tidy::utils::UseRangesCheck::check(), clang::tidy::abseil::StringFindStartswithCheck::check(), clang::tidy::cppcoreguidelines::InitVariablesCheck::check(), clang::tidy::misc::UniqueptrResetReleaseCheck::check(), clang::tidy::modernize::PassByValueCheck::check(), clang::tidy::modernize::ReplaceRandomShuffleCheck::check(), clang::tidy::modernize::UseIntegerSignComparisonCheck::check(), clang::tidy::modernize::UseStdFormatCheck::check(), clang::tidy::modernize::UseStdNumbersCheck::check(), clang::tidy::modernize::UseStdPrintCheck::check(), clang::tidy::performance::TypePromotionInMathFnCheck::check(), clang::tidy::readability::UseStdMinMaxCheck::check(), createMainFileIncludeInsertion(), and clang::tidy::performance::UnnecessaryValueParamCheck::handleMoveFix().
std::optional< FixItHint > clang::tidy::utils::IncludeInserter::createMainFileIncludeInsertion | ( | llvm::StringRef | Header | ) |
Creates a Header
inclusion directive fixit in the main file.
When Header
is enclosed in angle brackets, uses angle brackets in the inclusion directive, otherwise uses quotes. Returns std::nullopt
on error or if the inclusion directive already exists.
Definition at line 86 of file IncludeInserter.cpp.
References createIncludeInsertion().
Referenced by clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::check(), and clang::tidy::modernize::ReplaceAutoPtrCheck::check().
|
inline |
Definition at line 85 of file IncludeInserter.h.
Referenced by clang::tidy::utils::UseRangesCheck::storeOptions(), clang::tidy::abseil::StringFindStartswithCheck::storeOptions(), clang::tidy::bugprone::ImplicitWideningOfMultiplicationResultCheck::storeOptions(), clang::tidy::cppcoreguidelines::InitVariablesCheck::storeOptions(), clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::storeOptions(), clang::tidy::misc::UniqueptrResetReleaseCheck::storeOptions(), clang::tidy::modernize::LoopConvertCheck::storeOptions(), clang::tidy::modernize::MakeSmartPtrCheck::storeOptions(), clang::tidy::modernize::MinMaxUseInitializerListCheck::storeOptions(), clang::tidy::modernize::PassByValueCheck::storeOptions(), clang::tidy::modernize::ReplaceAutoPtrCheck::storeOptions(), clang::tidy::modernize::ReplaceRandomShuffleCheck::storeOptions(), clang::tidy::modernize::UseIntegerSignComparisonCheck::storeOptions(), clang::tidy::modernize::UseStdFormatCheck::storeOptions(), clang::tidy::modernize::UseStdNumbersCheck::storeOptions(), clang::tidy::modernize::UseStdPrintCheck::storeOptions(), clang::tidy::performance::TypePromotionInMathFnCheck::storeOptions(), clang::tidy::performance::UnnecessaryValueParamCheck::storeOptions(), clang::tidy::readability::UseStdMinMaxCheck::storeOptions(), and clang::tidy::utils::TransformerClangTidyCheck::storeOptions().
void clang::tidy::utils::IncludeInserter::registerPreprocessor | ( | Preprocessor * | PP | ) |
Registers this with the Preprocessor PP
, must be called before this class is used.
Definition at line 43 of file IncludeInserter.cpp.
Referenced by clang::tidy::utils::UseRangesCheck::registerPPCallbacks(), clang::tidy::abseil::StringFindStartswithCheck::registerPPCallbacks(), clang::tidy::bugprone::ImplicitWideningOfMultiplicationResultCheck::registerPPCallbacks(), clang::tidy::cppcoreguidelines::InitVariablesCheck::registerPPCallbacks(), clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::registerPPCallbacks(), clang::tidy::misc::UniqueptrResetReleaseCheck::registerPPCallbacks(), clang::tidy::modernize::LoopConvertCheck::registerPPCallbacks(), clang::tidy::modernize::MakeSmartPtrCheck::registerPPCallbacks(), clang::tidy::modernize::MinMaxUseInitializerListCheck::registerPPCallbacks(), clang::tidy::modernize::PassByValueCheck::registerPPCallbacks(), clang::tidy::modernize::ReplaceAutoPtrCheck::registerPPCallbacks(), clang::tidy::modernize::ReplaceRandomShuffleCheck::registerPPCallbacks(), clang::tidy::modernize::UseIntegerSignComparisonCheck::registerPPCallbacks(), clang::tidy::modernize::UseStdFormatCheck::registerPPCallbacks(), clang::tidy::modernize::UseStdNumbersCheck::registerPPCallbacks(), clang::tidy::modernize::UseStdPrintCheck::registerPPCallbacks(), clang::tidy::performance::TypePromotionInMathFnCheck::registerPPCallbacks(), clang::tidy::performance::UnnecessaryValueParamCheck::registerPPCallbacks(), clang::tidy::readability::UseStdMinMaxCheck::registerPPCallbacks(), and clang::tidy::utils::TransformerClangTidyCheck::registerPPCallbacks().
|
friend |
Definition at line 98 of file IncludeInserter.h.