[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 05:50:01 PST 2020


baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:43
+static bool isLiteral(const Expr *E) {
+  return isa<StringLiteral>(E) ||
+         isa<CharacterLiteral>(E) ||
----------------
aaron.ballman wrote:
> What about other kinds of literals like user-defined literals, or literal class types? Should this be using `E->getType()->isLiteralType()`?
`E->getType()->isLiteralType()` does not work since it tells about the type, not the expression itself. Here we should return `true` for literals only, not for any expressions whose type is a literal type. Thus `int` is a literal type, `5` is an `int` literal, but `n` or `return_any_int()` not.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71199/new/

https://reviews.llvm.org/D71199





More information about the cfe-commits mailing list