llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.25k stars 11.66k forks source link

Fix misc-assign-operator-signature when const Type& returned #24613

Open EugeneZelenko opened 9 years ago

EugeneZelenko commented 9 years ago
Bugzilla Link 24239
Version unspecified
OS All

Extended Description

I run trunk Clang-tidy against trunk LLDB code which contain a lot of assign operators which return const Type& instead of Type&, but Clang-tidy was not able to fix such code.

EugeneZelenko commented 9 years ago

What Alex said. The cost of writing the fixit code was not worth it, at least for us. For the 'const T&' case we might be able to do it, since there is already a return statement. For other return types (void, int, etc) it would be really hard.

There is 156 placed in LLDB code majority of which return const Type&. This looks worth to try to automate.

Automation may make sense in other code bases.

llvmbot commented 9 years ago

What Alex said. The cost of writing the fixit code was not worth it, at least for us. For the 'const T&' case we might be able to do it, since there is already a return statement. For other return types (void, int, etc) it would be really hard.

llvmbot commented 9 years ago

This check doesn't produce fixit hints. I'm not sure whether it can produce fixits for all cases safely. It would need to analyze the implementation of the assignment operator and in some cases its usages.

I also expect this check to fire not extremely frequently, so a fix wouldn't save much time, I guess. But I also may be wrong ;)