<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/150874>150874</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
After overloading the type conversion operator, clang-tidy analysis errors occur.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
inschrift-spruch-raum
</td>
</tr>
</table>
<pre>
```cpp main.cpp
#include <iostream>
class A {
public:
int a;
int b;
explicit operator double(this const A& self) { return self.a + self.b; }
};
auto main(std::int32_t /*argc*/, const char* /*argv*/[]) -> std::int32_t {
auto c = A{.a = 1, .b = 2};
double d = double(c);
std::cout << d;
}
```
```
clang-tidy main.cpp
5809 warnings generated.
main.cpp:12:8: warning: variable name 'c' is too short, expected at least 3 characters [readability-identifier-length]
12 | auto c = A{.a = 1, .b = 2};
| ^
main.cpp:13:3: warning: use auto when initializing with a cast to avoid duplicating the type name [hicpp-use-auto]
13 | double d = double(c);
| ^~~~~~
| auto
main.cpp:13:10: warning: variable name 'd' is too short, expected at least 3 characters [readability-identifier-length]
13 | double d = double(c);
| ^
main.cpp:13:14: warning: redundant cast to the same type [google-readability-casting]
13 | double d = double(c);
| ^
note: this fix will not be applied because it overlaps with another fix
main.cpp:13:14: warning: redundant explicit casting to the same type 'double' as the sub-expression, remove this casting [readability-redundant-casting]
13 | double d = double(c);
| ^~~~~~~ ~
main.cpp:8:12: note: source type originates from the invocation of this method
8 | explicit operator double(this const A& self) { return self.a + self.b; }
| ^
Suppressed 5804 warnings (5804 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0Vs1u4zYQfhr6MpAhkZYlH3yQ4-QFip4LihxLLGhSIEdO3MM-e0FJtpPstou0WMGA-TvzffONZiRjNJ1D3LPywMrjSo7U-7A3Lqo-mBNlc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