Multiclass diagnostics

Aaron Ballman aaron at aaronballman.com
Fri Dec 27 07:18:25 PST 2013


There are several instances where we have diagnostics that take a
warning form as well as an error form, but retain the same spelling
between the two forms. Eg)

def warn_attribute_pointers_only : Warning<
  "%0 attribute only applies to pointer arguments">,
  InGroup<IgnoredAttributes>;
def err_attribute_pointers_only : Error<
  "%0 attribute only applies to pointer arguments">;

This duplication can make it easy for the two diagnostic wordings to
get out of sync. For instance, with the attribute subject diagnostics,
there is a %select list that must remain in sync between the two
diagnostics.

These two patches implement multiclass support for diagnostics.

The llvm side of things modifies the table generator to pay attention
to the whether the multiclass name should be a prefix or suffix. It
does so by looking at whether the class name ends with an underscore.
So foo_ will be treated as a prefix, and anything else will be treated
as a suffix.

The clang side uses the new tablegen functionality by creating a
warning_and_error multiclass which uses the warn_ and err_ prefixes.
Because they end with an underscore, they will be concatenated
properly to form warn_attribute_pointers_only and
err_attribute_pointers_only.

If this approach seems like a good idea, I will also update the
tablegen documentation to note the new functionality, and can likely
switch over more diagnostics to using the warning_and_error base
multiclass.

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warning_error_clang.patch
Type: application/octet-stream
Size: 3372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/45e5ff1d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multiclass_prefix.patch
Type: application/octet-stream
Size: 2044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/45e5ff1d/attachment-0001.obj>


More information about the llvm-commits mailing list