[PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

Matthias Gehre via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 25 14:20:28 PDT 2017


mgehre added inline comments.


================
Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:377
+        else if (type->isIntegerType())
+          Initializer = " = 0";
+        else if (type->isFloatingType())
----------------
aaron.ballman wrote:
> What about cases where a suffix is desired, like `U` or `LL`?
Is this really necessary for initializing to zero?
The compiler will figure out the correct thing, and I personally find "0" easier to read than "0ULL".


================
Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:379
+        else if (type->isFloatingType())
+          Initializer = " = 0.0";
+        else if (type->isPointerType())
----------------
aaron.ballman wrote:
> Same here for `f`.
This is now fixed in the check.


================
Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp:1
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -config="{CheckOptions: [{key: "cppcoreguidelines-pro-type-member-init.LiteralInitializers", value: 1}]}" -- -std=c++11
+
----------------
hokein wrote:
> `-std=c++11` is not needed. This extra compile argument is added by default when running check_clang_tidy.
If I remove ``-std=c++11``, the behavior changes and Context.getLangOpts().CPlusPlus11 is false.


https://reviews.llvm.org/D24892





More information about the cfe-commits mailing list