This patch adds an initial rudimentary support for capturing variables that should be passed to the extracted function.
The variables are passed to the extracted function if they're used in the extracted code. If they're defined they're ignored for now, but we'll be able to handle variables that defined in extracted code but that are used after extracted code later. The variables are sorted by name when passing them to the extracted function. The exact passing semantics (reference/pointer/const reference/const pointer) are not yet computed.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Implementation looks good. Just some nits.
lib/Tooling/Refactoring/Extract/CaptureVariables.cpp | ||
---|---|---|
37 | and this? | |
51 | nit: s/Detemine/Determine/ It might make more sense to put these FIXME in class-level comment. | |
lib/Tooling/Refactoring/Extract/CaptureVariables.h | ||
37 | Maybe a FIXME here for Kind? | |
39 | Does this include trailing commas? Maybe add an example in the comment? Same below. | |
44 | Maybe printFunctionCallArg? It's unclear where this is used. | |
lib/Tooling/Refactoring/Extract/Extract.cpp | ||
154 | nit: Capture.index() > 0 to be more explicit. |
Address review comments
lib/Tooling/Refactoring/Extract/CaptureVariables.cpp | ||
---|---|---|
37 | This is a different kind of expression that won't be handled in this method, and there's a fixit for 'this' further down already. | |
lib/Tooling/Refactoring/Extract/CaptureVariables.h | ||
37 | I think this constructor will always set the same kind. |
lib/Tooling/Refactoring/Extract/CaptureVariables.cpp | ||
---|---|---|
98 | A more informative message would be better. | |
lib/Tooling/Refactoring/Extract/CaptureVariables.h | ||
29 | The name is a bit hard to parse. Maybe just CapturedEntity or simply CapturedVar? | |
37 | Then why do you need Kind? Is it changed somewhere else? Please document the behavior, |
Address review comments
lib/Tooling/Refactoring/Extract/CaptureVariables.h | ||
---|---|---|
37 | The kind will be set to a different value by the other constructors that will be added later |
The name is a bit hard to parse. Maybe just CapturedEntity or simply CapturedVar?