This is an archive of the discontinued LLVM Phabricator instance.

[Attr] Print enum attributes at correct position
ClosedPublic

Authored by jdenny on Apr 9 2018, 2:22 PM.

Details

Summary

For example, given:

void fn() {
  enum __attribute__((deprecated)) T *p; 
}

-ast-print produced:

void fn() {
  enum T __attribute__((deprecated(""))) *p; 
}

-ast-print on that produced:

void fn() {
  enum T *p __attribute__((deprecated("")));
}

The attribute is on enum T in the first case, but it's on p in the
other cases.

Details:

Within enum declarations, enum attributes were always printed after
the tag and any member list. When no member list was present but the
enum was a type specifier in a variable declaration, the attribute
then applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.

Diff Detail

Repository
rL LLVM

Event Timeline

jdenny created this revision.Apr 9 2018, 2:22 PM
jdenny updated this revision to Diff 142672.Apr 16 2018, 12:12 PM
jdenny edited the summary of this revision. (Show Details)

Rebased onto a more recent master.

Added example to summary.

jdenny edited the summary of this revision. (Show Details)Apr 16 2018, 12:13 PM

Ping.

In case it's not clear: this patch doesn't depend on other patches, but others depend on it.

rsmith accepted this revision.Apr 23 2018, 5:36 PM
This revision is now accepted and ready to land.Apr 23 2018, 5:36 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.