[clang-format] Don't put `noexcept` on empty line following constructor
authorEmilia Dreamer <emilia@rymiel.space>
Mon, 5 Sep 2022 10:19:31 +0000 (12:19 +0200)
committerBjörn Schäpers <bjoern@hazardy.de>
Mon, 5 Sep 2022 10:35:39 +0000 (12:35 +0200)
commitf54d42abcf82e122ed0ac4688f01c1f4da5599f2
tree7c48dea76a84c275529db67d66aab2d32ed6a13a
parent84c4efbc6d61ec2bed9e9bc64b5829b4487b210c
[clang-format] Don't put `noexcept` on empty line following constructor

With the AlwaysBreakTemplateDeclarations option, having a constructor
template for a type consisting of all-uppercase letters with a
noexcept specifier would put said noexcept specifier on its own blank
line.

This is because the all-uppercase type is understood as a macro-like
attribute (such as DEPRECATED()), and noexcept is seen as the
declaration. However, noexcept is a keyword and cannot be an
identifier on its own.

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

Differential Revision: https://reviews.llvm.org/D132189
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp