[PATCH] D157242: [clang-tidy] Exclude delegate constructors in cppcoreguidelines-prefer-member-initializer

2023-08-07 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a4b12e39b84: [clang-tidy] Exclude delegate constructors in 
cppcoreguidelines-prefer-member… (authored by PiotrZSL).

Changed prior to commit:
  https://reviews.llvm.org/D157242?vs=547607=547649#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157242/new/

https://reviews.llvm.org/D157242

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
@@ -563,3 +563,10 @@
 // CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
   }
 };
+
+struct PR52818  {
+PR52818() : bar(5) {}
+PR52818(int) : PR52818() { bar = 3; }
+
+int bar;
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@
   to ignore ``static`` variables declared within the scope of
   ``class``/``struct``.
 
+- Improved :doc:`cppcoreguidelines-prefer-member-initializer
+  ` check to
+  ignore delegate constructors.
+
 - Improved :doc:`llvm-namespace-comment
   ` check to provide fixes for
   ``inline`` namespaces in the same format as :program:`clang-format`.
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -141,10 +141,11 @@
 }
 
 void PreferMemberInitializerCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  cxxConstructorDecl(hasBody(compoundStmt()), unless(isInstantiated()))
-  .bind("ctor"),
-  this);
+  Finder->addMatcher(cxxConstructorDecl(hasBody(compoundStmt()),
+unless(isInstantiated()),
+unless(isDelegatingConstructor()))
+ .bind("ctor"),
+ this);
 }
 
 void PreferMemberInitializerCheck::check(


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
@@ -563,3 +563,10 @@
 // CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
   }
 };
+
+struct PR52818  {
+PR52818() : bar(5) {}
+PR52818(int) : PR52818() { bar = 3; }
+
+int bar;
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@
   to ignore ``static`` variables declared within the scope of
   ``class``/``struct``.
 
+- Improved :doc:`cppcoreguidelines-prefer-member-initializer
+  ` check to
+  ignore delegate constructors.
+
 - Improved :doc:`llvm-namespace-comment
   ` check to provide fixes for
   ``inline`` namespaces in the same format as :program:`clang-format`.
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -141,10 +141,11 @@
 }
 
 void PreferMemberInitializerCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  cxxConstructorDecl(hasBody(compoundStmt()), unless(isInstantiated()))
-  .bind("ctor"),
-  this);
+  Finder->addMatcher(cxxConstructorDecl(hasBody(compoundStmt()),
+unless(isInstantiated()),
+unless(isDelegatingConstructor()))
+ .bind("ctor"),
+ this);
 }
 
 void PreferMemberInitializerCheck::check(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157242: [clang-tidy] Exclude delegate constructors in cppcoreguidelines-prefer-member-initializer

2023-08-06 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp, ccotter.
Herald added subscribers: shchenz, kbarton, xazax.hun, nemanjai.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

As proposed by check fix would result in compilation error,
lets exclude delegate constructors from being checked.

Fixes: #52818


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157242

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
@@ -563,3 +563,10 @@
 // CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
   }
 };
+
+struct PR52818  {
+PR52818() : bar(5) {}
+PR52818(int) : PR52818() { bar = 3; }
+
+int bar;
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@
   to ignore ``static`` variables declared within the scope of
   ``class``/``struct``.
 
+- Improved :doc:`cppcoreguidelines-prefer-member-initializer
+  ` check to
+  exclude delegate constructors from being checked.
+
 - Improved :doc:`llvm-namespace-comment
   ` check to provide fixes for
   ``inline`` namespaces in the same format as :program:`clang-format`.
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -141,10 +141,11 @@
 }
 
 void PreferMemberInitializerCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  cxxConstructorDecl(hasBody(compoundStmt()), unless(isInstantiated()))
-  .bind("ctor"),
-  this);
+  Finder->addMatcher(cxxConstructorDecl(hasBody(compoundStmt()),
+unless(isInstantiated()),
+unless(isDelegatingConstructor()))
+ .bind("ctor"),
+ this);
 }
 
 void PreferMemberInitializerCheck::check(


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
@@ -563,3 +563,10 @@
 // CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
   }
 };
+
+struct PR52818  {
+PR52818() : bar(5) {}
+PR52818(int) : PR52818() { bar = 3; }
+
+int bar;
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@
   to ignore ``static`` variables declared within the scope of
   ``class``/``struct``.
 
+- Improved :doc:`cppcoreguidelines-prefer-member-initializer
+  ` check to
+  exclude delegate constructors from being checked.
+
 - Improved :doc:`llvm-namespace-comment
   ` check to provide fixes for
   ``inline`` namespaces in the same format as :program:`clang-format`.
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -141,10 +141,11 @@
 }
 
 void PreferMemberInitializerCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  cxxConstructorDecl(hasBody(compoundStmt()), unless(isInstantiated()))
-  .bind("ctor"),
-  this);
+  Finder->addMatcher(cxxConstructorDecl(hasBody(compoundStmt()),
+unless(isInstantiated()),
+unless(isDelegatingConstructor()))
+ .bind("ctor"),
+ this);
 }
 
 void PreferMemberInitializerCheck::check(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits