This is an archive of the discontinued LLVM Phabricator instance.

[libTooling] Add assorted `EditGenerator` combinators.
ClosedPublic

Authored by ymandel on Jul 22 2020, 5:06 AM.

Details

Summary

This patch adds various combinators that help in constructing EditGenerators:

  • noEdits
  • ifBound, specialized to ASTEdit
  • flatten and flattenVector which allow for easy construction from a set of sub edits.
  • shrinkTo, which generates edits to shrink a given range to another that it encloses.

Diff Detail

Event Timeline

ymandel created this revision.Jul 22 2020, 5:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2020, 5:06 AM
ymandel updated this revision to Diff 279771.Jul 22 2020, 5:08 AM

revert unrelated change in RangeSelector.h

asoffer accepted this revision.Jul 23 2020, 9:33 AM
asoffer added inline comments.
clang/include/clang/Tooling/Transformer/RewriteRule.h
125

I don't know about LLVM style preferences here, but a default argument to the example above seems reasonable too.

This revision is now accepted and ready to land.Jul 23 2020, 9:33 AM
ymandel marked an inline comment as done.Jul 23 2020, 10:02 AM
ymandel added inline comments.
clang/include/clang/Tooling/Transformer/RewriteRule.h
125

I'd like that, but don't see how to get the types to work out, "noEdits" is a generator, but FalseEdit branch is an ASTEdit. did you have something in mind?

gribozavr2 accepted this revision.Jul 23 2020, 10:58 AM
ymandel updated this revision to Diff 280424.Jul 24 2020, 5:50 AM

fixed lint

This revision was automatically updated to reflect the committed changes.