diff options
author | Tommy Chen <gcchen@google.com> | 2025-03-12 01:05:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-11 18:05:01 +0100 |
commit | d22d14375d4410cdb441e04016531962e3abb44e (patch) | |
tree | 750f4c43a127cdea518ca6b6bada4b8b69c46d1a /clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp | |
parent | 517c6778ead6e7c476e0f4482763060c679ee80b (diff) | |
download | llvm-d22d14375d4410cdb441e04016531962e3abb44e.zip llvm-d22d14375d4410cdb441e04016531962e3abb44e.tar.gz llvm-d22d14375d4410cdb441e04016531962e3abb44e.tar.bz2 |
[clang-tidy] support different precisions (#130540)
Support float and long double versions of the math functions for
UseStdNumbersCheck.
For example, after this commit the check is able to catch `sqrtf(2)` and
`expl(1)`.
Fixes: #130325
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp index 1548fc4..38ef771 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp @@ -91,8 +91,11 @@ struct MatchBuilder { auto matchMathCall(const StringRef FunctionName, const Matcher<clang::Expr> ArgumentMatcher) const { + auto HasAnyPrecisionName = hasAnyName( + FunctionName, (FunctionName + "l").str(), + (FunctionName + "f").str()); // Support long double(l) and float(f). return expr(ignoreParenAndFloatingCasting( - callExpr(callee(functionDecl(hasName(FunctionName), + callExpr(callee(functionDecl(HasAnyPrecisionName, hasParameter(0, hasType(isArithmetic())))), hasArgument(0, ArgumentMatcher)))); } |