This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix QualifierOrder breaking the code with requires clause.
ClosedPublic

Authored by curdeius on Feb 22 2022, 1:02 AM.

Details

Summary

Fixes https://github.com/llvm/llvm-project/issues/53962.

Given the config:

BasedOnStyle: LLVM
QualifierAlignment: Custom
QualifierOrder: ['constexpr', 'type']

The code:

template <typename F>
  requires std::invocable<F>
constexpr constructor();

was incorrectly formatted to:

template <typename F>
  requires 
constexpr std::invocable<F> constructor();

because we considered std::invocable<F> constexpr as a type, not recognising the requires clause.

This patch avoids moving the qualifier across the boundary of the requires clause (checking ClosesRequiresClause).

Diff Detail

Event Timeline

curdeius requested review of this revision.Feb 22 2022, 1:02 AM
curdeius created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 1:02 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan accepted this revision.Feb 22 2022, 1:12 AM
This revision is now accepted and ready to land.Feb 22 2022, 1:12 AM

Does it work with a more complex requires clause? Or were they unaffected before? Like Foo<T> && Bar<T>?

Does it work with a more complex requires clause? Or were they unaffected before? Like Foo<T> && Bar<T>?

They were unaffected but I'll add a test.

curdeius updated this revision to Diff 410618.Feb 22 2022, 12:57 PM

Add a test.

This revision was landed with ongoing or failed builds.Feb 24 2022, 1:16 AM
This revision was automatically updated to reflect the committed changes.