This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Disallow requires clauses to become function declarations
ClosedPublic

Authored by rymiel on Sep 16 2022, 8:49 AM.

Details

Summary

There already exists logic to disallow requires *expressions* to be
treated as function declarations, but this expands it to include
requires *clauses*, when they happen to also be parenthesized.

Previously, in the following case:

template <typename T>
  requires(Foo<T>)
T foo();

The line with the requires clause was actually being considered as the
line with the function declaration due to the parentheses, and the
*real* function declaration on the next line became a trailing
annotation

(Together with https://reviews.llvm.org/D134049) Fixes https://github.com/llvm/llvm-project/issues/56213

Diff Detail

Event Timeline

rymiel created this revision.Sep 16 2022, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 8:49 AM
rymiel requested review of this revision.Sep 16 2022, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 8:49 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rymiel added a project: Restricted Project.Sep 16 2022, 8:50 AM
This revision is now accepted and ready to land.Sep 16 2022, 1:30 PM
owenpan accepted this revision.Sep 16 2022, 10:17 PM