[PATCH] D52892: [Clang-tidy] readability check to convert numerical constants to std::numeric_limits

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 9 02:42:42 PDT 2018


JonasToth added inline comments.


================
Comment at: clang-tidy/readability/NumericalCostantsToMaxIntCheck.cpp:63
+  const auto *Lit = Result.Nodes.getNodeAs<IntegerLiteral>("Literal");
+  assert(Decl != nullptr);
+  std::string InsteadOf = "-1";
----------------
please assert `Lit` as well and add an error message in the assert, like `assert(Decl && Lit && "Expect both matchers to match");`


================
Comment at: docs/clang-tidy/checks/readability-numerical-costants-to-max-int.rst:45
+   is `llvm`.
\ No newline at end of file

----------------
Please remove the empty line at the end


================
Comment at: test/clang-tidy/readability-numerical-costants-to-max-int.cpp:72
+unsigned char Uval27 = ~0;
+
+#define UNSIGNED unsigned
----------------
Please add tests that use typedefs (and `using = ...`) to mask the underlying type. If they dont work, use `hasCanonicalType` in the matcher, as the canonical type looks through the typedefs.

Common typedefs are `uint32_t` and the like to control the bitwidth of the integer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52892





More information about the cfe-commits mailing list