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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 17:54:36 PDT 2016


alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good! Thank you for addressing the comments.


================
Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:117
@@ +116,3 @@
+static llvm::SmallDenseMap<int, int> createRelativeCharSizesMap() {
+  llvm::SmallDenseMap<int, int> Result(6);
+  Result[BuiltinType::UChar] = 1;
----------------
baloghadamsoftware wrote:
> I changed to SmallDenseMap and its lookup() member function is nice. However it unfortunately lacks an initializer_list constructor.
It has a constructor from two iterators, but I'm not sure it'll result in a significantly better code.

================
Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:188
@@ -114,1 +187,3 @@
+    if (CastBuiltinType && CalcBuiltinType &&
+        !isFirstWider(CastBuiltinType->getKind(), CalcBuiltinType->getKind()))
       return;
----------------
baloghadamsoftware wrote:
> Is this an LLVM style rule? I always learned that it is the safest to use braces even for single-line if bodies.
http://llvm.org/docs/CodingStandards.html is surprisingly inconsistent in this regard, but "no braces around single-line if/for/... bodies" is a more common style in LLVM and, in particular, in clang-tidy code. The problems this style might lead to (statements indented as-if they were under if/for/..., but they actually aren't) are mitigated by the wide use of clang-format.


http://reviews.llvm.org/D17987





More information about the cfe-commits mailing list