Issue |
141292
|
Summary |
clang-tidy `bugprone-unused-return-value` does not work for Obj-C methods
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
seanm
|
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs