[clang] [clang][Sema] Refine unused-member-function diagnostic message for constructors (PR #84515)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 6 06:46:56 PDT 2025
================
@@ -402,7 +402,7 @@ def warn_unused_function : Warning<"unused function %0">,
InGroup<UnusedFunction>, DefaultIgnore;
def warn_unused_template : Warning<"unused %select{function|variable}0 template %1">,
InGroup<UnusedTemplate>, DefaultIgnore;
-def warn_unused_member_function : Warning<"unused member function %0">,
+def warn_unused_member_function : Warning<"unused %select{constructor|member function %1}0">,
----------------
guillem-bartrina-sonarsource wrote:
Yes, `select_special_member_kind` supports more than the default constructor: all other special members (copy constructor, move constructor, copy assignment operator, move assignment operator and destructor).
However, this PR was originally to refine the diagnostic message for **all** constructors, not just the default, copy and move ones.
With your approach, which only uses `select_special_member_kind`,
```cpp
struct S {
S() = default; // <---
S(int) {}
S(float);
S(const S &) {} // <---
S(S &&) {} // <---
}
```
Only the message will be refined for constructors with an arrow, because **the other constructors are not considered “special members”**.
https://github.com/llvm/llvm-project/pull/84515
More information about the cfe-commits
mailing list