[clang-tools-extra] [llvm] [clang] Fix #41439: Update the documentation with the correct information. (PR #69377)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 26 05:16:56 PST 2023


https://github.com/Da-Viper updated https://github.com/llvm/llvm-project/pull/69377

>From 0e0a3e7ad1a0a7098e05a5164413369eaa58c55b Mon Sep 17 00:00:00 2001
From: Ezike Ebuka <yerimyah1 at gmail.com>
Date: Tue, 17 Oct 2023 20:49:47 +0100
Subject: [PATCH 1/4] Fix #41439: Update the documentation with the correct
 information.

---
 .../clang-tidy/checks/readability/named-parameter.rst    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
index 8d28c0aa02169a7..7e7099b3df251d1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
@@ -10,7 +10,12 @@ Guide:
 
 https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions
 
-All parameters should be named, with identical names in the declaration and
-implementation.
+A parameter name may be omitted only if the parameter is not used in the
+function's definition.
+
+.. code-block:: c++
+int doingSomething(int a, int b, int) {  // Ok: the third paramet is not used
+    return a + b;
+}
 
 Corresponding cpplint.py check name: `readability/function`.

>From 9c6bb278d10264d3a47752062e754dba5a372cec Mon Sep 17 00:00:00 2001
From: Ezike Ebuka <yerimyah1 at gmail.com>
Date: Sat, 11 Nov 2023 20:27:05 +0000
Subject: [PATCH 2/4] Fix: Add the recommended explanation

---
 .../docs/clang-tidy/checks/readability/named-parameter.rst    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
index 7e7099b3df251d1..603a186862451be 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
@@ -10,8 +10,8 @@ Guide:
 
 https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions
 
-A parameter name may be omitted only if the parameter is not used in the
-function's definition.
+All parameters should have the same name in both the function declaration and definition.
+If a parameter is not utilized, its name can be commented out in a function definition.
 
 .. code-block:: c++
 int doingSomething(int a, int b, int) {  // Ok: the third paramet is not used

>From 5a2d5b844958b2e503d634a162d6fb9589ddaa4c Mon Sep 17 00:00:00 2001
From: Ezike Ebuka <yerimyah1 at gmail.com>
Date: Sun, 26 Nov 2023 13:16:10 +0000
Subject: [PATCH 4/4] Update: the documentation with the correct information

---
 .../clang-tidy/checks/readability/named-parameter.rst  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
index 603a186862451be..73677a48605f495 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst
@@ -14,8 +14,12 @@ All parameters should have the same name in both the function declaration and de
 If a parameter is not utilized, its name can be commented out in a function definition.
 
 .. code-block:: c++
-int doingSomething(int a, int b, int) {  // Ok: the third paramet is not used
-    return a + b;
-}
+
+    int doingSomething(int a, int b, int c);
+
+    int doingSomething(int a, int b, int /*c*/) {
+        // Ok: the third param is not used
+        return a + b;
+    }
 
 Corresponding cpplint.py check name: `readability/function`.



More information about the cfe-commits mailing list