Add rewriter of data members to getter/setter member functions
This CL adds a Clang rewriter that converts references to a data
member to calls of a getter or setter. The intended use-case is to
convert a struct with public members to a class with getters and
setters.
Specifically, it's intended to rewrite the structs FormData and
FormFieldData, starting with FormFieldData::value.
The rewriter does the following conversion, where `foo` is a
`FormFieldData`:
Old: `foo.value = bar` `foo->value = bar`
New: `foo.set_value(bar)` `foo->set_value(bar)`
Outside of the LHS of an assignment:
Old: `foo.value` `foo->value`
New: `foo.value()` `foo->value()`
Old: `::testing::Field(&FormFieldData::value, bar)`
New: `::testing::Property(&FormFieldData::value, bar)`
Followup CLs will extend the rewriter to other public data members
of FormFieldData and add another rewriter for its parent struct
FormData.
Bug: 40232021
Change-Id: Iaad5042514f6deafe3ee3f6a95f428bfb216508a
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5422009
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Christoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/main@{#1288878}
NOKEYCHECK=True
GitOrigin-RevId: 42c36aeee2de84c1ef21ef767114b56a7e265c0c
5 files changed