https://github.com/maflcko updated
https://github.com/llvm/llvm-project/pull/179105
>From 70f801e54729107f5f80fc70a00ca500a297e911 Mon Sep 17 00:00:00 2001
From: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
Date: Sun, 1 Feb 2026 12:52:45 +0100
Subject: [PATCH 1/3] [clang-tidy] Check inherited constructors in
bugprone-argument-comment
---
.../bugprone/ArgumentCommentCheck.cpp | 8 +++++++
clang-tools-extra/docs/ReleaseNotes.rst | 4 ++++
...-comment-cxx-11-inherited-constructors.cpp | 22 +++++++++++++++++++
3 files changed, 34 insertions(+)
create mode 100644
clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index 2e963cd995f74..6581f49b8ef30 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -268,6 +268,14 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
return;
Callee = Callee->getFirstDecl();
+ if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(Callee)) {
+ if (Ctor->isInheritingConstructor()) {
+ if (const auto *BaseCtor =
+ Ctor->getInheritedConstructor().getConstructor()) {
+ Callee = BaseCtor->getFirstDecl();
+ }
+ }
+ }
const unsigned NumArgs =
std::min<unsigned>(Args.size(), Callee->getNumParams());
if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1))
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8cf2006172d3f..ea80502735ede 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -140,6 +140,10 @@ New check aliases
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^
+- Improved :doc:`bugprone-argument-comment
+ <clang-tidy/checks/bugprone/argument-comment>` to also check for C++11
+ inherited constructors.
+
- Improved :doc:`bugprone-macro-parentheses
<clang-tidy/checks/bugprone/macro-parentheses>` check by printing the macro
definition in the warning message if the macro is defined on command line.
diff --git
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
new file mode 100644
index 0000000000000..b5e69fa9e92cc
--- /dev/null
+++
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s bugprone-argument-comment %t
+
+struct Base {
+ explicit Base(int val) {}
+};
+
+struct Over : public Base {
+ using Base::Base;
+};
+
+int wrong() {
+ Base b{/*vall=*/2};
+// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'vall' in comment does
not match parameter name 'val'
+// CHECK-NOTES: [[@LINE-10]]:21: note: 'val' declared here
+// CHECK-FIXES: Base b{/*val=*/2};
+
+ Over o{/*vall=*/3};
+// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'vall' in comment does
not match parameter name 'val'
+// CHECK-NOTES: [[@LINE-15]]:21: note: 'val' declared here
+// CHECK-NOTES: [[@LINE-12]]:15: note: actual callee ('Base') is declared here
+// CHECK-FIXES: Over o{/*val=*/3};
+}
>From b22a5cff3a0de5e09a69e50a76cac51841b86a35 Mon Sep 17 00:00:00 2001
From: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
Date: Sun, 1 Feb 2026 14:23:54 +0100
Subject: [PATCH 2/3] remove brace for single-line if body
---
clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index 6581f49b8ef30..3fcfe66237d9a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -271,9 +271,8 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(Callee)) {
if (Ctor->isInheritingConstructor()) {
if (const auto *BaseCtor =
- Ctor->getInheritedConstructor().getConstructor()) {
+ Ctor->getInheritedConstructor().getConstructor())
Callee = BaseCtor->getFirstDecl();
- }
}
}
const unsigned NumArgs =
>From 5e5f841e04e3f064f9704fe01dca569c50f6cfa8 Mon Sep 17 00:00:00 2001
From: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
Date: Sun, 1 Feb 2026 20:04:27 +0100
Subject: [PATCH 3/3] struct Derived : public Over
---
...-comment-cxx-11-inherited-constructors.cpp | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
index b5e69fa9e92cc..679cbb2df681d 100644
---
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
+++
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-cxx-11-inherited-constructors.cpp
@@ -8,15 +8,25 @@ struct Over : public Base {
using Base::Base;
};
+struct Derived : public Over {
+ using Over::Over;
+};
+
int wrong() {
- Base b{/*vall=*/2};
-// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'vall' in comment does
not match parameter name 'val'
-// CHECK-NOTES: [[@LINE-10]]:21: note: 'val' declared here
+ Base b{/*val2=*/2};
+// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'val2' in comment does
not match parameter name 'val'
+// CHECK-NOTES: [[@LINE-14]]:21: note: 'val' declared here
// CHECK-FIXES: Base b{/*val=*/2};
- Over o{/*vall=*/3};
-// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'vall' in comment does
not match parameter name 'val'
-// CHECK-NOTES: [[@LINE-15]]:21: note: 'val' declared here
-// CHECK-NOTES: [[@LINE-12]]:15: note: actual callee ('Base') is declared here
+ Over o{/*val3=*/3};
+// CHECK-NOTES: [[@LINE-1]]:10: warning: argument name 'val3' in comment does
not match parameter name 'val'
+// CHECK-NOTES: [[@LINE-19]]:21: note: 'val' declared here
+// CHECK-NOTES: [[@LINE-16]]:15: note: actual callee ('Base') is declared here
// CHECK-FIXES: Over o{/*val=*/3};
+
+ Derived d{/*val4=*/4};
+// CHECK-NOTES: [[@LINE-1]]:13: warning: argument name 'val4' in comment does
not match parameter name 'val'
+// CHECK-NOTES: [[@LINE-25]]:21: note: 'val' declared here
+// CHECK-NOTES: [[@LINE-18]]:15: note: actual callee ('Base') is declared here
+// CHECK-FIXES: Derived d{/*val=*/4};
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits