[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 13 06:36:00 PST 2016
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<bool>(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 <cmath> 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
More information about the cfe-commits
mailing list