flx added a comment.

In D102175#2759945 <https://reviews.llvm.org/D102175#2759945>, @ymandel wrote:

> Hi Felix,
> Can you clarify your concern over the warning? Is it the case that the 
> warning is not present before the fix and is only triggered after the fix?  
> I'm concerned that removing the call may have unintended side effects and I 
> would think it might better to leave the check for usage separate.  However, 
> if the fix is causing the warning then I can understand better why you want 
> to make this change.  That said, have considered replacing the var binding 
> with `(void)`, rather than deleting the statement?

Yes, the fix of converting the copied variable to a const reference introduces 
a warning when -Wall (or more specifically -Wunused) is specified and the 
variable is not used at all. The fix converts the local variable to a const 
reference. Take a const reference of an object and not using it has no 
observable side effects I think.

Here is an example of an unused, but copied variable before the fix:

https://godbolt.org/z/a5E4fMWKj

The compiler flags are "-Werror -Wall": no warnings or errors are produced.

Now after the fix:

https://godbolt.org/z/a5E4fMWKj

For more context, the assumption the check makes is that the copy is 
unnecessary. If the type executes specific side-effects in its copy-constructor 
code the type should be excluded from the check using the `AllowedTypes` 
setting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102175/new/

https://reviews.llvm.org/D102175

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to