[PATCH] D18300: [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer
Felix Berger via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 19 20:26:12 PDT 2016
flx created this revision.
flx added reviewers: alexfh, JVApen.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.
This fixes bug https://llvm.org/bugs/show_bug.cgi?id=26747
Repository:
rL LLVM
http://reviews.llvm.org/D18300
Files:
clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===================================================================
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -86,6 +86,14 @@
int I;
};
+struct A {};
+template <class> class B;
+template <class T> class NegativeTemplateConstructor {
+ NegativeTemplateConstructor(const B<T> &, A) {}
+ bool Bool{false};
+ // CHECK-FIXES: bool Bool{false};
+};
+
#define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
struct UninitializedField##FIELD { \
UninitializedField##FIELD() {} \
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -32,6 +32,8 @@
fieldsRequiringInit(const RecordDecl::field_range &Fields,
SmallPtrSetImpl<const FieldDecl *> &FieldsToInit) {
for (const FieldDecl *F : Fields) {
+ if (F->hasInClassInitializer())
+ continue;
QualType Type = F->getType();
if (Type->isPointerType() || Type->isBuiltinType())
FieldsToInit.insert(F);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18300.51123.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160320/d62b2ecd/attachment-0001.bin>
More information about the cfe-commits
mailing list