[PATCH] D93333: [clang-tidy] ppcoreguidelines-pro-type-member-init: suppress warning for default member funcs
Malcolm Parsons via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 20 03:24:59 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35f2c3a8b41f: [clang-tidy] cppcoreguidelines-pro-type-member-init: suppress warning for… (authored by cwarner-8702, committed by malcolm.parsons).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93333/new/
https://reviews.llvm.org/D93333
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -501,3 +501,19 @@
void Bug33557() {
NegativeImplicitInheritedCtor I(5);
}
+
+struct NegativeDefaultedCtorOutOfDecl {
+ NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &);
+ int F;
+};
+
+NegativeDefaultedCtorOutOfDecl::NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &) = default;
+
+struct PositiveDefaultConstructorOutOfDecl {
+ PositiveDefaultConstructorOutOfDecl();
+ int F;
+ // CHECK-FIXES: int F{};
+};
+
+PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = default;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -297,6 +297,10 @@
// Skip declarations delayed by late template parsing without a body.
if (!Ctor->getBody())
return;
+ // Skip out-of-band explicitly defaulted special member functions
+ // (except the default constructor).
+ if (Ctor->isExplicitlyDefaulted() && !Ctor->isDefaultConstructor())
+ return;
checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), Ctor);
} else if (const auto *Record =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93333.312965.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201220/eaf773f7/attachment.bin>
More information about the llvm-commits
mailing list