10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONREWRITER_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONREWRITER_H 13 #include "clang/ASTMatchers/ASTMatchFinder.h" 14 #include "clang/ASTMatchers/ASTMatchers.h" 43 llvm::Optional<std::string>
44 stripFloatCast(
const ast_matchers::MatchFinder::MatchResult &Result,
51 llvm::Optional<std::string>
69 const std::pair<llvm::StringRef, llvm::StringRef> &
75 const ast_matchers::MatchFinder::MatchResult &Result,
DurationScale Scale,
79 DurationConversionFunction) {
82 hasAnyName(
"::absl::ToDoubleHours",
"::absl::ToDoubleMinutes",
83 "::absl::ToDoubleSeconds",
"::absl::ToDoubleMilliseconds",
84 "::absl::ToDoubleMicroseconds",
"::absl::ToDoubleNanoseconds",
85 "::absl::ToInt64Hours",
"::absl::ToInt64Minutes",
86 "::absl::ToInt64Seconds",
"::absl::ToInt64Milliseconds",
87 "::absl::ToInt64Microseconds",
"::absl::ToInt64Nanoseconds"));
91 DurationFactoryFunction) {
93 return functionDecl(hasAnyName(
"::absl::Nanoseconds",
"::absl::Microseconds",
94 "::absl::Milliseconds",
"::absl::Seconds",
95 "::absl::Minutes",
"::absl::Hours"));
102 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONCOMPARISONCHECK_H
AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher< FunctionDecl >, DurationConversionFunction)
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 ...
llvm::StringRef getFactoryForScale(DurationScale Scale)
Returns the factory function name for a given Scale.
static constexpr llvm::StringLiteral Name
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
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...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< std::string > stripFloatCast(const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node)
Possibly strip a floating point cast expression.
llvm::Optional< std::string > stripFloatLiteralFraction(const MatchFinder::MatchResult &Result, const Expr &Node)
bool IsLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node)
Returns true if Node is a value which evaluates to a literal 0.
const std::pair< llvm::StringRef, llvm::StringRef > & getInverseForScale(DurationScale Scale)
Given a Scale return the fully qualified inverse functions for it.
DurationScale
Duration factory and conversion scales.