[clang-tools-extra] r268352 - [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer.

Felix Berger via cfe-commits cfe-commits at lists.llvm.org
Mon May 2 18:41:19 PDT 2016


Author: flx
Date: Mon May  2 20:41:19 2016
New Revision: 268352

URL: http://llvm.org/viewvc/llvm-project?rev=268352&view=rev
Log:
[clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer.

Reviewers: alexfh, JVApen, aaron.ballman

Subscribers: flx, aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D18300

Modified:
    clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=268352&r1=268351&r2=268352&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp Mon May  2 20:41:19 2016
@@ -31,6 +31,8 @@ void fieldsRequiringInit(const RecordDec
                          ASTContext &Context,
                          SmallPtrSetImpl<const FieldDecl *> &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+    if (F->hasInClassInitializer())
+      continue;
     QualType Type = F->getType();
     if (!F->hasInClassInitializer() &&
         type_traits::isTriviallyDefaultConstructible(Type, Context))

Modified: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=268352&r1=268351&r2=268352&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp Mon May  2 20:41:19 2016
@@ -85,6 +85,14 @@ struct NegativeInitializedInBody {
   int I;
 };
 
+struct A {};
+template <class> class AA;
+template <class T> class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const AA<T> &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD {             \
     UninitializedField##FIELD() {}               \




More information about the cfe-commits mailing list