[PATCH] D16310: new clang-tidy checker misc-long-cast
Richard via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 20 14:01:35 PST 2016
LegalizeAdulthood added inline comments.
================
Comment at: clang-tidy/misc/LongCastCheck.cpp:43
@@ +42,3 @@
+
+static unsigned getMaxCalculationWidth(ASTContext &C, const Expr *E) {
+ E = E->IgnoreParenImpCasts();
----------------
Prefer anonymous namespace over `static` to scope visibility.
================
Comment at: clang-tidy/misc/LongCastCheck.cpp:97
@@ +96,3 @@
+
+ if (!CastType->isIntegerType() || !SubType->isIntegerType())
+ return;
----------------
Why don't you check for casting a `float` expression to a `double` or `long double`?
Isn't this the exact same issue?
If so, add a test case for casting a `float` expression to `double` and a test case for casting a `double` expression to a `long double`.
================
Comment at: clang-tidy/misc/MiscTidyModule.cpp:61
@@ -59,1 +60,3 @@
+ CheckFactories.registerCheck<LongCastCheck>(
+ "misc-long-cast");
CheckFactories.registerCheck<MacroParenthesesCheck>(
----------------
The documentation describes this check as one that looks for a cast to a "bigger type", but the name of the check implies that it only works for casts to `long`.
The name of the check should be made more generic to reflect reality.
Perhaps `misc-redundant-cast-to-larger-type` or `misc-redundant-bigger-type-cast`?
================
Comment at: docs/clang-tidy/checks/misc-long-cast.rst:11
@@ +10,3 @@
+
+Example code::
+
----------------
Please add an example for another type other than `long`, such as casting a `float` expression to a `double`.
Repository:
rL LLVM
http://reviews.llvm.org/D16310
More information about the cfe-commits
mailing list