This is an archive of the discontinued LLVM Phabricator instance.

[clan-format] detect function definitions more conservatively
ClosedPublic

Authored by krasimir on Aug 2 2021, 6:01 AM.

Details

Summary

https://reviews.llvm.org/D105964 updated the detection of function
definitions. It had the unfortunate effect to start marking object
definitions with attribute-like macros as function definitions.

This addresses this issue.

Diff Detail

Event Timeline

krasimir requested review of this revision.Aug 2 2021, 6:01 AM
krasimir created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2021, 6:01 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan added inline comments.Aug 3 2021, 1:36 AM
clang/lib/Format/TokenAnnotator.cpp
2485–2486

I was contemplating the above in https://reviews.llvm.org/D105964 and should have used it instead. This is probably more conservative and accurate than checking for an l_brace following the r_paren.

krasimir updated this revision to Diff 363669.Aug 3 2021, 2:52 AM
  • apply review suggestion
krasimir added inline comments.Aug 3 2021, 2:55 AM
clang/lib/Format/TokenAnnotator.cpp
2485–2486

Thank you!

Applied the suggestion. I was a bit worried that this suggestion won't work for function definitions with a trailing semicolon, but there the semicolon is not part of the same line as the function name, so all is good there. Added a few tests for this case.

owenpan accepted this revision.Aug 3 2021, 4:13 AM

LGTM

This revision is now accepted and ready to land.Aug 3 2021, 4:13 AM
owenpan added a project: Restricted Project.Aug 12 2021, 1:48 PM