clang-tools
8.0.0
|
Classes | |
class | ArgumentCommentCheck |
class | AssertSideEffectCheck |
Finds assert() with side effect. More... | |
class | BoolPointerImplicitConversionCheck |
Checks for conditions based on implicit conversion from a bool pointer to bool. More... | |
class | BugproneModule |
class | CopyConstructorInitCheck |
Finds copy constructors where the ctor don't call the copy constructor of the base class. More... | |
class | DanglingHandleCheck |
Detect dangling references in value handlers like std::experimental::string_view. More... | |
class | ExceptionEscapeCheck |
Finds functions which should not throw exceptions: Destructors, move constructors, move assignment operators, the main() function, swap() functions, functions marked with throw() or noexcept and functions given as option to the checker. More... | |
class | FoldInitTypeCheck |
Find and flag invalid initializer values in folds, e.g. More... | |
class | ForwardDeclarationNamespaceCheck |
Checks if an unused forward declaration is in a wrong namespace. More... | |
class | ForwardingReferenceOverloadCheck |
The checker looks for constructors that can act as copy or move constructors through their forwarding reference parameters. More... | |
class | InaccurateEraseCheck |
Checks for inaccurate use of the erase() method. More... | |
class | IncorrectRoundingsCheck |
Checks the usage of patterns known to produce incorrect rounding. More... | |
class | IntegerDivisionCheck |
Finds cases where integer division in a floating point context is likely to cause unintended loss of precision. More... | |
class | LambdaFunctionNameCheck |
Detect when func or FUNCTION is being used from within a lambda. More... | |
class | MacroParenthesesCheck |
Finds macros that can have unexpected behaviour due to missing parentheses. More... | |
class | MacroRepeatedSideEffectsCheck |
Checks for repeated argument with side effects in macros. More... | |
class | MisplacedOperatorInStrlenInAllocCheck |
Finds cases where 1 is added to the string in the argument to a function in the strlen() family instead of the result and value is used as an argument to a memory allocation function. More... | |
class | MisplacedWideningCastCheck |
Find casts of calculation results to bigger type. More... | |
class | MoveForwardingReferenceCheck |
The check warns if std::move is applied to a forwarding reference (i.e. More... | |
class | MultipleStatementMacroCheck |
Detect multiple statement macros that are used in unbraced conditionals. More... | |
class | ParentVirtualCallCheck |
Finds calls to grand..-parent virtual methods instead of parent's. More... | |
class | SizeofContainerCheck |
Find usages of sizeof on expressions of STL container types. More... | |
class | SizeofExpressionCheck |
Find suspicious usages of sizeof expression. More... | |
class | StringConstructorCheck |
Finds suspicious string constructor and check their parameters. More... | |
class | StringIntegerAssignmentCheck |
Finds instances where an integer is assigned to a string. More... | |
class | StringLiteralWithEmbeddedNulCheck |
Find suspicious string literals with embedded NUL characters. More... | |
class | SuspiciousEnumUsageCheck |
The checker detects various cases when an enum is probably misused (as a bitmask). More... | |
class | SuspiciousMemsetUsageCheck |
Finds memset calls with potential mistakes in their arguments. More... | |
class | SuspiciousMissingCommaCheck |
This check finds string literals which are probably concatenated accidentally. More... | |
class | SuspiciousSemicolonCheck |
This check finds semicolon that modifies the meaning of the program unintendedly. More... | |
class | SuspiciousStringCompareCheck |
Find suspicious calls to string compare functions. More... | |
class | SwappedArgumentsCheck |
Finds potentially swapped arguments by looking at implicit conversions. More... | |
class | TerminatingContinueCheck |
Checks if a 'continue' statement terminates the loop (i.e. More... | |
class | ThrowKeywordMissingCheck |
Emits a warning about temporary objects whose type is (or is derived from) a class that has 'EXCEPTION', 'Exception' or 'exception' in its name. More... | |
class | TooSmallLoopVariableCheck |
This check gives a warning if a loop variable has a too small type which might not be able to represent all values which are part of the whole range in which the loop iterates. More... | |
class | UndefinedMemoryManipulationCheck |
Finds calls of memory manipulation functions memset() , memcpy() and memmove() on not TriviallyCopyable objects resulting in undefined behavior. More... | |
class | UndelegatedConstructorCheck |
Finds creation of temporary objects in constructors that look like a function call to another constructor of the same class. More... | |
class | UnusedRaiiCheck |
Finds temporaries that look like RAII objects. More... | |
class | UnusedReturnValueCheck |
Detects function calls where the return value is unused. More... | |
class | UseAfterMoveCheck |
The check warns if an object is used after it has been moved, without an intervening reinitialization. More... | |
struct | ValueRange |
Stores a min and a max value which describe an interval. More... | |
class | VirtualNearMissCheck |
Checks for near miss of virtual methods. More... | |
Typedefs | |
using | BasesVector = llvm::SmallVector< const CXXRecordDecl *, 5 > |
Functions | |
static std::vector< std::pair< SourceLocation, StringRef > > | getCommentsInRange (ASTContext *Ctx, CharSourceRange Range) |
static std::vector< std::pair< SourceLocation, StringRef > > | getCommentsBeforeLoc (ASTContext *Ctx, SourceLocation Loc) |
static bool | isLikelyTypo (llvm::ArrayRef< ParmVarDecl *> Params, StringRef ArgName, unsigned ArgIndex) |
static bool | sameName (StringRef InComment, StringRef InDecl, bool StrictMode) |
static bool | looksLikeExpectMethod (const CXXMethodDecl *Expect) |
static bool | areMockAndExpectMethods (const CXXMethodDecl *Mock, const CXXMethodDecl *Expect) |
static const CXXMethodDecl * | findMockedMethod (const CXXMethodDecl *Method) |
static const FunctionDecl * | resolveMocks (const FunctionDecl *Func) |
*that are placed right before the argument **code *void | f (bool foo) |
Checks that argument comments match parameter names. More... | |
*** | f (true) |
static bool | isValidBuiltinFold (const BuiltinType &ValueType, const BuiltinType &InitType, const ASTContext &Context) |
Returns true if ValueType is allowed to fold into InitType, i.e. More... | |
static bool | haveSameNamespaceOrTranslationUnit (const CXXRecordDecl *Decl1, const CXXRecordDecl *Decl2) |
static std::string | getNameOfNamespace (const CXXRecordDecl *Decl) |
static bool | isSurroundedLeft (const Token &T) |
Is argument surrounded properly with parentheses/braces/squares/commas? More... | |
static bool | isSurroundedRight (const Token &T) |
Is argument surrounded properly with parentheses/braces/squares/commas? More... | |
static bool | isKeyword (const Token &T) |
Is given TokenKind a keyword? More... | |
static bool | isWarnOp (const Token &T) |
Warning is written when one of these operators are not within parentheses. More... | |
static bool | isVarDeclKeyword (const Token &T) |
Is given Token a keyword that is used in variable declarations? More... | |
static bool | possibleVarDecl (const MacroInfo *MI, const Token *Tok) |
Is there a possible variable declaration at Tok? More... | |
static unsigned | getMaxCalculationWidth (const ASTContext &Context, const Expr *E) |
static int | relativeIntSizes (BuiltinType::Kind Kind) |
static int | relativeCharSizes (BuiltinType::Kind Kind) |
static int | relativeCharSizesW (BuiltinType::Kind Kind) |
static bool | isFirstWider (BuiltinType::Kind First, BuiltinType::Kind Second) |
static void | replaceMoveWithForward (const UnresolvedLookupExpr *Callee, const ParmVarDecl *ParmVar, const TemplateTypeParmDecl *TypeParmDecl, DiagnosticBuilder &Diag, const ASTContext &Context) |
static bool | isParentOf (const CXXRecordDecl &Parent, const CXXRecordDecl &ThisClass) |
static BasesVector | getParentsByGrandParent (const CXXRecordDecl &GrandParent, const CXXRecordDecl &ThisClass, const CXXMethodDecl &MemberDecl) |
static std::string | getNameAsString (const NamedDecl *Decl) |
static std::string | getExprAsString (const clang::Expr &E, clang::ASTContext &AC) |
static int | enumLength (const EnumDecl *EnumDec) |
Return the number of EnumConstantDecls in an EnumDecl. More... | |
static bool | hasDisjointValueRange (const EnumDecl *Enum1, const EnumDecl *Enum2) |
static bool | isNonPowerOf2NorNullLiteral (const EnumConstantDecl *EnumConst) |
static bool | isMaxValAllBitSetLiteral (const EnumDecl *EnumDec) |
static int | countNonPowOfTwoLiteralNum (const EnumDecl *EnumDec) |
static bool | isPossiblyBitMask (const EnumDecl *EnumDec) |
Check if there is one or two enumerators that are not a power of 2 and are initialized by a literal in the enum type, and that the enumeration contains enough elements to reasonably act as a bitmask. More... | |
static const Expr * | ignoreNoOpCasts (const Expr *E) |
Look through lvalue to rvalue and nop casts. More... | |
static bool | isImplicitCastCandidate (const CastExpr *Cast) |
Restrict the warning to implicit casts that are most likely accidental. More... | |
static unsigned | calcPositiveBits (const ASTContext &Context, const QualType &IntExprType) |
Returns the positive part of the integer width for an integer type. More... | |
static unsigned | calcUpperBoundPositiveBits (const ASTContext &Context, const Expr *UpperBound, const QualType &UpperBoundType) |
Calculate the upper bound expression's positive bits, but ignore constant like values to reduce false positives. More... | |
static StatementMatcher | inDecltypeOrTemplateArg () |
bool | isStandardSmartPointer (const ValueDecl *VD) |
static void | emitDiagnostic (const Expr *MovingCall, const DeclRefExpr *MoveArg, const UseAfterMove &Use, ClangTidyCheck *Check, ASTContext *Context) |
static bool | isOverrideMethod (const CXXMethodDecl *MD) |
Finds out if the given method overrides some method. More... | |
static bool | checkOverridingFunctionReturnType (const ASTContext *Context, const CXXMethodDecl *BaseMD, const CXXMethodDecl *DerivedMD) |
Checks whether the return types are covariant, according to C++[class.virtual]p7. More... | |
static QualType | getDecayedType (QualType Type) |
static bool | checkParamTypes (const CXXMethodDecl *BaseMD, const CXXMethodDecl *DerivedMD) |
static bool | checkOverrideWithoutName (const ASTContext *Context, const CXXMethodDecl *BaseMD, const CXXMethodDecl *DerivedMD) |
static bool | checkOverrideByDerivedMethod (const CXXMethodDecl *BaseMD, const CXXMethodDecl *DerivedMD) |
Check whether BaseMD overrides DerivedMD. More... | |
Variables | |
static const char | DifferentEnumErrorMessage [] |
static const char | BitmaskErrorMessage [] |
static const char | BitmaskVarErrorMessage [] |
static const char | BitmaskNoteMessage [] = "used here as a bitmask" |
static const char | KnownStringCompareFunctions [] |
static constexpr llvm::StringLiteral | LoopName |
static constexpr llvm::StringLiteral | LoopVarName |
static constexpr llvm::StringLiteral | LoopVarCastName |
static constexpr llvm::StringLiteral | LoopUpperBoundName |
static constexpr llvm::StringLiteral | LoopIncrementName |
using clang::tidy::bugprone::BasesVector = typedef llvm::SmallVector<const CXXRecordDecl *, 5> |
Definition at line 25 of file ParentVirtualCallCheck.cpp.
|
static |
Definition at line 156 of file ArgumentCommentCheck.cpp.
References looksLikeExpectMethod().
Referenced by findMockedMethod().
|
static |
Returns the positive part of the integer width for an integer type.
Definition at line 89 of file TooSmallLoopVariableCheck.cpp.
|
static |
Calculate the upper bound expression's positive bits, but ignore constant like values to reduce false positives.
Definition at line 100 of file TooSmallLoopVariableCheck.cpp.
|
static |
Check whether BaseMD overrides DerivedMD.
Prerequisite: the class which BaseMD is in should be a base class of that DerivedMD is in.
Definition at line 170 of file VirtualNearMissCheck.cpp.
References isOverrideMethod().
|
static |
Definition at line 150 of file VirtualNearMissCheck.cpp.
|
static |
Checks whether the return types are covariant, according to C++[class.virtual]p7.
Similar with clang::Sema::CheckOverridingFunctionReturnType.
Check if the return types are covariant.
BTy is the class type in return type of BaseMD. For example, B* Base::md() While BRD is the declaration of B.
Definition at line 40 of file VirtualNearMissCheck.cpp.
|
static |
Definition at line 132 of file VirtualNearMissCheck.cpp.
References getDecayedType().
|
static |
Definition at line 90 of file SuspiciousEnumUsageCheck.cpp.
References isNonPowerOf2NorNullLiteral().
Referenced by isPossiblyBitMask().
|
static |
Definition at line 356 of file UseAfterMoveCheck.cpp.
Referenced by clang::tidy::bugprone::UseAfterMoveCheck::check().
|
static |
Return the number of EnumConstantDecls in an EnumDecl.
Definition at line 54 of file SuspiciousEnumUsageCheck.cpp.
Referenced by isPossiblyBitMask().
* that are placed right before the argument* * code* void clang::tidy::bugprone::f | ( | bool | foo | ) |
Checks that argument comments match parameter names.
The check understands argument comments in the form `/*parameter_name=
Referenced by clang::clangd::uriProximity().
* * * clang::tidy::bugprone::f | ( | true | ) |
|
static |
Definition at line 171 of file ArgumentCommentCheck.cpp.
References areMockAndExpectMethods(), Ctx, D, and looksLikeExpectMethod().
Referenced by resolveMocks().
|
static |
Definition at line 91 of file ArgumentCommentCheck.cpp.
|
static |
Definition at line 47 of file ArgumentCommentCheck.cpp.
|
static |
Definition at line 125 of file VirtualNearMissCheck.cpp.
Referenced by checkParamTypes().
|
static |
Definition at line 74 of file ParentVirtualCallCheck.cpp.
Referenced by clang::tidy::bugprone::ParentVirtualCallCheck::check().
|
static |
Definition at line 56 of file MisplacedWideningCastCheck.cpp.
References Result.
Referenced by clang::tidy::bugprone::MisplacedWideningCastCheck::check().
|
static |
Definition at line 63 of file ParentVirtualCallCheck.cpp.
Referenced by clang::tidy::bugprone::ParentVirtualCallCheck::check().
|
static |
Definition at line 104 of file ForwardDeclarationNamespaceCheck.cpp.
Referenced by clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit().
|
static |
Definition at line 40 of file ParentVirtualCallCheck.cpp.
References Result.
Referenced by clang::tidy::bugprone::ParentVirtualCallCheck::check().
|
static |
Definition at line 58 of file SuspiciousEnumUsageCheck.cpp.
References clang::tidy::bugprone::ValueRange::MaxVal, and clang::tidy::bugprone::ValueRange::MinVal.
Referenced by clang::tidy::bugprone::SuspiciousEnumUsageCheck::check().
|
static |
Definition at line 83 of file ForwardDeclarationNamespaceCheck.cpp.
Referenced by clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit().
|
static |
Look through lvalue to rvalue and nop casts.
This filters out implicit conversions that have no effect on the input but block our view for other implicit casts.
Definition at line 29 of file SwappedArgumentsCheck.cpp.
Referenced by clang::tidy::bugprone::SwappedArgumentsCheck::check().
|
static |
Definition at line 78 of file UseAfterMoveCheck.cpp.
|
static |
Definition at line 170 of file MisplacedWideningCastCheck.cpp.
References relativeCharSizes(), relativeCharSizesW(), and relativeIntSizes().
Referenced by clang::tidy::bugprone::MisplacedWideningCastCheck::check().
|
static |
Restrict the warning to implicit casts that are most likely accidental.
User defined or integral conversions fit in this category, lvalue to rvalue or derived to base does not.
Definition at line 40 of file SwappedArgumentsCheck.cpp.
Referenced by clang::tidy::bugprone::SwappedArgumentsCheck::check().
|
static |
Is given TokenKind a keyword?
Definition at line 56 of file MacroParenthesesCheck.cpp.
|
static |
Definition at line 109 of file ArgumentCommentCheck.cpp.
References clang::clangd::lower().
|
static |
Definition at line 75 of file SuspiciousEnumUsageCheck.cpp.
Referenced by isPossiblyBitMask().
|
static |
Definition at line 65 of file SuspiciousEnumUsageCheck.cpp.
Referenced by countNonPowOfTwoLiteralNum().
|
static |
Finds out if the given method overrides some method.
Definition at line 31 of file VirtualNearMissCheck.cpp.
Referenced by checkOverrideByDerivedMethod().
|
static |
Definition at line 27 of file ParentVirtualCallCheck.cpp.
Referenced by clang::tidy::bugprone::ParentVirtualCallCheck::check().
|
static |
Check if there is one or two enumerators that are not a power of 2 and are initialized by a literal in the enum type, and that the enumeration contains enough elements to reasonably act as a bitmask.
Exclude the case where the last enumerator is the sum of the lesser values (and initialized by a literal) or when it could contain consecutive values.
Definition at line 101 of file SuspiciousEnumUsageCheck.cpp.
References countNonPowOfTwoLiteralNum(), enumLength(), isMaxValAllBitSetLiteral(), clang::tidy::bugprone::ValueRange::MaxVal, and clang::tidy::bugprone::ValueRange::MinVal.
Referenced by clang::tidy::bugprone::SuspiciousEnumUsageCheck::check().
bool clang::tidy::bugprone::isStandardSmartPointer | ( | const ValueDecl * | VD | ) |
Definition at line 209 of file UseAfterMoveCheck.cpp.
|
static |
Is argument surrounded properly with parentheses/braces/squares/commas?
Definition at line 44 of file MacroParenthesesCheck.cpp.
|
static |
Is argument surrounded properly with parentheses/braces/squares/commas?
Definition at line 50 of file MacroParenthesesCheck.cpp.
|
static |
Returns true if ValueType is allowed to fold into InitType, i.e.
if: static_cast<InitType>(ValueType{some_value}) does not result in trucation.
Definition at line 80 of file FoldInitTypeCheck.cpp.
|
static |
Is given Token a keyword that is used in variable declarations?
Definition at line 70 of file MacroParenthesesCheck.cpp.
|
static |
Warning is written when one of these operators are not within parentheses.
Definition at line 62 of file MacroParenthesesCheck.cpp.
|
static |
Definition at line 151 of file ArgumentCommentCheck.cpp.
Referenced by areMockAndExpectMethods(), and findMockedMethod().
|
static |
Is there a possible variable declaration at Tok?
Definition at line 78 of file MacroParenthesesCheck.cpp.
|
static |
Definition at line 132 of file MisplacedWideningCastCheck.cpp.
Referenced by isFirstWider().
|
static |
Definition at line 151 of file MisplacedWideningCastCheck.cpp.
Referenced by isFirstWider().
|
static |
Definition at line 97 of file MisplacedWideningCastCheck.cpp.
Referenced by isFirstWider().
|
static |
Definition at line 22 of file MoveForwardingReferenceCheck.cpp.
Referenced by clang::tidy::bugprone::MoveForwardingReferenceCheck::check().
|
static |
Definition at line 196 of file ArgumentCommentCheck.cpp.
References Ctx, and findMockedMethod().
|
static |
Definition at line 142 of file ArgumentCommentCheck.cpp.
|
static |
Definition at line 24 of file SuspiciousEnumUsageCheck.cpp.
|
static |
Definition at line 34 of file SuspiciousEnumUsageCheck.cpp.
|
static |
Definition at line 29 of file SuspiciousEnumUsageCheck.cpp.
|
static |
Definition at line 21 of file SuspiciousEnumUsageCheck.cpp.
Referenced by clang::tidy::bugprone::SuspiciousEnumUsageCheck::check().
|
static |
Definition at line 25 of file SuspiciousStringCompareCheck.cpp.
|
static |
Definition at line 28 of file TooSmallLoopVariableCheck.cpp.
Referenced by clang::tidy::bugprone::TooSmallLoopVariableCheck::check().
|
static |
Definition at line 20 of file TooSmallLoopVariableCheck.cpp.
|
static |
Definition at line 26 of file TooSmallLoopVariableCheck.cpp.
Referenced by clang::tidy::bugprone::TooSmallLoopVariableCheck::check().
|
static |
Definition at line 24 of file TooSmallLoopVariableCheck.cpp.
|
static |
Definition at line 22 of file TooSmallLoopVariableCheck.cpp.
Referenced by clang::tidy::bugprone::TooSmallLoopVariableCheck::check().