Currently, all changes returned by a single application of a rule must fit in
one atomic change and therefore must apply to one file. However, there are
patterns in which a single rule will want to modify multiple files; for example,
a header and implementation to change a declaration and its definition. This
patch relaxes Transformer, libTooling's interpreter of RewriteRules, to support
multiple changes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Tooling/Transformer/Transformer.cpp | ||
---|---|---|
65–79 | The test shows an example transformer that removes code, so the header insertion logic is not triggered there. However, for a change that would be adding code, is it correct to insert the header into every file being edited? I think not necessarily. Or do you prefer to deal with this issue when we have a sample use case? |
Thanks for the review.
clang/lib/Tooling/Transformer/Transformer.cpp | ||
---|---|---|
65–79 | You're right -- these two features don't mix well. Once we support multiple files per transformation, we should change the header manipluation to be change-specific rather than apply to the whole rule. That will require some re-factoring of the APIs. For now, I'll put in a FIXME, since this is not (yet) a high demand feature and we'll just note the limitations. |
The test shows an example transformer that removes code, so the header insertion logic is not triggered there. However, for a change that would be adding code, is it correct to insert the header into every file being edited? I think not necessarily. Or do you prefer to deal with this issue when we have a sample use case?