[PATCH] D70569: [clangd] Allow extract-to-function on regions that always return.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 03:57:39 PST 2019
kadircet added inline comments.
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:611
+ // (Others are possible if there are conversions, but this seems clearest).
+ if (CapturedInfo.HasReturnStmt) {
+ // If the return is conditional, neither replacing the code with
----------------
sammccall wrote:
> kadircet wrote:
> > nit: early exits
> I'm not sure what this comment means, can you elaborate?
> (I do mean "sometimes returns and sometimes doesn't". Early-exits aren't a problem, e.g. `if (x) return 1; return 2;` can be extracted.)
ah sorry, i was trying to imply usage of early exits in the code, i.e:
```
ExtractedFunc.ReturnType = EnclosingFunc.getParentASTContext().VoidTy;
if not HasReturnStmt
return true;
if not AlwaysReturn
return false;
.
.
.
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70569/new/
https://reviews.llvm.org/D70569
More information about the cfe-commits
mailing list