[clang-tools-extra] [clangd] Consider expression statements in ExtractVariable tweak (PR #112525)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 8 17:33:25 PST 2024


HighCommander4 wrote:

@ckandeler Could you elaborate on the motivation for this change?

In my mind, the value proposition of the "extract variable" refactoring is that it saves you the work of moving the expression from one location to another, and typing the name of the variable twice (once at the declaration and once at the use).

In the expression-statement case, the expression isn't moving to a new location, and the variable name is only mentioned in one place. In essence, the refactoring amounts to prepending `auto placeholder = ` to the expression. Given that you're going to be (very likely) renaming `placeholder` anyways, does this really add anything meaningful over just typing `auto VariableNameYouWant = ` "manually"?

https://github.com/llvm/llvm-project/pull/112525


More information about the cfe-commits mailing list