| Issue |
58116
|
| Summary |
[clang-tidy] misc-unused-parameters inconsistently misses intitializers
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
DaAwesomeP
|
I am seeing clang-tidy inconsistently warn or ignore about unused parameters in constructors where the initializer makes use of the parameter. It will complain about some parameters but not others.
I have some functions like:
```cpp
class MyClass {
public:
MyClass(Point point1, Point point2, MyStruct otherStruct, bool someBool, float someFloat)
: mPoint1{ point1 }
, mPoint2{ point2 }
, mOtherStruct{ otherStruct }
, mIgnore{ someBool }
, mSomeFloat{ someFloat } {}
MyClass(Point point1, Point point2)
: mPoint1{ point1 }
, mPoint2{ point2 }
, mOtherStruct{ MyStruct() }
, mIgnore{ false }
, mSomeFloat{ 0 } {}
private:
Point mPoint1;
Point mPoint2;
MyStruct mOtherStruct;
bool mSomeBool;
float mSomeFloat;
};
```
I am seeing:
```
/home/myuser/file.hpp:30:20: error: parameter 'point1' is unused [misc-unused-parameters,-warnings-as-errors]
MyClass(Point point1, Point point2, MyStruct otherStruct, bool someBool, float someFloat)
^~~~~~
/*point1*/
/home/myuser/file.hpp:30:34: error: parameter 'point2' is unused [misc-unused-parameters,-warnings-as-errors]
MyClass(Point point1, Point point2, MyStruct otherStruct, bool someBool, float someFloat)
^~~
/*point2*/
/home/myuser/file.hpp:37:20: error: parameter 'point1' is unused [misc-unused-parameters,-warnings-as-errors]
MyClass(Point point1, Point point2)
^~~~~~
/*point1*/
/home/myuser/file.hpp:37:34: error: parameter 'point2' is unused [misc-unused-parameters,-warnings-as-errors]
MyClass(Point point1, Point point2)
^~~
/*point2*/
```
Even though `point1` and `point2` are clearly used in the initializers. **More importantly, I am not seeing this warning for `otherStruct`, `someBool`, or `someFloat`.**
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs