[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 10:47:09 PST 2018


aaron.ballman added inline comments.


================
Comment at: clang-tidy/bugprone/UnusedReturnValueCheck.cpp:68
+    diag(Matched->getLocStart(),
+         "the value returned by %0 should normally be used")
+        << dyn_cast_or_null<NamedDecl>(Matched->getCalleeDecl())
----------------
"Normally" is probably a bad term to use here. How about "the value returned by %0 is usually not intended to be discarded"?


================
Comment at: clang-tidy/bugprone/UnusedReturnValueCheck.cpp:69
+         "the value returned by %0 should normally be used")
+        << dyn_cast_or_null<NamedDecl>(Matched->getCalleeDecl())
+        << Matched->getSourceRange();
----------------
In the event this returns null, the diagnostic is going to look rather odd. Because the value of the call expression is unused, this will most often trigger in a context where the method call can be inferred (especially because you're now highlighting the source range). It might make sense to simply replace the %0 with "this call expression" or somesuch in the diagnostic.


https://reviews.llvm.org/D41655





More information about the cfe-commits mailing list