This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Don't wrap struct return types as structs
ClosedPublic

Authored by rymiel on Mar 17 2023, 3:30 AM.

Details

Summary

When using BraceWrapping.AfterClass or BraceWrapping.AfterStruct, the
token annotator relies on the first token of the line to determine if
we're dealing with a struct or class, however, this check is faulty if
it's actually a function with an elaborated struct/class return type, as
is common in C.

This patch skips the check if the brace is already annotated as
FunctionLBrace, in which case we already know it's a function and should
be treated as such.

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

Diff Detail

Event Timeline

rymiel created this revision.Mar 17 2023, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:30 AM
rymiel requested review of this revision.Mar 17 2023, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan accepted this revision.Mar 19 2023, 2:53 AM
This revision is now accepted and ready to land.Mar 19 2023, 2:53 AM
This revision was landed with ongoing or failed builds.Mar 25 2023, 6:42 PM
This revision was automatically updated to reflect the committed changes.