[PATCH] D16259: Add clang-tidy readability-redundant-return check

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 09:40:44 PST 2016


aaron.ballman added inline comments.

================
Comment at: clang-tidy/readability/RedundantReturnCheck.cpp:24
@@ +23,3 @@
+      functionDecl(isDefinition(), returns(asString("void")),
+                   has(compoundStmt(hasAnySubstatement(returnStmt()))))
+          .bind("fn"),
----------------
LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > Would be best to restrict this to a return statement that has no expression if we don't want to diagnose this:
> > ```
> > void g();
> > 
> > void f() {
> >   return g();
> > }
> > ```
> > Either way, it would be good to have a test that ensures this isn't mangled.
> How about transforming this odd looking duck into
> 
> ```
> void g();
> 
> void f() {
>   g();
> }
> ```
> 
> ?
I think in the context of this check, that would be fine.


http://reviews.llvm.org/D16259





More information about the cfe-commits mailing list