Page MenuHomePhabricator

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

Authored by rymiel on Fri, Mar 17, 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.Fri, Mar 17, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Mar 17, 3:58 AM
rymiel requested review of this revision.Fri, Mar 17, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Mar 17, 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.Sun, Mar 19, 2:57 AM

Annotator tests (copied from format tests)

owenpan accepted this revision.Sun, Mar 19, 3:10 AM
This revision is now accepted and ready to land.Sun, Mar 19, 3:10 AM
MyDeveloperDay accepted this revision.Tue, Mar 21, 3:16 AM