This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Parse __attribute((foo)) as a pointer qualifier
ClosedPublic

Authored by arichardson on Aug 27 2020, 6:51 AM.

Details

Summary

Before: void f() { MACRO(A * attribute((foo)) a); }
After: void f() { MACRO(A *
attribute((foo)) a); }

Also check that the attribute alias is handled.

Diff Detail

Event Timeline

arichardson created this revision.Aug 27 2020, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2020, 6:51 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
arichardson requested review of this revision.Aug 27 2020, 6:51 AM
aaron.ballman added inline comments.
clang/lib/Format/TokenAnnotator.cpp
1895

What about other attributes than GNU-style ones, like [[clang::address_space(0)]]?

arichardson added inline comments.Aug 27 2020, 6:59 AM
clang/lib/Format/TokenAnnotator.cpp
1895

I guess those should also be handled. I can try to do that in a follow-up change.

arichardson added inline comments.Aug 27 2020, 8:48 AM
clang/lib/Format/TokenAnnotator.cpp
1895

It appears that they are already handled for this case. I've handled them in cast expressions in D86721.

aaron.ballman added inline comments.Aug 27 2020, 9:39 AM
clang/lib/Format/TokenAnnotator.cpp
1895

Ah, thank you for the update! Can you add a test case for that, as I don't see one in the current tests?

arichardson marked 2 inline comments as done.Aug 28 2020, 2:57 AM
arichardson added inline comments.
clang/lib/Format/TokenAnnotator.cpp
1895

I added the test to D86721 since this change handles attribute and that one deals with [[attr]]

MyDeveloperDay accepted this revision.Aug 28 2020, 2:58 AM

LGTM thank you for these updates

This revision is now accepted and ready to land.Aug 28 2020, 2:58 AM
This revision was landed with ongoing or failed builds.Aug 28 2020, 3:32 AM
This revision was automatically updated to reflect the committed changes.
arichardson marked an inline comment as done.