[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

Florin Iucha via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 28 10:13:27 PDT 2018


0x8000-0000 marked 7 inline comments as done.
0x8000-0000 added inline comments.


================
Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:53
+
+const char DefaultIgnoredIntegerValues[] = "0;1;";
+
----------------
aaron.ballman wrote:
> Is the trailing semicolon after the `1` necessary?
I have found so, experimentally.


================
Comment at: docs/clang-tidy/checks/readability-magic-numbers.rst:61-63
+configuration for accepted floating point values, primarily because most
+floating point comparisons are not exact, and some of the exact ones are not
+portable.
----------------
aaron.ballman wrote:
> I am curious to know how true this is. You got some data for integer values and reported it, but I'm wondering if you've tried the same experiment with floating-point numbers?
The problem with the floating point numbers as text is: they need to be parsed both from the configuration and from the source code _then_ compared. What is an acceptable epsilon? I don't know. Is the same epsilon acceptable on all source code? I don't know.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114





More information about the cfe-commits mailing list