clang-tools 20.0.0git
|
Namespaces | |
namespace | decl_ref_expr |
namespace | fixit |
namespace | lexer |
namespace | options |
namespace | type_traits |
Classes | |
struct | BraceInsertionHints |
A provider of fix-it hints to insert opening and closing braces. More... | |
class | ExceptionAnalyzer |
This class analysis if a FunctionDecl can in principle throw an exception, either directly or indirectly. More... | |
class | ExceptionSpecAnalyzer |
This class analysis if a FunctionDecl has been declared implicitly through defaulting or explicitly as throwing or not and evaluates noexcept expressions if needed. More... | |
class | ExprSequence |
Provides information about the evaluation order of (sub-)expressions within a CFGBlock . More... | |
class | FormatStringConverter |
Convert a printf-style format string to a std::formatter-style one, and prepare any casts that are required to wrap the arguments to retain printf compatibility. More... | |
class | HeaderGuardCheck |
Finds and fixes header guards. More... | |
class | IncludeInserter |
Produces fixes to insert specified includes to source files, if not yet present. More... | |
class | IncludeInserterCallback |
class | IncludeSorter |
Class used by IncludeInserterCallback to record the names of the inclusions in a given source file being processed and generate the necessary commands to sort the inclusions according to the precedence encoded in IncludeKinds . More... | |
class | NamespaceAliaser |
class | StmtToBlockMap |
Maps Stmt s to the CFGBlock that contains them. More... | |
class | TransformerClangTidyCheck |
A base class for defining a ClangTidy check based on a RewriteRule . More... | |
class | UseRangesCheck |
Base class for handling converting std iterator algorithms to a range equivalent. More... | |
class | UsingInserter |
Functions | |
static bool | isAccessForVar (const Stmt *S, const VarDecl *Var) |
Return whether S is a reference to the declaration of Var . | |
static bool | capturesByRef (const CXXRecordDecl *RD, const VarDecl *Var) |
static bool | isPtrOrReferenceForVar (const Stmt *S, const VarDecl *Var) |
Return whether Var has a pointer or reference in S . | |
static bool | hasPtrOrReferenceInStmt (const Stmt *S, const VarDecl *Var) |
Return whether Var has a pointer or reference in S . | |
static bool | refersToEnclosingLambdaCaptureByRef (const Decl *Func, const VarDecl *Var) |
bool | hasPtrOrReferenceInFunc (const Decl *Func, const VarDecl *Var) |
Returns whether Var has a pointer or reference in Func . | |
const FunctionDecl * | getSurroundingFunction (ASTContext &Context, const Stmt &Statement) |
bool | isBinaryOrTernary (const Expr *E) |
bool | exprHasBitFlagWithSpelling (const Expr *Flags, const SourceManager &SM, const LangOptions &LangOpts, StringRef FlagName) |
Checks whether a macro flag is present in the given argument. | |
bool | rangeIsEntirelyWithinMacroArgument (SourceRange Range, const SourceManager *SM) |
bool | rangeContainsMacroExpansion (SourceRange Range, const SourceManager *SM) |
bool | rangeCanBeFixed (SourceRange Range, const SourceManager *SM) |
bool | areStatementsIdentical (const Stmt *FirstStmt, const Stmt *SecondStmt, const ASTContext &Context, bool Canonical) |
const IndirectFieldDecl * | findOutermostIndirectFieldDeclForField (const FieldDecl *FD) |
static tok::TokenKind | getTokenKind (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
static SourceLocation | findEndLocation (const Stmt &S, const SourceManager &SM, const LangOptions &LangOpts) |
BraceInsertionHints | getBraceInsertionsHints (const Stmt *const S, const LangOptions &LangOpts, const SourceManager &SM, SourceLocation StartLoc, SourceLocation EndLocHint=SourceLocation()) |
Create fix-it hints for braces that wrap the given statement when applied. | |
llvm::DenseMap< SourceLocation, std::string > | getUnwrittenDesignators (const InitListExpr *Syn) |
llvm::DenseMap< clang::SourceLocation, std::string > | getUnwrittenDesignators (const clang::InitListExpr *Syn) |
Get designators describing the elements of a (syntactic) init list. | |
static bool | canThrow (const FunctionDecl *Func) |
static SmallVector< const Stmt *, 1 > | getParentStmts (const Stmt *S, ASTContext *Context) |
bool | isExpansionLocInHeaderFile (SourceLocation Loc, const SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions) |
Checks whether expansion location of Loc is in header file. | |
bool | isPresumedLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions) |
Checks whether presumed location of Loc is in header file. | |
bool | isSpellingLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions) |
Checks whether spelling location of Loc is in header file. | |
bool | parseFileExtensions (StringRef AllFileExtensions, FileExtensionsSet &FileExtensions, StringRef Delimiters) |
Parses header file extensions from a semicolon-separated list. | |
std::optional< StringRef > | getFileExtension (StringRef FileName, const FileExtensionsSet &FileExtensions) |
Decides whether a file has a header file extension. | |
bool | isFileExtension (StringRef FileName, const FileExtensionsSet &FileExtensions) |
Decides whether a file has one of the specified file extensions. | |
StringRef | defaultHeaderFileExtensions () |
Returns recommended default value for the list of header file extensions. | |
StringRef | defaultImplementationFileExtensions () |
Returns recommended default value for the list of implementation file extensions. | |
StringRef | defaultFileExtensionDelimiters () |
Returns recommended default value for the list of file extension delimiters. | |
static bool | isRealCharType (const clang::QualType &Ty) |
Is the passed type the actual "char" type, whether that be signed or unsigned, rather than explicit signed char or unsigned char types. | |
static std::optional< std::string > | getCorrespondingSignedTypeName (const clang::QualType &QT) |
If possible, return the text name of the signed type that corresponds to the passed integer type. | |
static std::optional< std::string > | getCorrespondingUnsignedTypeName (const clang::QualType &QT) |
If possible, return the text name of the unsigned type that corresponds to the passed integer type. | |
static std::optional< std::string > | castTypeForArgument (ConversionSpecifier::Kind ArgKind, const clang::QualType &QT) |
static bool | isMatchingSignedness (ConversionSpecifier::Kind ArgKind, const clang::QualType &ArgType) |
static bool | castMismatchedIntegerTypes (const CallExpr *Call, bool StrictMode) |
static std::string | withoutCStrReplacement (const BoundNodes &CStrRemovalMatch, ASTContext &Context) |
static std::string | cleanPath (StringRef Path) |
canonicalize a path by removing ./ and ../ components. | |
AST_MATCHER_P (NamespaceAliasDecl, hasTargetNamespace, ast_matchers::internal::Matcher< NamespaceDecl >, innerMatcher) | |
static bool | hasGenerator (const transformer::Generator< std::string > &G) |
static void | verifyRule (const RewriteRuleWith< std::string > &Rule) |
std::string | escapeForDiagnostic (std::string ToEscape) |
static std::string | getFullPrefix (ArrayRef< UseRangesCheck::Indexes > Signature) |
static auto | makeExprMatcher (ast_matchers::internal::Matcher< Expr > ArgumentMatcher, ArrayRef< StringRef > MethodNames, ArrayRef< StringRef > FreeNames) |
static ast_matchers::internal::Matcher< CallExpr > | makeMatcherPair (StringRef State, const UseRangesCheck::Indexes &Indexes, ArrayRef< StringRef > BeginFreeNames, ArrayRef< StringRef > EndFreeNames, const std::optional< UseRangesCheck::ReverseIteratorDescriptor > &ReverseDescriptor) |
static void | removeFunctionArgs (DiagnosticBuilder &Diag, const CallExpr &Call, ArrayRef< unsigned > Indexes, const ASTContext &Ctx) |
static StringRef | getUnqualifiedName (StringRef QualifiedName) |
bool clang::tidy::utils::areStatementsIdentical | ( | const Stmt * | FirstStmt, |
const Stmt * | SecondStmt, | ||
const ASTContext & | Context, | ||
bool | Canonical | ||
) |
Definition at line 91 of file ASTUtils.cpp.
Referenced by clang::tidy::modernize::areSameExpr(), areSwitchBranchesIdentical(), clang::tidy::bugprone::BranchCloneCheck::check(), clang::tidy::modernize::generateReplacements(), clang::tidy::readability::maxCondition(), clang::tidy::readability::minCondition(), and clang::tidy::matchers::NotIdenticalStatementsPredicate::operator()().
clang::tidy::utils::AST_MATCHER_P | ( | NamespaceAliasDecl | , |
hasTargetNamespace | , | ||
ast_matchers::internal::Matcher< NamespaceDecl > | , | ||
innerMatcher | |||
) |
Definition at line 23 of file NamespaceAliaser.cpp.
|
static |
Definition at line 322 of file ExceptionAnalyzer.cpp.
|
static |
Definition at line 24 of file Aliasing.cpp.
References C.
Referenced by isPtrOrReferenceForVar(), and refersToEnclosingLambdaCaptureByRef().
|
static |
For printf-style functions, the signedness of the type printed is indicated by the corresponding type in the format string. std::print will determine the signedness from the type of the argument. This means that it is necessary to generate a cast in StrictMode to ensure that the exact behaviour is maintained. However, for templated functions like absl::PrintF and fmt::printf, the signedness of the type printed is also taken from the actual argument like std::print, so such casts are never necessary. printf-style functions are variadic, whereas templated ones aren't, so we can use that to distinguish between the two cases.
Definition at line 178 of file FormatStringConverter.cpp.
References FuncDecl.
|
static |
Definition at line 149 of file FormatStringConverter.cpp.
References getCorrespondingSignedTypeName(), and getCorrespondingUnsignedTypeName().
|
static |
canonicalize a path by removing ./ and ../ components.
Definition at line 19 of file HeaderGuard.cpp.
References Path.
|
inline |
Returns recommended default value for the list of file extension delimiters.
Definition at line 45 of file FileExtensionsUtils.h.
|
inline |
Returns recommended default value for the list of header file extensions.
Definition at line 35 of file FileExtensionsUtils.h.
|
inline |
Returns recommended default value for the list of implementation file extensions.
Definition at line 39 of file FileExtensionsUtils.h.
std::string clang::tidy::utils::escapeForDiagnostic | ( | std::string | ToEscape | ) |
Definition at line 33 of file TransformerClangTidyCheck.cpp.
Referenced by clang::tidy::utils::TransformerClangTidyCheck::check().
bool clang::tidy::utils::exprHasBitFlagWithSpelling | ( | const Expr * | Flags, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts, | ||
StringRef | FlagName | ||
) |
Checks whether a macro flag is present in the given argument.
Only considers cases of single match or match in a binary OR expression. For example, <needed-flag> or <flag> | <needed-flag> | ...
Definition at line 38 of file ASTUtils.cpp.
References exprHasBitFlagWithSpelling(), Flags, and MacroName.
Referenced by exprHasBitFlagWithSpelling(), and clang::tidy::android::CloexecCheck::insertMacroFlag().
|
static |
Definition at line 61 of file BracesAroundStatement.cpp.
References getTokenKind(), clang::tidy::utils::lexer::getUnifiedEndLoc(), and Loc.
Referenced by getBraceInsertionsHints().
const IndirectFieldDecl * clang::tidy::utils::findOutermostIndirectFieldDeclForField | ( | const FieldDecl * | FD | ) |
Definition at line 117 of file ASTUtils.cpp.
BraceInsertionHints clang::tidy::utils::getBraceInsertionsHints | ( | const Stmt *const | S, |
const LangOptions & | LangOpts, | ||
const SourceManager & | SM, | ||
SourceLocation | StartLoc, | ||
SourceLocation | EndLocHint = SourceLocation() |
||
) |
Create fix-it hints for braces that wrap the given statement when applied.
The algorithm computing them respects comment before and after the statement and adds line breaks before the braces accordingly.
Definition at line 102 of file BracesAroundStatement.cpp.
References findEndLocation(), and getTokenKind().
Referenced by clang::tidy::readability::AvoidReturnWithVoidValueCheck::check().
|
static |
If possible, return the text name of the signed type that corresponds to the passed integer type.
If the passed type is already signed then its name is just returned. Only supports BuiltinTypes.
Definition at line 46 of file FormatStringConverter.cpp.
Referenced by castTypeForArgument().
|
static |
If possible, return the text name of the unsigned type that corresponds to the passed integer type.
If the passed type is already unsigned then its name is just returned. Only supports BuiltinTypes.
Definition at line 98 of file FormatStringConverter.cpp.
Referenced by castTypeForArgument().
std::optional< StringRef > clang::tidy::utils::getFileExtension | ( | StringRef | FileName, |
const FileExtensionsSet & | FileExtensions | ||
) |
Decides whether a file has a header file extension.
Returns the file extension, if included in the provided set.
Definition at line 56 of file FileExtensionsUtils.cpp.
References FileName.
Referenced by isFileExtension().
|
static |
Definition at line 42 of file utils/UseRangesCheck.cpp.
References OS, Output, and Signature.
Referenced by clang::tidy::utils::UseRangesCheck::check(), and clang::tidy::utils::UseRangesCheck::registerMatchers().
|
static |
Definition at line 28 of file ExprSequence.cpp.
References Node.
Referenced by clang::tidy::utils::StmtToBlockMap::blockContainingStmt(), and clang::tidy::utils::ExprSequence::inSequence().
const FunctionDecl * clang::tidy::utils::getSurroundingFunction | ( | ASTContext & | Context, |
const Stmt & | Statement | ||
) |
|
static |
Definition at line 48 of file BracesAroundStatement.cpp.
References Loc.
Referenced by findEndLocation(), and getBraceInsertionsHints().
|
static |
Definition at line 21 of file UsingInserter.cpp.
Referenced by clang::tidy::utils::UsingInserter::createUsingDeclaration(), and clang::tidy::utils::UsingInserter::getShortName().
llvm::DenseMap< clang::SourceLocation, std::string > clang::tidy::utils::getUnwrittenDesignators | ( | const clang::InitListExpr * | Syn | ) |
Get designators describing the elements of a (syntactic) init list.
Given for example the type
and the definition
calling getUnwrittenDesignators
for the initializer list expression {1, 2}
would produce the map {loc(1): ".i", loc(2): ".j"}
.
It does not produce designators for any explicitly-written nested lists, e.g. {1, .j=2}
would only return {loc(1): ".i"}
.
It also considers structs with fields of record types like struct T { S s; };
. In this case, there would be designators of the form .s.i
and .s.j
in the returned map.
llvm::DenseMap< SourceLocation, std::string > clang::tidy::utils::getUnwrittenDesignators | ( | const InitListExpr * | Syn | ) |
Definition at line 175 of file DesignatedInitializers.cpp.
|
static |
Definition at line 19 of file TransformerClangTidyCheck.cpp.
Referenced by verifyRule().
bool clang::tidy::utils::hasPtrOrReferenceInFunc | ( | const Decl * | Func, |
const VarDecl * | Var | ||
) |
Returns whether Var
has a pointer or reference in Func
.
Example: void f() { int n; ... int *p = &n; }
For f()
and n
the function returns true
because p
is a pointer to n
created in f()
.
Definition at line 92 of file Aliasing.cpp.
References hasPtrOrReferenceInFunc(), hasPtrOrReferenceInStmt(), and refersToEnclosingLambdaCaptureByRef().
Referenced by hasPtrOrReferenceInFunc().
|
static |
Return whether Var
has a pointer or reference in S
.
Definition at line 64 of file Aliasing.cpp.
References hasPtrOrReferenceInStmt(), and isPtrOrReferenceForVar().
Referenced by hasPtrOrReferenceInFunc(), and hasPtrOrReferenceInStmt().
|
static |
Return whether S
is a reference to the declaration of Var
.
Definition at line 17 of file Aliasing.cpp.
Referenced by isPtrOrReferenceForVar().
bool clang::tidy::utils::isBinaryOrTernary | ( | const Expr * | E | ) |
Definition at line 25 of file ASTUtils.cpp.
References E, and isBinaryOrTernary().
Referenced by isBinaryOrTernary().
bool clang::tidy::utils::isExpansionLocInHeaderFile | ( | SourceLocation | Loc, |
const SourceManager & | SM, | ||
const FileExtensionsSet & | HeaderFileExtensions | ||
) |
Checks whether expansion location of Loc
is in header file.
Definition at line 16 of file FileExtensionsUtils.cpp.
References isFileExtension(), and Loc.
bool clang::tidy::utils::isFileExtension | ( | StringRef | FileName, |
const FileExtensionsSet & | FileExtensions | ||
) |
Decides whether a file has one of the specified file extensions.
Definition at line 66 of file FileExtensionsUtils.cpp.
References FileName, and getFileExtension().
Referenced by clang::tidy::misc::UnusedUsingDeclsCheck::check(), isExpansionLocInHeaderFile(), isPresumedLocInHeaderFile(), isSpellingLocInHeaderFile(), clang::tidy::utils::HeaderGuardCheck::shouldSuggestEndifComment(), and clang::tidy::utils::HeaderGuardCheck::shouldSuggestToAddHeaderGuard().
|
static |
Definition at line 156 of file FormatStringConverter.cpp.
bool clang::tidy::utils::isPresumedLocInHeaderFile | ( | SourceLocation | Loc, |
SourceManager & | SM, | ||
const FileExtensionsSet & | HeaderFileExtensions | ||
) |
Checks whether presumed location of Loc
is in header file.
Definition at line 22 of file FileExtensionsUtils.cpp.
References isFileExtension(), and Loc.
Referenced by clang::tidy::bugprone::DynamicStaticInitializersCheck::check(), and clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::check().
|
static |
Return whether Var
has a pointer or reference in S
.
Definition at line 32 of file Aliasing.cpp.
References capturesByRef(), Decl, and isAccessForVar().
Referenced by hasPtrOrReferenceInStmt().
|
static |
Is the passed type the actual "char" type, whether that be signed or unsigned, rather than explicit signed char or unsigned char types.
Definition at line 33 of file FormatStringConverter.cpp.
References Type.
bool clang::tidy::utils::isSpellingLocInHeaderFile | ( | SourceLocation | Loc, |
SourceManager & | SM, | ||
const FileExtensionsSet & | HeaderFileExtensions | ||
) |
Checks whether spelling location of Loc
is in header file.
Definition at line 28 of file FileExtensionsUtils.cpp.
References isFileExtension(), and Loc.
Referenced by clang::tidy::google::readability::GlobalNamesInHeadersCheck::check(), and clang::tidy::llvm_libc::InlineFunctionDeclCheck::check().
|
static |
Definition at line 59 of file utils/UseRangesCheck.cpp.
Referenced by makeMatcherPair().
|
static |
Definition at line 71 of file utils/UseRangesCheck.cpp.
References ArgName, clang::tidy::utils::UseRangesCheck::Indexes::BeginArg, BoundCall, clang::tidy::utils::UseRangesCheck::Indexes::EndArg, ID, and makeExprMatcher().
Referenced by clang::tidy::utils::UseRangesCheck::registerMatchers().
bool clang::tidy::utils::parseFileExtensions | ( | StringRef | AllFileExtensions, |
FileExtensionsSet & | FileExtensions, | ||
StringRef | Delimiters | ||
) |
Parses header file extensions from a semicolon-separated list.
Definition at line 34 of file FileExtensionsUtils.cpp.
bool clang::tidy::utils::rangeCanBeFixed | ( | SourceRange | Range, |
const SourceManager * | SM | ||
) |
Definition at line 86 of file ASTUtils.cpp.
References Range, rangeContainsMacroExpansion(), and rangeIsEntirelyWithinMacroArgument().
Referenced by clang::tidy::bugprone::SmartPtrArrayMismatchCheck::check().
bool clang::tidy::utils::rangeContainsMacroExpansion | ( | SourceRange | Range, |
const SourceManager * | SM | ||
) |
Definition at line 81 of file ASTUtils.cpp.
References Range, and rangeIsEntirelyWithinMacroArgument().
Referenced by rangeCanBeFixed().
bool clang::tidy::utils::rangeIsEntirelyWithinMacroArgument | ( | SourceRange | Range, |
const SourceManager * | SM | ||
) |
Definition at line 65 of file ASTUtils.cpp.
References Range.
Referenced by rangeCanBeFixed(), and rangeContainsMacroExpansion().
|
static |
Definition at line 79 of file Aliasing.cpp.
References capturesByRef().
Referenced by hasPtrOrReferenceInFunc().
|
static |
Definition at line 164 of file utils/UseRangesCheck.cpp.
Referenced by clang::tidy::utils::UseRangesCheck::check().
|
static |
Definition at line 24 of file TransformerClangTidyCheck.cpp.
References hasGenerator().
Referenced by clang::tidy::utils::TransformerClangTidyCheck::setRule().
|
static |
Definition at line 684 of file FormatStringConverter.cpp.
References clang::tidy::utils::fixit::formatDereference().
Referenced by clang::tidy::utils::FormatStringConverter::applyFixes().