[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar added a comment. Sent https://reviews.llvm.org/D27748 for #include suggestion. Repository: rL LLVM https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
This revision was automatically updated to reflect the committed changes. Closed by commit rL289627: [ClangTidy] Add new performance-type-promotion-in-math-fn check. (authored by jlebar). Changed prior to commit: https://reviews.llvm.org/D27284?vs=80011&id=81339#toc Repository: rL LLVM https://reviews.llvm.org/D27284 Files: clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp +++ clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,314 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double, double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} std::acos(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' + // CHECK-FIXES: {{^}} std::acosh(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' + // CHECK-FIXES: {{^}} std::asin(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' + // CHECK-FIXES: {{^}} std::asinh(a);{{$}} + atan2(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' + // CHECK-FIXES: {{^}} std::atan2(a, b);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' + // CHECK-FIXES: {{^}} std::atan(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' + // CHECK-FIXES: {{^}} std::atanh(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' + // CHECK-FIXES: {{^}} std::cbrt(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' + // CHECK-FIXES: {{^}} std::ceil(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' + // CHECK-FIXES: {{^}} std::copysign(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' + // CHECK-FIXES: {{^}} std::cos(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' + // CHECK-FIXES: {{^}} std::cosh(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' + // CHECK-FIXES: {{^}} std::erf(a);{{$}} + erfc(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc' + // CHECK-FIXES: {{^}} std::erfc(a);{{$}} + exp2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2' + // CHECK-FIXES: {{^}} std::exp2(a);{{$}} + exp(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp' + // CHECK-FIXES: {{^}} std::exp(a);{{$}} + expm1(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1' + // CHECK-FIXES: {{^}} std::expm1(a);{{$}} + fabs(a); + // CHECK-MES
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar marked an inline comment as done. jlebar added a comment. In https://reviews.llvm.org/D27284#621052, @malcolm.parsons wrote: > In https://reviews.llvm.org/D27284#609937, @Eugene.Zelenko wrote: > > > Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). > > > This has not been done. Indeed, sorry I missed that. Done now, will be reflected when I submit. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:167-168 + + // FIXME: Perhaps we should suggest #include if we suggest a cmath + // function and cmath is not already included. +} alexfh wrote: > We definitely should. See the use of IncludeInserter in > UnnecessaryValueParamCheck, for example. Fine for a follow-up. OK, would rather send a followup because this patch is already nontrivial. I'll get to work on that -- thank you for the pointer. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
malcolm.parsons added a comment. In https://reviews.llvm.org/D27284#609937, @Eugene.Zelenko wrote: > Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). This has not been done. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG with one nit. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145-153 + bool StdFnRequresCpp11 = + llvm::StringSwitch(OldFnName) + .Cases("acosh", "asinh", "atanh", "cbrt", "copysign", "erf", "erfc", + "exp2", "expm1", "fdim", true) + .Cases("fma", "fmax", "fmin", "hypot", "ilogb", "lgamma", "llrint", + "llround", "log1p", true) + .Cases("log2", "logb", "lrint", "lround", "nearbyint", "nextafter", Maybe just make a static StringSet of all the names and check whether the name is in it? Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:167-168 + + // FIXME: Perhaps we should suggest #include if we suggest a cmath + // function and cmath is not already included. +} We definitely should. See the use of IncludeInserter in UnnecessaryValueParamCheck, for example. Fine for a follow-up. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar added a comment. @alexfh , friendly ping. I'm not in a huge rush on this or anything, but I don't want one or both of us to lose all context here... https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar added a comment. Thank you very much for the reviews, @alexfh. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar updated this revision to Diff 80011. jlebar added a comment. Suggest std::foo instead of ::foof. I spoke with rtrieu IRL and he suggested I do this to match what he did in SemaChecking.cpp for calls to "abs". Seems reasonable to me. This also lets me sidestep the question of lexing the qualifiers, which is nice. https://reviews.llvm.org/D27284 Files: clang-tools-extra/clang-tidy/performance/CMakeLists.txt clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,314 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double, double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} std::acos(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' + // CHECK-FIXES: {{^}} std::acosh(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' + // CHECK-FIXES: {{^}} std::asin(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' + // CHECK-FIXES: {{^}} std::asinh(a);{{$}} + atan2(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' + // CHECK-FIXES: {{^}} std::atan2(a, b);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' + // CHECK-FIXES: {{^}} std::atan(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' + // CHECK-FIXES: {{^}} std::atanh(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' + // CHECK-FIXES: {{^}} std::cbrt(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' + // CHECK-FIXES: {{^}} std::ceil(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' + // CHECK-FIXES: {{^}} std::copysign(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' + // CHECK-FIXES: {{^}} std::cos(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' + // CHECK-FIXES: {{^}} std::cosh(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' + // CHECK-FIXES: {{^}} std::erf(a);{{$}} + erfc(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc' + // CHECK-FIXES: {{^}} std::erfc(a);{{$}} + exp2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2' + // CHECK-FIXES: {{^}} std::exp2(a);{{$}} + exp(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp' + // CHECK-FIXES: {{^}} std::exp(a);{{$}} + expm1(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1' + // CHECK-FIXES: {{^}} std::expm1(a);{{$}} + fabs(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs' + // CHECK-FIXES: {{^}} std::fabs(a);{{$}} + fdim(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67 + Finder->addMatcher( + callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2), + hasBuiltinTyParam(0, DoubleTy), + hasBuiltinTyParam(1, DoubleTy))), + hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy)) + .bind("call"), jlebar wrote: > alexfh wrote: > > I guess, functions with arbitrary number of parameters can all be handled > > using `forEachArgumentWithParam`. Roughly like this: > > > > forEachArgumentWithParam( > > hasType(isBuiltinType(FloatTy)), > > parmVarDecl(hasType(isBuiltinType(DoubleTy))) > > > > One difference to your existing implementation will be that it will match > > calls where at least one parameter is double and argument is float, not all > > of them. Do you expect this to make the check more noisy? > > Do you expect this to make the check more noisy? > > Yes, to the point of not being worth doing, I think. > > Specifically, I think there is nothing wrong with calling a two-arg function > double function with one float and one double arg and expecting the float arg > to be promoted: `::hypot(3.f, 4.)` probably *should* call the double version. > > So checking that the arg types are all `float` is important, I think. > Checking that the parameter types are all `double` is less important but also > worth doing, I think, so if you declare some bizarre function in the global > namespace called e.g. `::hypot`, we won't suggest changing that to `::hypotf`. Fair enough. I don't like the verbosity of the code here, but it may really be valuable to be strict here. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145 + // Skip the "::" following the qualifier. + FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2); +} jlebar wrote: > alexfh wrote: > > `getLocWithOffset` makes the code quite brittle. Imagine whitespace around > > `::`, for example. Same below. In order to make this kind of code more > > robust, you can operate on tokens (using Lexer). > > > > Same below. > Hm. I agree this is super-brittle. But I am having a lot of difficulty > using the Lexer successfully. > > For one thing, there may be comments basically anywhere in this stream, and I > have to skip over them. I see getPreviousNonCommentToken, but it doesn't > quite work if I need to go *forward* in the stream. I looked at a bunch of > other uses of the Lexer in clang-tidy and they all looked pretty different > from what I'm trying to do here, which also suggested that maybe I'm doing > the wrong thing. > > Is there no way to get the source location of "sin" out of the DeclRefExpr > for "::sin"? I don't see it, but it seems bizarre that it wouldn't be there. > > Any tips would be much appreciated. Skipping from `::` to the next identifier should be straightforward using Lexer::getRawToken and Lexer::getLocForEndOfToken. Tell me if you need more details. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar added inline comments. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67 + Finder->addMatcher( + callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2), + hasBuiltinTyParam(0, DoubleTy), + hasBuiltinTyParam(1, DoubleTy))), + hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy)) + .bind("call"), alexfh wrote: > I guess, functions with arbitrary number of parameters can all be handled > using `forEachArgumentWithParam`. Roughly like this: > > forEachArgumentWithParam( > hasType(isBuiltinType(FloatTy)), > parmVarDecl(hasType(isBuiltinType(DoubleTy))) > > One difference to your existing implementation will be that it will match > calls where at least one parameter is double and argument is float, not all > of them. Do you expect this to make the check more noisy? > Do you expect this to make the check more noisy? Yes, to the point of not being worth doing, I think. Specifically, I think there is nothing wrong with calling a two-arg function double function with one float and one double arg and expecting the float arg to be promoted: `::hypot(3.f, 4.)` probably *should* call the double version. So checking that the arg types are all `float` is important, I think. Checking that the parameter types are all `double` is less important but also worth doing, I think, so if you declare some bizarre function in the global namespace called e.g. `::hypot`, we won't suggest changing that to `::hypotf`. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145 + // Skip the "::" following the qualifier. + FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2); +} alexfh wrote: > `getLocWithOffset` makes the code quite brittle. Imagine whitespace around > `::`, for example. Same below. In order to make this kind of code more > robust, you can operate on tokens (using Lexer). > > Same below. Hm. I agree this is super-brittle. But I am having a lot of difficulty using the Lexer successfully. For one thing, there may be comments basically anywhere in this stream, and I have to skip over them. I see getPreviousNonCommentToken, but it doesn't quite work if I need to go *forward* in the stream. I looked at a bunch of other uses of the Lexer in clang-tidy and they all looked pretty different from what I'm trying to do here, which also suggested that maybe I'm doing the wrong thing. Is there no way to get the source location of "sin" out of the DeclRefExpr for "::sin"? I don't see it, but it seems bizarre that it wouldn't be there. Any tips would be much appreciated. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar updated this revision to Diff 79951. jlebar marked 2 inline comments as done. jlebar added a comment. Update test, use "auto". Still need to figure out how to lex these function calls properly. https://reviews.llvm.org/D27284 Files: clang-tools-extra/clang-tidy/performance/CMakeLists.txt clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,326 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acosf(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' + // CHECK-FIXES: {{^}} acoshf(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' + // CHECK-FIXES: {{^}} asinf(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' + // CHECK-FIXES: {{^}} asinhf(a);{{$}} + atan2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' + // CHECK-FIXES: {{^}} atan2f(a);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' + // CHECK-FIXES: {{^}} atanf(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' + // CHECK-FIXES: {{^}} atanhf(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' + // CHECK-FIXES: {{^}} cbrtf(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' + // CHECK-FIXES: {{^}} ceilf(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' + // CHECK-FIXES: {{^}} copysignf(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' + // CHECK-FIXES: {{^}} cosf(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' + // CHECK-FIXES: {{^}} coshf(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' + // CHECK-FIXES: {{^}} erff(a);{{$}} + erfc(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc' + // CHECK-FIXES: {{^}} erfcf(a);{{$}} + exp2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2' + // CHECK-FIXES: {{^}} exp2f(a);{{$}} + exp(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp' + // CHECK-FIXES: {{^}} expf(a);{{$}} + expm1(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1' + // CHECK-FIXES: {{^}} expm1f(a);{{$}} + fabs(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs' + // CHECK-FIXES: {{^}} fabsf(a);{{$}} + fdim(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fdim' + // CHECK-FIXES: {{^}} fdimf(a, b);{{$}} + floor(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'floor' + // CHECK-FIXES: {{^}} floorf(a);{{$}} + fma(a, b, c); +
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. Thank you for the new check! A few comments. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:22 +AST_MATCHER_P(Type, isBuiltinType, BuiltinType::Kind, Kind) { + if (const BuiltinType *BT = dyn_cast(&Node)) { +return BT->getKind() == Kind; `const auto *` is preferred to avoid duplication of the type name. Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67 + Finder->addMatcher( + callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2), + hasBuiltinTyParam(0, DoubleTy), + hasBuiltinTyParam(1, DoubleTy))), + hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy)) + .bind("call"), I guess, functions with arbitrary number of parameters can all be handled using `forEachArgumentWithParam`. Roughly like this: forEachArgumentWithParam( hasType(isBuiltinType(FloatTy)), parmVarDecl(hasType(isBuiltinType(DoubleTy))) One difference to your existing implementation will be that it will match calls where at least one parameter is double and argument is float, not all of them. Do you expect this to make the check more noisy? Comment at: clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145 + // Skip the "::" following the qualifier. + FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2); +} `getLocWithOffset` makes the code quite brittle. Imagine whitespace around `::`, for example. Same below. In order to make this kind of code more robust, you can operate on tokens (using Lexer). Same below. Comment at: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp:70 + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acoshf(a);{{$}} We usually truncate repeated static parts of CHECK patterns (except for the first one) to make tests a bit less verbose. You can at least truncate the check name in all but the first check pattern. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar updated this revision to Diff 79835. jlebar marked an inline comment as done. jlebar added a comment. Note that the relevant functions may come from . https://reviews.llvm.org/D27284 Files: clang-tools-extra/clang-tidy/performance/CMakeLists.txt clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,321 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acosf(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acoshf(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinf(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinhf(a);{{$}} + atan2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atan2f(a);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanf(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanhf(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cbrtf(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} ceilf(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} copysignf(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cosf(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} coshf(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} erff(a);{{$}} + erfc(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc' promotes float to double
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst:6 + +Finds calls to math.h functions with implicit float to double promotions. + jlebar wrote: > Eugene.Zelenko wrote: > > Please enclose math.h, float and double into ``. > > > > Will be good idea to mention cmath too. > > Please enclose math.h, float and double into ``. > > Done. I used two backticks, I hope that's the right thing. > > > Will be good idea to mention cmath too. > > What about cmath, exactly? cmath is proper C++ header for math functions prototypes. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst:6 + +Finds calls to math.h functions with implicit float to double promotions. + Eugene.Zelenko wrote: > Please enclose math.h, float and double into ``. > > Will be good idea to mention cmath too. > Please enclose math.h, float and double into ``. Done. I used two backticks, I hope that's the right thing. > Will be good idea to mention cmath too. What about cmath, exactly? https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar updated this revision to Diff 79829. jlebar marked 3 inline comments as done. jlebar added a comment. Formatting fixes in documentation. https://reviews.llvm.org/D27284 Files: clang-tools-extra/clang-tidy/performance/CMakeLists.txt clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,321 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acosf(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acoshf(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinf(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinhf(a);{{$}} + atan2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atan2f(a);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanf(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanhf(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cbrtf(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} ceilf(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} copysignf(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cosf(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} coshf(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} erff(a);{{$}} + erfc(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc' promotes float to double [performance-
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
Eugene.Zelenko added a comment. Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst:6 + +Finds calls to math.h functions with implicit float to double promotions. + Please enclose math.h, float and double into ``. Will be good idea to mention cmath too. Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst:8 + +For example, warns on `::sin(0.f)`, because this funciton's parameter is a +double. You probably meant to call `::sinf(0.f)`, or maybe `std::sin(0.f)`. Please enclose functions into ``. Same in other places. Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst:9 +For example, warns on `::sin(0.f)`, because this funciton's parameter is a +double. You probably meant to call `::sinf(0.f)`, or maybe `std::sin(0.f)`. Please fix double space. https://reviews.llvm.org/D27284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
jlebar created this revision. jlebar added a subscriber: cfe-commits. Herald added a subscriber: mgorny. This checks for calls to double-precision math.h with single-precision arguments. For example, it suggests replacing ::sin(0.f) with ::sinf(0.f). https://reviews.llvm.org/D27284 Files: clang-tools-extra/clang-tidy/performance/CMakeLists.txt clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp @@ -0,0 +1,321 @@ +// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t + +double acos(double); +double acosh(double); +double asin(double); +double asinh(double); +double atan2(double); +double atan(double); +double atanh(double); +double cbrt(double); +double ceil(double); +double copysign(double, double); +double cos(double); +double cosh(double); +double erfc(double); +double erf(double); +double exp2(double); +double exp(double); +double expm1(double); +double fabs(double); +double fdim(double, double); +double floor(double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +double fmod(double, double); +double frexp(double, int *); +double hypot(double, double); +double ilogb(double); +double ldexp(double, double); +double lgamma(double); +long long llrint(double); +double log10(double); +double log1p(double); +double log2(double); +double logb(double); +double log(double); +long lrint(double); +double modf(double); +double nearbyint(double); +double nextafter(double, double); +double nexttoward(double, long double); +double pow(double, double); +double remainder(double, double); +double remquo(double, double, int *); +double rint(double); +double round(double); +double scalbln(double, long); +double scalbn(double, int); +double sin(double); +double sinh(double); +double sqrt(double); +double tan(double); +double tanh(double); +double tgamma(double); +double trunc(double); +long long llround(double); +long lround(double); + +void check_all_fns() { + float a, b, c; + int i; + long l; + int *int_ptr; + + acos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acosf(a);{{$}} + acosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} acoshf(a);{{$}} + asin(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinf(a);{{$}} + asinh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} asinhf(a);{{$}} + atan2(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atan2f(a);{{$}} + atan(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanf(a);{{$}} + atanh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} atanhf(a);{{$}} + cbrt(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cbrtf(a);{{$}} + ceil(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} ceilf(a);{{$}} + copysign(a, b); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} copysignf(a, b);{{$}} + cos(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} cosf(a);{{$}} + cosh(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} coshf(a);{{$}} + erf(a); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf' promotes float to double [performance-type-promotion-in-math-fn] + // CHECK-FIXES: {{^}} erff(a);{{$}} + e