[clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class...
authorFelix Berger <flx@google.com>
Tue, 3 May 2016 01:41:19 +0000 (01:41 +0000)
committerFelix Berger <flx@google.com>
Tue, 3 May 2016 01:41:19 +0000 (01:41 +0000)
Reviewers: alexfh, JVApen, aaron.ballman

Subscribers: flx, aaron.ballman, cfe-commits

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

llvm-svn: 268352

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

index eabadd8..9ba8bd9 100644 (file)
@@ -31,6 +31,8 @@ void fieldsRequiringInit(const RecordDecl::field_range &Fields,
                          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))
index b95f158..4cda3a4 100644 (file)
@@ -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() {}               \