[PATCH] D63773: [clangd] dummy variable extraction on a function scope
Shaurya Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 5 09:57:16 PDT 2019
SureYeaah added inline comments.
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:90
+bool isAFunctionRef(const clang::Expr *Expr) {
+ const clang::DeclRefExpr *DeclRef = dyn_cast_or_null<DeclRefExpr>(Expr);
+ if (DeclRef && isa<FunctionDecl>(DeclRef->getDecl()))
----------------
sammccall wrote:
> sammccall wrote:
> > Extracting just a declrefexpr (and replacing it with another declrefexpr) doesn't seem useful. Any reason to only do this for functions, rather than all declrefexprs?
> a syntactically similar case is MemberExpr where isImplicitAccess() is true. (This is referring to a method of the current class, without qualification)
Extracting
int a = [[f]]();
yields
auto dummy = f;
int a = dummy();
I thought this should be prevented. But now I see there's no need to do that.
I'll add a triviality check if needed in the next patch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63773/new/
https://reviews.llvm.org/D63773
More information about the cfe-commits
mailing list