llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

multiple `readability-named-parameter` warnings not reported at once with line breaks in function signature

Open firewave opened this issue 2 years ago • 2 comments

#include <string>

class A {
public:
    A() {}
    virtual ~A() {}

    virtual void f(const std::string &a, const char b[], const std::size_t c);
};

class B : public A {
public:
    void f(const std::string&, // warning
           const char[], // no warning
           const std::size_t) override {} // no warning
};

class C : public A {
public:
    void f(const std::string&, const char[], const std::size_t) override {} // warning
};
<source>:13:30: warning: all parameters should be named in a function [readability-named-parameter]
    void f(const std::string&, // warning
                             ^
                              /*a*/
<source>:20:30: warning: all parameters should be named in a function [readability-named-parameter]
    void f(const std::string&, const char[], const std::size_t) override {} // warning
                             ^
                              /*a*/       /*b*/                /*c*/

https://godbolt.org/z/o9WdWGqrh

If you fix the warning in line 13 and run it again it will report the one in line 14 and so on.

firewave avatar Sep 21 '22 15:09 firewave

@llvm/issue-subscribers-clang-tidy

llvmbot avatar Sep 21 '22 15:09 llvmbot

Actually check works correctly, it produces warning for first unnamed, but fixes for all of them. probably it could be changed to provide separate warning, but still message refers to all parameters, not 'xyz' parameter.

PiotrZSL avatar Jun 28 '23 07:06 PiotrZSL