[PATCH] D45082: [RFC][unittests] ADT: silence -Wself-assign diagnostics

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 31 09:53:30 PDT 2018


rjmccall added a comment.

In https://reviews.llvm.org/D45082#1053724, @lebedev.ri wrote:

> - Rebase
> - Drop comments
> - Silence the warning via "*&" contraption, not by casting to the reference.
>
>   The main question still stands, do we want to recommend everyone to use that in their codebases, or double the amount of diag flags and provide a way to silence this specific diagnostic?


I think it's probably best to just provide a blessed way of silencing the warning in code and recommend that people adopt that.  A good analogue here is the use of unnecessary parentheses to silence the -Wparens warning about using '=' instead of '==' in an if-condition; we've always recognized that there are legitimate reasons to write code that way, so we just picked a code idiom that we promise will always shut the warning off and tell people to use it if they need it.

I think I still prefer casting the RHS as the idiom to bless here, on the grounds that casts are the more universal "treat this as an opaque value" tool; for example, that's how you tell -Wconversion to shut up.  On the other hand, *& is certainly not something that we expect to see much of in ordinary code, so it works, and it's definitely a less annoying thing to type.


Repository:
  rL LLVM

https://reviews.llvm.org/D45082





More information about the llvm-commits mailing list