clang-tools
15.0.0git
|
Classes | |
class | AbseilModule |
class | CleanupCtadCheck |
Suggests switching the initialization pattern of absl::Cleanup instances from the factory function to class template argument deduction (CTAD), in C++17 and higher. More... | |
class | DurationAdditionCheck |
Checks for cases where addition should be performed in the absl::Time domain. More... | |
class | DurationComparisonCheck |
Prefer comparison in the absl::Duration domain instead of the numeric domain. More... | |
class | DurationConversionCastCheck |
Checks for casts of absl::Duration conversion functions, and recommends the right conversion function instead. More... | |
class | DurationDivisionCheck |
class | DurationFactoryFloatCheck |
This check finds cases where Duration factories are being called with floating point arguments, but could be called using integer arguments. More... | |
class | DurationFactoryScaleCheck |
This check finds cases where the incorrect Duration factory function is being used by looking for scaling constants inside the factory argument and suggesting a more appropriate factory. More... | |
struct | DurationScale2IndexFunctor |
class | DurationSubtractionCheck |
Checks for cases where subtraction should be performed in the absl::Duration domain. More... | |
class | DurationUnnecessaryConversionCheck |
Finds and fixes cases where absl::Duration values are being converted to numeric types and back again. More... | |
class | FasterStrsplitDelimiterCheck |
Finds instances of absl::StrSplit() or absl::MaxSplits() where the delimiter is a single character string literal and replaces it with a character. More... | |
class | NoInternalDependenciesCheck |
Finds instances where the user depends on internal details and warns them against doing so. More... | |
class | NoNamespaceCheck |
This check ensures users don't open namespace absl, as that violates Abseil's compatibility guidelines. More... | |
class | RedundantStrcatCallsCheck |
Flags redundant calls to absl::StrCat when the result is being passed to another call of absl::StrCat/absl::StrAppend. More... | |
class | StrCatAppendCheck |
Flags uses of absl::StrCat to append to a string. More... | |
class | StringFindStartswithCheck |
class | StringFindStrContainsCheck |
Finds s.find(...) == string::npos comparisons (for various string-like types) and suggests replacing with absl::StrContains. More... | |
class | TimeComparisonCheck |
Prefer comparison in the absl::Time domain instead of the numeric domain. More... | |
class | TimeSubtractionCheck |
Finds and fixes absl::Time subtraction expressions to do subtraction in the time domain instead of the numeric domain. More... | |
class | UpgradeDurationConversionsCheck |
Finds deprecated uses of absl::Duration arithmetic operators and factories. More... | |
Enumerations | |
enum | DurationScale : std::uint8_t { DurationScale::Hours = 0, DurationScale::Minutes, DurationScale::Seconds, DurationScale::Milliseconds, DurationScale::Microseconds, DurationScale::Nanoseconds } |
Duration factory and conversion scales. More... | |
Functions | |
static ClangTidyModuleRegistry::Add< AbseilModule > | X ("abseil-module", "Add Abseil checks.") |
RewriteRuleWith< std::string > | CleanupCtadCheckImpl () |
static bool | insideMacroDefinition (const MatchFinder::MatchResult &Result, SourceRange Range) |
static llvm::Optional< DurationScale > | getScaleForFactory (llvm::StringRef FactoryName) |
static double | getValue (const IntegerLiteral *IntLit, const FloatingLiteral *FloatLit) |
static llvm::Optional< std::tuple< DurationScale, double > > | getNewScaleSingleStep (DurationScale OldScale, double Multiplier) |
static llvm::Optional< DurationScale > | getNewScale (DurationScale OldScale, double Multiplier) |
static llvm::Optional< llvm::APSInt > | truncateIfIntegral (const FloatingLiteral &FloatLiteral) |
Returns an integer if the fractional part of a FloatingLiteral is 0 . More... | |
const std::pair< llvm::StringRef, llvm::StringRef > & | getDurationInverseForScale (DurationScale Scale) |
Given a Scale return the fully qualified inverse functions for it. More... | |
static llvm::Optional< std::string > | rewriteInverseDurationCall (const MatchFinder::MatchResult &Result, DurationScale Scale, const Expr &Node) |
If Node is a call to the inverse of Scale , return that inverse's argument, otherwise None. More... | |
static llvm::Optional< std::string > | rewriteInverseTimeCall (const MatchFinder::MatchResult &Result, DurationScale Scale, const Expr &Node) |
If Node is a call to the inverse of Scale , return that inverse's argument, otherwise None. More... | |
llvm::StringRef | getDurationFactoryForScale (DurationScale Scale) |
Returns the factory function name for a given Scale . More... | |
llvm::StringRef | getTimeFactoryForScale (DurationScale Scale) |
Given a 'Scale', return the appropriate factory function call for constructing a Time for that scale. More... | |
llvm::StringRef | getTimeInverseForScale (DurationScale Scale) |
Returns the Time factory function name for a given Scale . More... | |
bool | isLiteralZero (const MatchFinder::MatchResult &Result, const Expr &Node) |
Returns true if Node is a value which evaluates to a literal 0 . More... | |
llvm::Optional< std::string > | stripFloatCast (const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node) |
Possibly strip a floating point cast expression. More... | |
llvm::Optional< std::string > | stripFloatLiteralFraction (const MatchFinder::MatchResult &Result, const Expr &Node) |
std::string | simplifyDurationFactoryArg (const MatchFinder::MatchResult &Result, const Expr &Node) |
llvm::Optional< DurationScale > | getScaleForDurationInverse (llvm::StringRef Name) |
Given the name of an inverse Duration function (e.g., ToDoubleSeconds ), return its DurationScale , or None if a match is not found. More... | |
llvm::Optional< DurationScale > | getScaleForTimeInverse (llvm::StringRef Name) |
Given the name of an inverse Time function (e.g., ToUnixSeconds ), return its DurationScale , or None if a match is not found. More... | |
std::string | rewriteExprFromNumberToDuration (const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale, const Expr *Node) |
Assuming Node has type double or int representing a time interval of Scale , return the expression to make it a suitable Duration . More... | |
std::string | rewriteExprFromNumberToTime (const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale, const Expr *Node) |
Assuming Node has a type int representing a time instant of Scale since The Epoch, return the expression to make it a suitable Time . More... | |
bool | isInMacro (const MatchFinder::MatchResult &Result, const Expr *E) |
bool | isLiteralZero (const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node) |
llvm::Optional< std::string > | stripFloatLiteralFraction (const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node) |
Possibly remove the fractional part of a floating point literal. More... | |
std::string | simplifyDurationFactoryArg (const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node) |
Possibly further simplify a duration factory function's argument, without changing the scale of the factory function. More... | |
bool | isInMacro (const ast_matchers::MatchFinder::MatchResult &Result, const Expr *E) |
Return false if E is a either: not a macro at all; or an argument to one. More... | |
AST_MATCHER_FUNCTION (ast_matchers::internal::Matcher< FunctionDecl >, DurationConversionFunction) | |
AST_MATCHER_FUNCTION (ast_matchers::internal::Matcher< FunctionDecl >, DurationFactoryFunction) | |
AST_MATCHER_FUNCTION (ast_matchers::internal::Matcher< FunctionDecl >, TimeConversionFunction) | |
AST_MATCHER_FUNCTION_P (ast_matchers::internal::Matcher< Stmt >, comparisonOperatorWithCallee, ast_matchers::internal::Matcher< Decl >, funcDecl) | |
AST_MATCHER (Type, isCharType) | |
static transformer::RewriteRuleWith< std::string > | makeRewriteRule (ArrayRef< StringRef > StringLikeClassNames, StringRef AbseilStringsMatchHeader) |
static bool | insideMacroDefinition (const MatchFinder::MatchResult &Result, SourceRange Range) |
static bool | isConstructorAssignment (const MatchFinder::MatchResult &Result, const Expr *Node) |
static bool | isArgument (const MatchFinder::MatchResult &Result, const Expr *Node) |
static bool | isReturn (const MatchFinder::MatchResult &Result, const Expr *Node) |
static bool | parensRequired (const MatchFinder::MatchResult &Result, const Expr *Node) |
Variables | |
static const char | DefaultStringLikeClasses [] |
static const char | DefaultAbseilStringsMatchHeader [] = "absl/strings/match.h" |
|
strong |
Duration factory and conversion scales.
Enumerator | |
---|---|
Hours | |
Minutes | |
Seconds | |
Milliseconds | |
Microseconds | |
Nanoseconds |
Definition at line 21 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER | ( | Type | , |
isCharType | |||
) |
Definition at line 35 of file StringFindStrContainsCheck.cpp.
clang::tidy::abseil::AST_MATCHER_FUNCTION | ( | ast_matchers::internal::Matcher< FunctionDecl > | , |
DurationConversionFunction | |||
) |
Definition at line 99 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER_FUNCTION | ( | ast_matchers::internal::Matcher< FunctionDecl > | , |
DurationFactoryFunction | |||
) |
Definition at line 111 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER_FUNCTION | ( | ast_matchers::internal::Matcher< FunctionDecl > | , |
TimeConversionFunction | |||
) |
Definition at line 119 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER_FUNCTION_P | ( | ast_matchers::internal::Matcher< Stmt > | , |
comparisonOperatorWithCallee | , | ||
ast_matchers::internal::Matcher< Decl > | , | ||
funcDecl | |||
) |
Definition at line 127 of file DurationRewriter.h.
RewriteRuleWith<std::string> clang::tidy::abseil::CleanupCtadCheckImpl | ( | ) |
Definition at line 26 of file CleanupCtadCheck.cpp.
References CompletionModelCodegen::node().
llvm::StringRef clang::tidy::abseil::getDurationFactoryForScale | ( | DurationScale | Scale | ) |
Returns the factory function name for a given Scale
.
Given a Scale
, return the appropriate factory function call for constructing a Duration
for that scale.
Definition at line 104 of file DurationRewriter.cpp.
const std::pair< llvm::StringRef, llvm::StringRef > & clang::tidy::abseil::getDurationInverseForScale | ( | DurationScale | Scale | ) |
Given a Scale
return the fully qualified inverse functions for it.
The first returned value is the inverse for double
, and the second returned value is the inverse for int64
.
Definition at line 40 of file DurationRewriter.cpp.
|
static |
Definition at line 97 of file DurationFactoryScaleCheck.cpp.
|
static |
Definition at line 51 of file DurationFactoryScaleCheck.cpp.
llvm::Optional< DurationScale > clang::tidy::abseil::getScaleForDurationInverse | ( | llvm::StringRef | Name | ) |
Given the name of an inverse Duration function (e.g., ToDoubleSeconds
), return its DurationScale
, or None
if a match is not found.
Definition at line 231 of file DurationRewriter.cpp.
References Name.
|
static |
Definition at line 25 of file DurationFactoryScaleCheck.cpp.
llvm::Optional< DurationScale > clang::tidy::abseil::getScaleForTimeInverse | ( | llvm::StringRef | Name | ) |
Given the name of an inverse Time function (e.g., ToUnixSeconds
), return its DurationScale
, or None
if a match is not found.
Definition at line 253 of file DurationRewriter.cpp.
References Name.
llvm::StringRef clang::tidy::abseil::getTimeFactoryForScale | ( | DurationScale | Scale | ) |
Given a 'Scale', return the appropriate factory function call for constructing a Time
for that scale.
Definition at line 122 of file DurationRewriter.cpp.
llvm::StringRef clang::tidy::abseil::getTimeInverseForScale | ( | DurationScale | Scale | ) |
Returns the Time factory function name for a given Scale
.
Returns the Time inverse function name for a given Scale
.
Definition at line 141 of file DurationRewriter.cpp.
|
static |
Definition at line 38 of file DurationFactoryScaleCheck.cpp.
|
static |
Definition at line 23 of file TimeSubtractionCheck.cpp.
|
static |
Definition at line 23 of file DurationFactoryFloatCheck.cpp.
|
static |
Definition at line 48 of file TimeSubtractionCheck.cpp.
|
static |
Definition at line 31 of file TimeSubtractionCheck.cpp.
bool clang::tidy::abseil::isInMacro | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const Expr * | E | ||
) |
Return false
if E
is a either: not a macro at all; or an argument to one.
In the both cases, we often want to do the transformation.
bool clang::tidy::abseil::isInMacro | ( | const MatchFinder::MatchResult & | Result, |
const Expr * | E | ||
) |
Definition at line 305 of file DurationRewriter.cpp.
bool clang::tidy::abseil::isLiteralZero | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
bool clang::tidy::abseil::isLiteralZero | ( | const MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Returns true
if Node
is a value which evaluates to a literal 0
.
Definition at line 160 of file DurationRewriter.cpp.
|
static |
Definition at line 67 of file TimeSubtractionCheck.cpp.
|
static |
Definition at line 43 of file StringFindStrContainsCheck.cpp.
References CompletionModelCodegen::node().
|
static |
Definition at line 81 of file TimeSubtractionCheck.cpp.
std::string clang::tidy::abseil::rewriteExprFromNumberToDuration | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
DurationScale | Scale, | ||
const Expr * | Node | ||
) |
Assuming Node
has type double
or int
representing a time interval of Scale
, return the expression to make it a suitable Duration
.
Definition at line 269 of file DurationRewriter.cpp.
std::string clang::tidy::abseil::rewriteExprFromNumberToTime | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
DurationScale | Scale, | ||
const Expr * | Node | ||
) |
Assuming Node
has a type int
representing a time instant of Scale
since The Epoch, return the expression to make it a suitable Time
.
Definition at line 287 of file DurationRewriter.cpp.
|
static |
If Node
is a call to the inverse of Scale
, return that inverse's argument, otherwise None.
Definition at line 71 of file DurationRewriter.cpp.
|
static |
If Node
is a call to the inverse of Scale
, return that inverse's argument, otherwise None.
Definition at line 90 of file DurationRewriter.cpp.
std::string clang::tidy::abseil::simplifyDurationFactoryArg | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Possibly further simplify a duration factory function's argument, without changing the scale of the factory function.
Return that simplification or the text of the argument if no simplification is possible.
std::string clang::tidy::abseil::simplifyDurationFactoryArg | ( | const MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Definition at line 216 of file DurationRewriter.cpp.
llvm::Optional< std::string > clang::tidy::abseil::stripFloatCast | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Possibly strip a floating point cast expression.
If Node
represents an explicit cast to a floating point type, return the textual context of the cast argument, otherwise None
.
Definition at line 186 of file DurationRewriter.cpp.
llvm::Optional<std::string> clang::tidy::abseil::stripFloatLiteralFraction | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Possibly remove the fractional part of a floating point literal.
If Node
represents a floating point literal with a zero fractional part, return the textual context of the integral part, otherwise None
.
llvm::Optional<std::string> clang::tidy::abseil::stripFloatLiteralFraction | ( | const MatchFinder::MatchResult & | Result, |
const Expr & | Node | ||
) |
Definition at line 206 of file DurationRewriter.cpp.
|
static |
Returns an integer if the fractional part of a FloatingLiteral
is 0
.
Definition at line 28 of file DurationRewriter.cpp.
|
static |
|
static |
Definition at line 40 of file StringFindStrContainsCheck.cpp.
|
static |
Definition at line 37 of file StringFindStrContainsCheck.cpp.