clang-tools
4.0.0
|
Classes | |
class | AvoidBindCheck |
Replace simple uses of std::bind with a lambda. More... | |
class | DeprecatedHeadersCheck |
This check replaces deprecated C library headers with their C++ STL alternatives. More... | |
class | LoopConvertCheck |
class | StmtAncestorASTVisitor |
Class used build the reverse AST properties needed to detect name conflicts and free variables. More... | |
class | ComponentFinderASTVisitor |
Class used to find the variables and member expressions on which an arbitrary expression depends. More... | |
class | DependencyFinderASTVisitor |
Class used to determine if an expression is dependent on a variable declared inside of the loop where it would be used. More... | |
class | DeclFinderASTVisitor |
Class used to determine if any declarations used in a Stmt would conflict with a particular identifier. More... | |
struct | Usage |
The information needed to describe a valid convertible usage of an array index or iterator. More... | |
class | Confidence |
A class to encapsulate lowering of the tool's confidence level. More... | |
class | ForLoopIndexUseVisitor |
Discover usages of expressions consisting of index or iterator access. More... | |
struct | TUTrackingInfo |
class | VariableNamer |
Create names for generated variables within a particular statement. More... | |
class | MakeSharedCheck |
Replace the pattern: More... | |
class | MakeSmartPtrCheck |
Base class for MakeSharedCheck and MakeUniqueCheck. More... | |
class | MakeUniqueCheck |
Replace the pattern: More... | |
class | ModernizeModule |
class | PassByValueCheck |
class | RawStringLiteralCheck |
This check replaces string literals with escaped characters to raw string literals. More... | |
class | RedundantVoidArgCheck |
Find and remove redundant void argument lists. More... | |
class | ReplaceAutoPtrCheck |
Transforms the deprecated std::auto_ptr into the C++11 std::unique_ptr . More... | |
class | ShrinkToFitCheck |
Replace copy and swap tricks on shrinkable containers with the shrink_to_fit() method call. More... | |
class | UseAutoCheck |
class | UseBoolLiteralsCheck |
Finds integer literals which are cast to bool. More... | |
class | UseDefaultMemberInitCheck |
Convert a default constructor's member initializers into default member initializers. More... | |
class | UseEmplaceCheck |
This check looks for cases when inserting new element into std::vector but the element is constructed temporarily. More... | |
class | UseEqualsDefaultCheck |
Replace default bodies of special member functions with '= default;'. More... | |
class | UseEqualsDeleteCheck |
Mark unimplemented private special member functions with '= delete'. More... | |
class | UseNullptrCheck |
class | UseOverrideCheck |
Use C++11's override and remove virtual where applicable. More... | |
class | UseTransparentFunctorsCheck |
Prefer using transparent functors to non-transparent ones. More... | |
class | UseUsingCheck |
Check finds typedefs and replaces it with usings. More... | |
Typedefs | |
typedef llvm::DenseMap< const clang::Stmt *, const clang::Stmt * > | StmtParentMap |
A map used to walk the AST in reverse: maps child Stmt to parent Stmt. More... | |
typedef llvm::DenseMap< const clang::VarDecl *, const clang::DeclStmt * > | DeclParentMap |
A map used to walk the AST in reverse: maps VarDecl to the to parent DeclStmt. More... | |
typedef llvm::DenseMap< const clang::ForStmt *, const clang::VarDecl * > | ReplacedVarsMap |
A map used to track which variables have been removed by a refactoring pass. More... | |
typedef llvm::DenseMap< const clang::Stmt *, std::string > | StmtGeneratedVarNameMap |
A map used to remember the variable names generated in a Stmt. More... | |
typedef llvm::SmallVector < const clang::Expr *, 16 > | ComponentVector |
A vector used to store the AST subtrees of an Expr. More... | |
typedef llvm::SmallVector < Usage, 8 > | UsageResult |
Enumerations | |
enum | LoopFixerKind { LFK_Array, LFK_Iterator, LFK_PseudoArray } |
Functions | |
static SmallVector < BindArgument, 4 > | buildBindArguments (const MatchFinder::MatchResult &Result, const CallExpr *C) |
static void | addPlaceholderArgs (const ArrayRef< BindArgument > Args, llvm::raw_ostream &Stream) |
static void | addFunctionCallArgs (const ArrayRef< BindArgument > Args, llvm::raw_ostream &Stream) |
static bool | isPlaceHolderIndexRepeated (const ArrayRef< BindArgument > Args) |
StatementMatcher | makeArrayLoopMatcher () |
The matcher for loops over arrays. More... | |
StatementMatcher | makeIteratorLoopMatcher () |
The matcher used for iterator-based for loops. More... | |
StatementMatcher | makePseudoArrayLoopMatcher () |
The matcher used for array-like containers (pseudoarrays). More... | |
static const Expr * | getContainerFromBeginEndCall (const Expr *Init, bool IsBegin, bool *IsArrow) |
Determine whether Init appears to be an initializing an iterator. More... | |
static const Expr * | findContainer (ASTContext *Context, const Expr *BeginExpr, const Expr *EndExpr, bool *ContainerNeedsDereference) |
Determines the container whose begin() and end() functions are called for an iterator-based loop. More... | |
static StringRef | getStringFromRange (SourceManager &SourceMgr, const LangOptions &LangOpts, SourceRange Range) |
Obtain the original source code text from a SourceRange. More... | |
static const ValueDecl * | getReferencedVariable (const Expr *E) |
If the given expression is actually a DeclRefExpr or a MemberExpr, find and return the underlying ValueDecl; otherwise, return NULL. More... | |
static bool | isDirectMemberExpr (const Expr *E) |
Returns true when the given expression is a member expression whose base is this (implicitly or not). More... | |
static bool | canBeModified (ASTContext *Context, const Expr *E) |
Given an expression that represents an usage of an element from the containter that we are iterating over, returns false when it can be guaranteed this element cannot be modified as a result of this usage. More... | |
static bool | usagesAreConst (ASTContext *Context, const UsageResult &Usages) |
Returns true when it can be guaranteed that the elements of the container are not being modified. More... | |
static bool | usagesReturnRValues (const UsageResult &Usages) |
Returns true if the elements of the container are never accessed by reference. More... | |
static bool | containerIsConst (const Expr *ContainerExpr, bool Dereference) |
Returns true if the container is const-qualified. More... | |
const Expr * | digThroughConstructors (const Expr *E) |
Look through conversion/copy constructors to find the explicit initialization expression, returning it is found. More... | |
bool | areSameExpr (ASTContext *Context, const Expr *First, const Expr *Second) |
Returns true when two Exprs are equivalent. More... | |
const DeclRefExpr * | getDeclRef (const Expr *E) |
Returns the DeclRefExpr represented by E, or NULL if there isn't one. More... | |
bool | areSameVariable (const ValueDecl *First, const ValueDecl *Second) |
Returns true when two ValueDecls are the same variable. More... | |
static bool | exprReferencesVariable (const ValueDecl *Target, const Expr *E) |
Determines if an expression is a declaration reference to a particular variable. More... | |
static const Expr * | getDereferenceOperand (const Expr *E) |
If the expression is a dereference or call to operator*(), return the operand. More... | |
template<typename ContainerT > | |
static bool | containsExpr (ASTContext *Context, const ContainerT *Container, const Expr *E) |
Returns true when the Container contains an Expr equivalent to E. More... | |
static bool | isIndexInSubscriptExpr (const Expr *IndexExpr, const VarDecl *IndexVar) |
Returns true when the index expression is a declaration reference to IndexVar. More... | |
static bool | isIndexInSubscriptExpr (ASTContext *Context, const Expr *IndexExpr, const VarDecl *IndexVar, const Expr *Obj, const Expr *SourceExpr, bool PermitDeref) |
Returns true when the index expression is a declaration reference to IndexVar, Obj is the same expression as SourceExpr after all parens and implicit casts are stripped off. More... | |
static bool | isDereferenceOfOpCall (const CXXOperatorCallExpr *OpCall, const VarDecl *IndexVar) |
Returns true when Opcall is a call a one-parameter dereference of IndexVar. More... | |
static bool | isDereferenceOfUop (const UnaryOperator *Uop, const VarDecl *IndexVar) |
Returns true when Uop is a dereference of IndexVar. More... | |
static bool | isAliasDecl (ASTContext *Context, const Decl *TheDecl, const VarDecl *IndexVar) |
Determines whether the given Decl defines a variable initialized to the loop object. More... | |
static bool | arrayMatchesBoundExpr (ASTContext *Context, const QualType &ArrayType, const Expr *ConditionExpr) |
Determines whether the bound of a for loop condition expression is the same as the statically computable size of ArrayType. More... | |
static ClangTidyModuleRegistry::Add < ModernizeModule > | X ("modernize-module","Add modernize checks.") |
AST_MATCHER (CXXRecordDecl, isMoveConstructible) | |
Matches move-constructible classes. More... | |
static TypeMatcher | constRefType () |
static TypeMatcher | nonConstValueType () |
static bool | paramReferredExactlyOnce (const CXXConstructorDecl *Ctor, const ParmVarDecl *ParamDecl) |
Whether or not ParamDecl is used exactly one time in Ctor . More... | |
static SmallVector< const ParmVarDecl *, 2 > | collectParamDecls (const CXXConstructorDecl *Ctor, const ParmVarDecl *ParamDecl) |
Find all references to ParamDecl across all of the redeclarations of Ctor . More... | |
AST_MATCHER (Expr, isLValue) | |
Matches expressions that are lvalues. More... | |
TypeLocMatcher | makeAutoPtrTypeLocMatcher () |
Matches declarations whose declaration context is the C++ standard library namespace std. More... | |
DeclarationMatcher | makeAutoPtrUsingDeclMatcher () |
Creates a matcher that finds the using declarations referring to std::auto_ptr . More... | |
StatementMatcher | makeTransferOwnershipExprMatcher () |
Creates a matcher that finds the std::auto_ptr copy-ctor and assign-operator expressions. More... | |
static SourceLocation | locateFromTypeLoc (const TypeLoc *AutoPtrTypeLoc, const SourceManager &SM) |
Locates the auto_ptr token when it is referred by a TypeLoc . More... | |
static SourceLocation | locateFromUsingDecl (const UsingDecl *UsingAutoPtrDecl, const SourceManager &SM) |
Locates the auto_ptr token in using declarations. More... | |
static bool | checkTokenIsAutoPtr (SourceLocation TokenStart, const SourceManager &SM, const LangOptions &LO) |
Verifies that the token at TokenStart is 'auto_ptr'. More... | |
static StringRef | getValueOfValueInit (const QualType InitType) |
static bool | isZero (const Expr *E) |
static const Expr * | ignoreUnaryPlus (const Expr *E) |
static const Expr * | getInitializer (const Expr *E) |
static bool | sameValue (const Expr *E1, const Expr *E2) |
static std::set< const FieldDecl * > | getAllNamedFields (const CXXRecordDecl *Record) |
Finds all the named non-static fields of Record . More... | |
static std::set< const Type * > | getAllDirectBases (const CXXRecordDecl *Record) |
Returns the names of the direct bases of Record , both virtual and non-virtual. More... | |
internal::Matcher< Expr > | accessToFieldInVar (const FieldDecl *Field, const ValueDecl *Var) |
Returns a matcher that matches member expressions where the base is the variable declared as Var and the accessed member is the one declared as Field . More... | |
static bool | isCopyConstructorAndCanBeDefaulted (ASTContext *Context, const CXXConstructorDecl *Ctor) |
Check that the given constructor has copy signature and that it copy-initializes all its bases and members. More... | |
static bool | isCopyAssignmentAndCanBeDefaulted (ASTContext *Context, const CXXMethodDecl *Operator) |
Checks that the given method is an overloading of the assignment operator, has copy signature, returns a reference to "*this" and copies all its members and subobjects. More... | |
static bool | bodyEmpty (const ASTContext *Context, const CompoundStmt *Body) |
Returns false if the body has any non-whitespace character. More... | |
static SmallVector< Token, 16 > | ParseTokens (CharSourceRange Range, const MatchFinder::MatchResult &Result) |
static StringRef | GetText (const Token &Tok, const SourceManager &Sources) |
template<typename T > | |
static T | getInnerTypeLocAs (TypeLoc Loc) |
static bool | CheckRemoval (SourceManager &SM, const SourceLocation &LocStart, const SourceLocation &LocEnd, ASTContext &Context, SourceRange &ResultRange) |
Variables | |
static const char | LoopNameArray [] = "forLoopArray" |
static const char | LoopNameIterator [] = "forLoopIterator" |
static const char | LoopNamePseudoArray [] = "forLoopPseudoArray" |
static const char | ConditionBoundName [] = "conditionBound" |
static const char | ConditionVarName [] = "conditionVar" |
static const char | IncrementVarName [] = "incrementVar" |
static const char | InitVarName [] = "initVar" |
static const char | BeginCallName [] = "beginCall" |
static const char | EndCallName [] = "endCall" |
static const char | ConditionEndVarName [] = "conditionEndVar" |
static const char | EndVarName [] = "endVar" |
static const char | DerefByValueResultName [] = "derefByValueResult" |
static const char | DerefByRefResultName [] = "derefByRefResult" |
static const TypeMatcher | AnyType = anything() |
static const StatementMatcher | IntegerComparisonMatcher |
static const DeclarationMatcher | InitToZeroMatcher |
static const StatementMatcher | IncrementVarMatcher |
static const char | AutoPtrTokenId [] = "AutoPrTokenId" |
static const char | AutoPtrOwnershipTransferId [] = "AutoPtrOwnershipTransferId" |
static const auto | DefaultContainersWithPushBack |
static const auto | DefaultSmartPointers |
static const char | SpecialFunction [] = "SpecialFunction" |
static const char | SpecialFunction [] = "SpecialFunction" |
static const char | DeletedNotPublic [] = "DeletedNotPublic" |
static const StringRef | Message = "prefer transparent functors '%0'" |
typedef llvm::SmallVector<const clang::Expr *, 16> clang::tidy::modernize::ComponentVector |
A vector used to store the AST subtrees of an Expr.
Definition at line 50 of file LoopConvertUtils.h.
typedef llvm::DenseMap<const clang::VarDecl *, const clang::DeclStmt *> clang::tidy::modernize::DeclParentMap |
A map used to walk the AST in reverse: maps VarDecl to the to parent DeclStmt.
Definition at line 38 of file LoopConvertUtils.h.
typedef llvm::DenseMap<const clang::ForStmt *, const clang::VarDecl *> clang::tidy::modernize::ReplacedVarsMap |
A map used to track which variables have been removed by a refactoring pass.
It maps the parent ForStmt to the removed index variable's VarDecl.
Definition at line 43 of file LoopConvertUtils.h.
typedef llvm::DenseMap<const clang::Stmt *, std::string> clang::tidy::modernize::StmtGeneratedVarNameMap |
A map used to remember the variable names generated in a Stmt.
Definition at line 47 of file LoopConvertUtils.h.
typedef llvm::DenseMap<const clang::Stmt *, const clang::Stmt *> clang::tidy::modernize::StmtParentMap |
A map used to walk the AST in reverse: maps child Stmt to parent Stmt.
Definition at line 33 of file LoopConvertUtils.h.
typedef llvm::SmallVector<Usage, 8> clang::tidy::modernize::UsageResult |
Definition at line 271 of file LoopConvertUtils.h.
Enumerator | |
---|---|
LFK_Array | |
LFK_Iterator | |
LFK_PseudoArray |
Definition at line 30 of file LoopConvertUtils.h.
internal::Matcher<Expr> clang::tidy::modernize::accessToFieldInVar | ( | const FieldDecl * | Field, |
const ValueDecl * | Var | ||
) |
Returns a matcher that matches member expressions where the base is the variable declared as Var
and the accessed member is the one declared as Field
.
Definition at line 51 of file UseEqualsDefaultCheck.cpp.
Referenced by isCopyAssignmentAndCanBeDefaulted(), and isCopyConstructorAndCanBeDefaulted().
|
static |
Definition at line 97 of file AvoidBindCheck.cpp.
Referenced by clang::tidy::modernize::AvoidBindCheck::check().
|
static |
Definition at line 75 of file AvoidBindCheck.cpp.
Referenced by clang::tidy::modernize::AvoidBindCheck::check().
bool clang::tidy::modernize::areSameExpr | ( | ASTContext * | Context, |
const Expr * | First, | ||
const Expr * | Second | ||
) |
Returns true when two Exprs are equivalent.
Definition at line 188 of file LoopConvertUtils.cpp.
Referenced by findContainer(), and isIndexInSubscriptExpr().
bool clang::tidy::modernize::areSameVariable | ( | const ValueDecl * | First, |
const ValueDecl * | Second | ||
) |
Returns true when two ValueDecls are the same variable.
Definition at line 204 of file LoopConvertUtils.cpp.
Referenced by exprReferencesVariable(), and isIndexInSubscriptExpr().
|
static |
Determines whether the bound of a for loop condition expression is the same as the statically computable size of ArrayType.
Given
This is intended to permit
Definition at line 433 of file LoopConvertUtils.cpp.
clang::tidy::modernize::AST_MATCHER | ( | Expr | , |
isLValue | |||
) |
Matches expressions that are lvalues.
In the following example, a[0] matches expr(isLValue()):
Definition at line 36 of file ReplaceAutoPtrCheck.cpp.
clang::tidy::modernize::AST_MATCHER | ( | CXXRecordDecl | , |
isMoveConstructible | |||
) |
Matches move-constructible classes.
Given
recordDecl(isMoveConstructible()) matches "Foo".
Definition at line 40 of file PassByValueCheck.cpp.
|
static |
Returns false if the body has any non-whitespace character.
Definition at line 191 of file UseEqualsDefaultCheck.cpp.
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check().
|
static |
Definition at line 48 of file AvoidBindCheck.cpp.
Referenced by clang::tidy::modernize::AvoidBindCheck::check().
|
static |
Given an expression that represents an usage of an element from the containter that we are iterating over, returns false when it can be guaranteed this element cannot be modified as a result of this usage.
Definition at line 387 of file LoopConvertCheck.cpp.
Referenced by usagesAreConst().
|
static |
Definition at line 28 of file UseUsingCheck.cpp.
Referenced by clang::tidy::modernize::UseUsingCheck::check().
|
static |
Verifies that the token at TokenStart
is 'auto_ptr'.
Definition at line 179 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::check().
|
static |
Find all references to ParamDecl
across all of the redeclarations of Ctor
.
Definition at line 109 of file PassByValueCheck.cpp.
Referenced by clang::tidy::modernize::PassByValueCheck::check().
|
static |
Definition at line 48 of file PassByValueCheck.cpp.
Referenced by clang::tidy::modernize::PassByValueCheck::registerMatchers().
|
static |
Returns true if the container is const-qualified.
Definition at line 431 of file LoopConvertCheck.cpp.
References getReferencedVariable().
|
static |
Returns true when the Container contains an Expr equivalent to E.
Definition at line 235 of file LoopConvertUtils.cpp.
const Expr * clang::tidy::modernize::digThroughConstructors | ( | const Expr * | E | ) |
Look through conversion/copy constructors to find the explicit initialization expression, returning it is found.
The main idea is that given vector<int> v; we consider either of these initializations vector<int>::iterator it = v.begin(); vector<int>::iterator it(v.begin()); and retrieve v.begin()
as the expression used to initialize it
but do not include vector<int>::iterator it; vector<int>::iterator it(v.begin(), 0); // if this constructor existed as being initialized from v.begin()
Definition at line 169 of file LoopConvertUtils.cpp.
Referenced by getContainerFromBeginEndCall(), and isAliasDecl().
|
static |
Determines if an expression is a declaration reference to a particular variable.
Definition at line 211 of file LoopConvertUtils.cpp.
References areSameVariable(), and getDeclRef().
Referenced by isDereferenceOfOpCall(), and isDereferenceOfUop().
|
static |
Determines the container whose begin() and end() functions are called for an iterator-based loop.
BeginExpr must be a member call to a function named "begin()", and EndExpr must be a member.
Definition at line 329 of file LoopConvertCheck.cpp.
References areSameExpr(), and getContainerFromBeginEndCall().
Referenced by clang::tidy::modernize::LoopConvertCheck::check().
|
static |
Returns the names of the direct bases of Record
, both virtual and non-virtual.
Definition at line 38 of file UseEqualsDefaultCheck.cpp.
References Result.
Referenced by isCopyAssignmentAndCanBeDefaulted(), and isCopyConstructorAndCanBeDefaulted().
|
static |
Finds all the named non-static fields of Record
.
Definition at line 25 of file UseEqualsDefaultCheck.cpp.
References Result.
Referenced by isCopyAssignmentAndCanBeDefaulted(), and isCopyConstructorAndCanBeDefaulted().
|
static |
Determine whether Init appears to be an initializing an iterator.
If it is, returns the object whose begin() or end() method is called, and the output parameter isArrow is set to indicate whether the initialization is called via . or ->.
Definition at line 299 of file LoopConvertCheck.cpp.
References digThroughConstructors(), and Name.
Referenced by findContainer().
const DeclRefExpr * clang::tidy::modernize::getDeclRef | ( | const Expr * | E | ) |
Returns the DeclRefExpr represented by E, or NULL if there isn't one.
Definition at line 199 of file LoopConvertUtils.cpp.
Referenced by exprReferencesVariable(), getReferencedVariable(), and isIndexInSubscriptExpr().
|
static |
If the expression is a dereference or call to operator*(), return the operand.
Otherwise, return NULL.
Definition at line 220 of file LoopConvertUtils.cpp.
Referenced by isIndexInSubscriptExpr().
|
static |
Definition at line 96 of file UseDefaultMemberInitCheck.cpp.
Referenced by sameValue().
|
static |
Definition at line 73 of file UseTransparentFunctorsCheck.cpp.
References Result.
|
static |
If the given expression is actually a DeclRefExpr or a MemberExpr, find and return the underlying ValueDecl; otherwise, return NULL.
Definition at line 368 of file LoopConvertCheck.cpp.
References getDeclRef().
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and containerIsConst().
|
static |
Obtain the original source code text from a SourceRange.
Definition at line 354 of file LoopConvertCheck.cpp.
|
static |
Definition at line 57 of file UseOverrideCheck.cpp.
Referenced by clang::tidy::modernize::UseOverrideCheck::check().
|
static |
Definition at line 21 of file UseDefaultMemberInitCheck.cpp.
|
static |
Definition at line 89 of file UseDefaultMemberInitCheck.cpp.
Referenced by sameValue().
|
static |
Determines whether the given Decl defines a variable initialized to the loop object.
This is intended to find cases such as
and
Definition at line 350 of file LoopConvertUtils.cpp.
References digThroughConstructors(), isDereferenceOfOpCall(), isDereferenceOfUop(), and isIndexInSubscriptExpr().
|
static |
Checks that the given method is an overloading of the assignment operator, has copy signature, returns a reference to "*this" and copies all its members and subobjects.
Definition at line 117 of file UseEqualsDefaultCheck.cpp.
References accessToFieldInVar(), Context, getAllDirectBases(), and getAllNamedFields().
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check().
|
static |
Check that the given constructor has copy signature and that it copy-initializes all its bases and members.
Definition at line 60 of file UseEqualsDefaultCheck.cpp.
References accessToFieldInVar(), getAllDirectBases(), and getAllNamedFields().
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check().
|
static |
Returns true when Opcall is a call a one-parameter dereference of IndexVar.
For example, if the index variable is index
, returns true for *index but not index *notIndex
Definition at line 314 of file LoopConvertUtils.cpp.
References exprReferencesVariable().
Referenced by isAliasDecl().
|
static |
Returns true when Uop is a dereference of IndexVar.
For example, if the index variable is index
, returns true for *index but not index *notIndex
Definition at line 327 of file LoopConvertUtils.cpp.
References exprReferencesVariable().
Referenced by isAliasDecl().
|
static |
Returns true when the given expression is a member expression whose base is this
(implicitly or not).
Definition at line 378 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check().
|
static |
Returns true when the index expression is a declaration reference to IndexVar.
If the index variable is index
, this function returns true on arrayExpression[index]; containerExpression[index]; but not containerExpression[notIndex];
Definition at line 254 of file LoopConvertUtils.cpp.
References areSameVariable(), and getDeclRef().
|
static |
Returns true when the index expression is a declaration reference to IndexVar, Obj is the same expression as SourceExpr after all parens and implicit casts are stripped off.
If PermitDeref is true, IndexExpression may be a dereference (overloaded or builtin operator*).
This function is intended for array-like containers, as it makes sure that both the container and the index match. If the loop has index variable index
and iterates over container
, then isIndexInSubscriptExpr returns true for
but not for
If PermitDeref is true, then isIndexInSubscriptExpr additionally returns true on these expressions:
Definition at line 288 of file LoopConvertUtils.cpp.
References areSameExpr(), and getDereferenceOperand().
Referenced by isAliasDecl().
|
static |
Definition at line 109 of file AvoidBindCheck.cpp.
Referenced by clang::tidy::modernize::AvoidBindCheck::check().
|
static |
Definition at line 67 of file UseDefaultMemberInitCheck.cpp.
Referenced by sameValue().
|
static |
Locates the auto_ptr
token when it is referred by a TypeLoc
.
The caret represents the location returned and the tildes cover the parameter AutoPtrTypeLoc
.
SourceLocation
if not found, otherwise the location of the beginning of the auto_ptr
token. Definition at line 153 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::check().
|
static |
Locates the auto_ptr
token in using declarations.
The caret represents the location returned.
SourceLocation
if not found, otherwise the location of the beginning of the auto_ptr
token. Definition at line 173 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::check().
StatementMatcher clang::tidy::modernize::makeArrayLoopMatcher | ( | ) |
The matcher for loops over arrays.
In this general example, assuming 'j' and 'k' are of integral type:
The following string identifiers are bound to these parts of the AST: ConditionVarName: 'j' (as a VarDecl) ConditionBoundName: '3 + 2' (as an Expr) InitVarName: 'i' (as a VarDecl) IncrementVarName: 'k' (as a VarDecl) LoopName: The entire for loop (as a ForStmt)
Client code will need to make sure that:
Definition at line 79 of file LoopConvertCheck.cpp.
References ConditionBoundName, IncrementVarMatcher, InitToZeroMatcher, IntegerComparisonMatcher, and LoopNameArray.
Referenced by clang::tidy::modernize::LoopConvertCheck::registerMatchers().
TypeLocMatcher clang::tidy::modernize::makeAutoPtrTypeLocMatcher | ( | ) |
Matches declarations whose declaration context is the C++ standard library namespace std.
Note that inline namespaces are silently ignored during the lookup since both libstdc++ and libc++ are known to use them for versioning purposes.
Given:
Definition at line 102 of file ReplaceAutoPtrCheck.cpp.
References AutoPtrTokenId.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::registerMatchers().
DeclarationMatcher clang::tidy::modernize::makeAutoPtrUsingDeclMatcher | ( | ) |
Creates a matcher that finds the using declarations referring to std::auto_ptr
.
Definition at line 115 of file ReplaceAutoPtrCheck.cpp.
References AutoPtrTokenId.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::registerMatchers().
StatementMatcher clang::tidy::modernize::makeIteratorLoopMatcher | ( | ) |
The matcher used for iterator-based for loops.
This matcher is more flexible than array-based loops. It will match catch loops of the following textual forms (regardless of whether the iterator type is actually a pointer type or a class type):
Assuming f, g, and h are of type containerType::iterator,
The following string identifiers are bound to the parts of the AST: InitVarName: 'it' (as a VarDecl) ConditionVarName: 'f' (as a VarDecl) LoopName: The entire for loop (as a ForStmt) In the first example only: EndVarName: 'e' (as a VarDecl) ConditionEndVarName: 'g' (as a VarDecl) In the second example only: EndCallName: 'container.end()' (as a CXXMemberCallExpr)
Client code will need to make sure that:
Definition at line 124 of file LoopConvertCheck.cpp.
References AnyType, BeginCallName, ConditionEndVarName, ConditionVarName, DerefByRefResultName, DerefByValueResultName, EndCallName, EndVarName, IncrementVarName, InitVarName, and LoopNameIterator.
Referenced by clang::tidy::modernize::LoopConvertCheck::registerMatchers().
StatementMatcher clang::tidy::modernize::makePseudoArrayLoopMatcher | ( | ) |
The matcher used for array-like containers (pseudoarrays).
This matcher is more flexible than array-based loops. It will match loops of the following textual forms (regardless of whether the iterator type is actually a pointer type or a class type):
Assuming f, g, and h are of type containerType::iterator,
The following string identifiers are bound to the parts of the AST: InitVarName: 'i' (as a VarDecl) ConditionVarName: 'f' (as a VarDecl) LoopName: The entire for loop (as a ForStmt) In the first example only: EndVarName: 'j' (as a VarDecl) ConditionEndVarName: 'g' (as a VarDecl) In the second example only: EndCallName: 'container.size()' (as a CXXMemberCallExpr)
Client code will need to make sure that:
Definition at line 231 of file LoopConvertCheck.cpp.
References ConditionEndVarName, EndCallName, EndVarName, IncrementVarMatcher, InitToZeroMatcher, IntegerComparisonMatcher, and LoopNamePseudoArray.
Referenced by clang::tidy::modernize::LoopConvertCheck::registerMatchers().
StatementMatcher clang::tidy::modernize::makeTransferOwnershipExprMatcher | ( | ) |
Creates a matcher that finds the std::auto_ptr
copy-ctor and assign-operator expressions.
AutoPtrOwnershipTransferId
is assigned to the argument of the expression, this is the part that has to be wrapped by std::move()
.
Definition at line 132 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::registerMatchers().
|
static |
Definition at line 52 of file PassByValueCheck.cpp.
Referenced by clang::tidy::modernize::PassByValueCheck::registerMatchers().
|
static |
Whether or not ParamDecl
is used exactly one time in Ctor
.
Checks both in the init-list and the body of the constructor.
clang::RecursiveASTVisitor
that checks that the given ParmVarDecl
is used exactly one time.
Whether or not the parameter variable is referred only once in the given constructor.
Counts the number of references to a variable.
Stops the AST traversal if more than one usage is found.
Definition at line 59 of file PassByValueCheck.cpp.
Referenced by clang::tidy::modernize::PassByValueCheck::check().
|
static |
Definition at line 30 of file UseOverrideCheck.cpp.
Referenced by clang::tidy::modernize::UseOverrideCheck::check().
|
static |
Definition at line 103 of file UseDefaultMemberInitCheck.cpp.
References getInitializer(), ignoreUnaryPlus(), and isZero().
|
static |
Returns true when it can be guaranteed that the elements of the container are not being modified.
Definition at line 406 of file LoopConvertCheck.cpp.
References canBeModified().
|
static |
Returns true if the elements of the container are never accessed by reference.
Definition at line 422 of file LoopConvertCheck.cpp.
|
static |
|
static |
Definition at line 48 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 25 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::check().
|
static |
Definition at line 24 of file ReplaceAutoPtrCheck.cpp.
Referenced by clang::tidy::modernize::ReplaceAutoPtrCheck::check(), makeAutoPtrTypeLocMatcher(), and makeAutoPtrUsingDeclMatcher().
|
static |
Definition at line 40 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 36 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and makeArrayLoopMatcher().
|
static |
Definition at line 42 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 37 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 18 of file UseEmplaceCheck.cpp.
|
static |
Definition at line 20 of file UseEmplaceCheck.cpp.
|
static |
Definition at line 22 of file UseEqualsDeleteCheck.cpp.
Referenced by clang::tidy::modernize::UseEqualsDeleteCheck::check(), and clang::tidy::modernize::UseEqualsDeleteCheck::registerMatchers().
|
static |
Definition at line 45 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 44 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 41 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), makeIteratorLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 43 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), makeIteratorLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 58 of file LoopConvertCheck.cpp.
Referenced by makeArrayLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 38 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and makeIteratorLoopMatcher().
|
static |
Definition at line 54 of file LoopConvertCheck.cpp.
Referenced by makeArrayLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 39 of file LoopConvertCheck.cpp.
Referenced by makeIteratorLoopMatcher().
|
static |
Definition at line 50 of file LoopConvertCheck.cpp.
Referenced by makeArrayLoopMatcher(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 33 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and makeArrayLoopMatcher().
|
static |
Definition at line 34 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and makeIteratorLoopMatcher().
|
static |
Definition at line 35 of file LoopConvertCheck.cpp.
Referenced by clang::tidy::modernize::LoopConvertCheck::check(), and makePseudoArrayLoopMatcher().
|
static |
Definition at line 71 of file UseTransparentFunctorsCheck.cpp.
Referenced by clang::tidy::modernize::UseOverrideCheck::check(), clang::tidy::modernize::UseTransparentFunctorsCheck::check(), clang::tidy::readability::DeletedDefaultCheck::check(), clang::tidy::readability::NamespaceCommentCheck::check(), clang::tidy::misc::UnconventionalAssignOperatorCheck::check(), and clang::tidy::ClangTidyDiagnosticConsumer::HandleDiagnostic().
|
static |
Definition at line 21 of file UseEqualsDefaultCheck.cpp.
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check(), and clang::tidy::modernize::UseEqualsDefaultCheck::registerMatchers().
|
static |
Definition at line 21 of file UseEqualsDeleteCheck.cpp.
Referenced by clang::tidy::modernize::UseEqualsDeleteCheck::check(), and clang::tidy::modernize::UseEqualsDeleteCheck::registerMatchers().