clang-tools
8.0.0
|
Classes | |
class | AbseilModule |
class | DurationComparisonCheck |
Prefer comparison in the absl::Duration domain instead of the numeric domain. 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 | 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 | 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.") |
static bool | IsValidMacro (const MatchFinder::MatchResult &Result, const Expr *E) |
Return true if E is a either: not a macro at all; or an argument to one. More... | |
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 > & | getInverseForScale (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... | |
llvm::StringRef | getFactoryForScale (DurationScale Scale) |
Returns the 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 > | getScaleForInverse (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... | |
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... | |
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... | |
AST_MATCHER_FUNCTION (ast_matchers::internal::Matcher< FunctionDecl >, DurationConversionFunction) | |
AST_MATCHER_FUNCTION (ast_matchers::internal::Matcher< FunctionDecl >, DurationFactoryFunction) | |
|
strong |
Duration factory and conversion scales.
Enumerator | |
---|---|
Hours | |
Minutes | |
Seconds | |
Milliseconds | |
Microseconds | |
Nanoseconds |
Definition at line 22 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER_FUNCTION | ( | ast_matchers::internal::Matcher< FunctionDecl > | , |
DurationConversionFunction | |||
) |
Definition at line 78 of file DurationRewriter.h.
clang::tidy::abseil::AST_MATCHER_FUNCTION | ( | ast_matchers::internal::Matcher< FunctionDecl > | , |
DurationFactoryFunction | |||
) |
Definition at line 90 of file DurationRewriter.h.
llvm::StringRef clang::tidy::abseil::getFactoryForScale | ( | 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 89 of file DurationRewriter.cpp.
Referenced by clang::tidy::abseil::DurationFactoryScaleCheck::check(), and rewriteExprFromNumberToDuration().
const std::pair< llvm::StringRef, llvm::StringRef > & clang::tidy::abseil::getInverseForScale | ( | 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 41 of file DurationRewriter.cpp.
Referenced by rewriteInverseDurationCall().
|
static |
Definition at line 103 of file DurationFactoryScaleCheck.cpp.
References GetNewScaleSingleStep().
Referenced by clang::tidy::abseil::DurationFactoryScaleCheck::check().
|
static |
Definition at line 57 of file DurationFactoryScaleCheck.cpp.
Referenced by GetNewScale().
|
static |
Definition at line 26 of file DurationFactoryScaleCheck.cpp.
Referenced by clang::tidy::abseil::DurationFactoryScaleCheck::check().
llvm::Optional< DurationScale > clang::tidy::abseil::getScaleForInverse | ( | 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 179 of file DurationRewriter.cpp.
Referenced by clang::tidy::abseil::DurationComparisonCheck::check(), and clang::tidy::abseil::DurationSubtractionCheck::check().
|
static |
Definition at line 44 of file DurationFactoryScaleCheck.cpp.
Referenced by clang::tidy::abseil::DurationFactoryScaleCheck::check().
|
static |
Definition at line 23 of file DurationFactoryFloatCheck.cpp.
Referenced by clang::tidy::abseil::DurationFactoryFloatCheck::check().
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 108 of file DurationRewriter.cpp.
Referenced by clang::tidy::abseil::DurationFactoryScaleCheck::check(), and rewriteExprFromNumberToDuration().
|
static |
Return true
if E
is a either: not a macro at all; or an argument to one.
In the latter case, we should still transform it.
Definition at line 24 of file DurationComparisonCheck.cpp.
References Loc.
Referenced by clang::tidy::abseil::DurationComparisonCheck::check().
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 201 of file DurationRewriter.cpp.
References getFactoryForScale(), IsLiteralZero(), rewriteInverseDurationCall(), and simplifyDurationFactoryArg().
Referenced by clang::tidy::abseil::DurationComparisonCheck::check(), and clang::tidy::abseil::DurationSubtractionCheck::check().
|
static |
If Node
is a call to the inverse of Scale
, return that inverse's argument, otherwise None.
Definition at line 72 of file DurationRewriter.cpp.
References getInverseForScale().
Referenced by rewriteExprFromNumberToDuration().
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 164 of file DurationRewriter.cpp.
References stripFloatCast(), and stripFloatLiteralFraction().
Referenced by rewriteExprFromNumberToDuration().
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 134 of file DurationRewriter.cpp.
Referenced by clang::tidy::abseil::DurationFactoryFloatCheck::check(), and simplifyDurationFactoryArg().
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 154 of file DurationRewriter.cpp.
References truncateIfIntegral().
Referenced by clang::tidy::abseil::DurationFactoryFloatCheck::check(), and simplifyDurationFactoryArg().
|
static |
Returns an integer if the fractional part of a FloatingLiteral
is 0
.
Definition at line 29 of file DurationRewriter.cpp.
Referenced by stripFloatLiteralFraction().
|
static |
Referenced by clang::tidy::abseil::AbseilModule::addCheckFactories(), and main().