This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Annotate noexcept, explicit specifiers as containing expressions
ClosedPublic

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

Details

Summary

The noexcept specifier and explicit specifier can optionally include a
boolean expression to make these specifiers apply conditionally,
however, clang-format didn't set the context for the parenthesized
content of these specifiers, meaning they inherited the parent context,
which usually isn't an expressions, leading to misannotated binary
operators.

This patch applies expression context to the content of these
specifiers, making them similar to the static_assert keyword.

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

Diff Detail

Event Timeline

rymiel created this revision.Mar 17 2023, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:58 AM
rymiel requested review of this revision.Mar 17 2023, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:58 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Should we add tests to TokenAnnotatorTest.cpp?

Yes, good point, I will do that

rymiel updated this revision to Diff 506370.Mar 19 2023, 2:57 AM

Annotator tests (copied from format tests)

owenpan accepted this revision.Mar 19 2023, 3:10 AM
This revision is now accepted and ready to land.Mar 19 2023, 3:10 AM
MyDeveloperDay accepted this revision.Mar 21 2023, 3:16 AM
This revision was landed with ongoing or failed builds.Mar 22 2023, 11:25 AM
This revision was automatically updated to reflect the committed changes.