[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing...
authorMarek Kurdej <marek.kurdej+llvm.org@gmail.com>
Wed, 13 Apr 2022 12:06:57 +0000 (14:06 +0200)
committerMarek Kurdej <marek.kurdej+llvm.org@gmail.com>
Mon, 9 May 2022 08:59:33 +0000 (10:59 +0200)
commit50cd52d9357224cce66a9e00c9a0417c658a5655
treee36d451d715c41b703e2f2263f088b617b94a019
parent02f8519502447de6ef69a85fa8de5732dd59d853
[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

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

This fixes regression introduced in https://github.com/llvm/llvm-project/commit/5e5efd8a91f2e340e79a73bedbc6ab66ad4a4281.

Before the culprit commit, macros in WhitespaceSensitiveMacros were correctly formatted even if their closing parenthesis weren't followed by semicolon (or, to be precise, when they were followed by a newline).
That commit changed the type of the macro token type from TT_UntouchableMacroFunc to TT_FunctionLikeOrFreestandingMacro.

Correct formatting (with `WhitespaceSensitiveMacros = ['FOO']`):
```
FOO(1+2)
FOO(1+2);
```

Regressed formatting:
```
FOO(1 + 2)
FOO(1+2);
```

Reviewed By: HazardyKnusperkeks, owenpan, ksyx

Differential Revision: https://reviews.llvm.org/D123676
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp