If an operation defines an optional attribute (OptionalAttr or
UnitAttr), transformations may wish to remove these attributes while
maintaining invariants established by the operation. Currently, the only
way to do this is by calling Operation::removeAttr("attrName"), which
requires developers to know the exact name of the attribute used by
table-gen. Furthermore, if the attribute name changes, this won't be
detected at compile time. Instead, removeAttr would return an empty
attribute and no errors would be raised, unless the caller checks for
the returned value.
This patch adds table gen support for generating remove<AttrName>Attr
methods for OptionalAttributes defined by operations.
Implementation choice: to preserve camelCase for the method's name, the
first character of an attribute called myAttr is changed to upper case
in order to preserve the coding style, so the final method would be
called removeMyAttr.
nit: in general we are conservative with auto and use it when it helps readability and/or the type is entirely obvious from the context.