[PATCH] D17987: [clang-tidy] Extension of checker misc-misplaced-widening-cast

Balogh, Ádám via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 04:35:27 PDT 2016

baloghadamsoftware added inline comments.

Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:119
@@ -98,4 +118,3 @@
   if (Context.getIntWidth(CastType) == Context.getIntWidth(CalcType)) {
-    if (CalcType->isSpecificBuiltinType(BuiltinType::Int) ||
-        CalcType->isSpecificBuiltinType(BuiltinType::UInt)) {
-      // There should be a warning when casting from int to long or long long.
+    if (CalcType->isSpecificBuiltinType(BuiltinType::SChar) ||
+        CalcType->isSpecificBuiltinType(BuiltinType::UChar) ||
alexfh wrote:
> `isSpecificBuiltinType` is not the best tool here. Instead, we could get the builtin type kinds and work with them (`CalcType->getAs<BuiltinType>()->getKind()` and `CastType->getAs<BuiltinType>()->getKind()` after checking that both are `BuiltinTypes`).
I do not like it either, just reused the original code and copy-pasted it. I also think that getKind() should be used and instead of the long branches we could do the comparison using relative size table(s).


More information about the cfe-commits mailing list