<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141292>141292</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy `bugprone-unused-return-value` does not work for Obj-C methods
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
seanm
</td>
</tr>
</table>
<pre>
Given:
```objc
#import <Foundation/Foundation.h>
int main (void)
{
[NSString alloc]; // expect warning: return value ignored
return 0;
}
```
Here I want a warning for ignoring the return value of `alloc`. (Like ignoring the return value of malloc, this is almost always wrong.)
`bugprone-unused-return-value` has an option `CheckedFunctions` which you can set to the regex `.*` to get warnings for ***all*** ignored return values. This indeed works for C/C++ functions, even in Obj-C source files. I can't get it to work for Obj-C methods though.
I don't know the LLVM codebase at all, but was learning about clang-tidy, and looked at [UnusedReturnValueCheck.cpp](https://github.com/llvm/llvm-project/blob/35c15e41ae9ce0c503efacda592c1aa5eb61e6ec/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp#L175) and I wonder if this is because it matches with [callExpr](https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html) and [ObjCMessageExpr](https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html) is not a subclass of that.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVF1v2zYU_TX0y4UF6cqS4wc9xE61BUhXYN36WvDjWmJCkwZJ2cm_H0jZTjsUxYYCBGyRPOeec3hJHoIeLFHHmi1rHhZ8iqPzXSBuDwvh1Fv3mz6RZfU9K_Noy3k48SzTN9b6cHQ-Aqt3vZus4lE7y7B__yhGVn-Y4dpGOHBtgeHdyWnFcJMW1ltW3gOwZvvH58_RazsAN8ZJ1jywegsMe4Y90OuRZIQz91bbgdX34ClO3sKJm4lAD9Z5UrnQJo97uO4oWb3NhR6-9TBr-p08wSOcuY3Ar-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