File tree Expand file tree Collapse file tree 3 files changed +52
-4
lines changed Expand file tree Collapse file tree 3 files changed +52
-4
lines changed Original file line number Diff line number Diff line change @@ -281,8 +281,14 @@ ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
281
281
282
282
void ProTypeMemberInitCheck::registerMatchers (MatchFinder *Finder) {
283
283
auto IsUserProvidedNonDelegatingConstructor =
284
- allOf (isUserProvided (),
285
- unless (anyOf (isInstantiated (), isDelegatingConstructor ())));
284
+ allOf (isUserProvided (), unless (isInstantiated ()),
285
+ unless (isDelegatingConstructor ()),
286
+ ofClass (cxxRecordDecl ().bind (" parent" )),
287
+ unless (hasAnyConstructorInitializer (cxxCtorInitializer (
288
+ isWritten (), unless (isMemberInitializer ()),
289
+ hasTypeLoc (loc (
290
+ qualType (hasDeclaration (equalsBoundNode (" parent" )))))))));
291
+
286
292
auto IsNonTrivialDefaultConstructor = allOf (
287
293
isDefaultConstructor (), unless (isUserProvided ()),
288
294
hasParent (cxxRecordDecl (unless (isTriviallyDefaultConstructible ()))));
Original file line number Diff line number Diff line change @@ -176,6 +176,10 @@ Changes in existing checks
176
176
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
177
177
ignore delegate constructors.
178
178
179
+ - Improved :doc: `cppcoreguidelines-pro-type-member-init
180
+ <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` check to ignore
181
+ dependent delegate constructors.
182
+
179
183
- Improved :doc: `cppcoreguidelines-pro-type-vararg
180
184
<clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check to ignore
181
185
false-positives in unevaluated context (e.g., ``decltype ``, ``sizeof ``, ...).
Original file line number Diff line number Diff line change @@ -372,8 +372,7 @@ template <typename T>
372
372
class PositiveSelfInitialization : NegativeAggregateType
373
373
{
374
374
PositiveSelfInitialization () : PositiveSelfInitialization() {}
375
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
376
- // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
375
+ // This will be detected by -Wdelegating-ctor-cycles and there is no proper way to fix this
377
376
};
378
377
379
378
class PositiveIndirectMember {
@@ -579,3 +578,42 @@ struct S3 {
579
578
int C = 0 ;
580
579
};
581
580
};
581
+
582
+ // Ignore issues from delegate constructors
583
+ namespace PR37250 {
584
+ template <typename T>
585
+ struct A {
586
+ A () : A(42 ) {}
587
+ explicit A (int value) : value_(value) {}
588
+ int value_;
589
+ };
590
+
591
+ struct B {
592
+ B () : B(42 ) {}
593
+ explicit B (int value) : value_(value) {}
594
+ int value_;
595
+ };
596
+
597
+ template <typename T>
598
+ struct C {
599
+ C () : C(T()) {}
600
+ explicit C (T value) : value_(value) {}
601
+ T value_;
602
+ };
603
+
604
+ struct V {
605
+ unsigned size () const ;
606
+ };
607
+
608
+ struct S {
609
+ unsigned size_;
610
+
611
+ S (unsigned size) : size_{size} {}
612
+
613
+ template <typename U>
614
+ S (const U& u) : S(u.size()) {}
615
+ };
616
+
617
+ const V v;
618
+ const S s{v};
619
+ }
You can’t perform that action at this time.
0 commit comments