[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 05:48:22 PST 2018
aaron.ballman added inline comments.
================
Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+ auto AsyncRetval1 = std::async(increment, 42);
----------------
khuttun wrote:
> aaron.ballman wrote:
> > Sorry, I just realized that we're missing a test case for a common situation -- where the result is used as part of another call expression. Can you add a test to `noWarning()` to make sure this does not warn:
> > ```
> > std::vector<int> v;
> > extern void f(bool);
> >
> > f(v.empty()); // Should not warn
> > ```
> See line 199 in this file.
Ah, my eyes missed that, thank you!
Hmm, I *think* this test should also be okay, but I want to be sure:
```
std::vector<int> v;
bool b = ({v.empty()}); // Should not warn
({v.empty()}); // ???
```
I kind of thing that, as an extension to the spirit of this check, any GNU expression statement whose result is unused should probably be diagnosed; what do you think?
You should add tests for the above so we document the expected behavior here.
https://reviews.llvm.org/D41655
More information about the cfe-commits
mailing list