This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix formatting of _Atomic() qualifier
ClosedPublic

Authored by arichardson on Sep 1 2020, 10:10 AM.

Details

Summary

Before: _Atomic(uint64_t) * a;
After: _Atomic(uint64_t) *a;

This treats _Atomic the same as the the TypenameMacros and decltype. It
also allows some cleanup by removing checks whether the token before a
paren is kw_decltype and instead checking for TT_TypeDeclarationParen.
While touching this code also extend the decltype test cases to also check
for typeof() and _Atomic(T).

Depends on D86950

Diff Detail

Event Timeline

arichardson created this revision.Sep 1 2020, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2020, 10:10 AM
arichardson requested review of this revision.Sep 1 2020, 10:10 AM
  • use valid C++ syntax in the test case
MyDeveloperDay accepted this revision.Sep 4 2020, 8:07 AM

This LGTM

This revision is now accepted and ready to land.Sep 4 2020, 8:07 AM
This revision was automatically updated to reflect the committed changes.

Sorry to be really late here, but this patch regressed some macro definitions like:

#define lambda [](const decltype(x) &ptr) {}

which now formats as

#define lambda [](const decltype(x) & ptr) {}

(extra space around ampersand)

It looks like the generalization of decltype into a tokentype on the parens isn't catching all the cases it used to.
This isn't really my area - any idea why this might be?

Sorry to be really late here, but this patch regressed some macro definitions like:

#define lambda [](const decltype(x) &ptr) {}

which now formats as

#define lambda [](const decltype(x) & ptr) {}

(extra space around ampersand)

It looks like the generalization of decltype into a tokentype on the parens isn't catching all the cases it used to.
This isn't really my area - any idea why this might be?

I did some debugging (see D88952) and should have a fix shortly.

Sorry to be really late here, but this patch regressed some macro definitions like:

#define lambda [](const decltype(x) &ptr) {}

which now formats as

#define lambda [](const decltype(x) & ptr) {}

(extra space around ampersand)

It looks like the generalization of decltype into a tokentype on the parens isn't catching all the cases it used to.
This isn't really my area - any idea why this might be?

I did some debugging (see D88952) and should have a fix shortly.

D88956 should fix this.