[clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44...
authorKrasimir Georgiev <krasimir@google.com>
Tue, 22 Feb 2022 14:43:09 +0000 (15:43 +0100)
committerKrasimir Georgiev <krasimir@google.com>
Tue, 22 Feb 2022 14:43:18 +0000 (15:43 +0100)
commitc9592ae49b8c486754a745e0c7b1a30b92a12e8b
tree1e0100962754a316db83e85b11fae08c9adda93d
parentffa4dfc8de526ba28d12d62a14f984a7e1e9224b
[clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c

In https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c
by setting the identifier info to nullptr, we started to subtly
interfere with the parts in the beginning of the function,
https://github.com/llvm/llvm-project/blob/529aa4b011c4ae808d658022ef643c44dd9b2c9c/clang/lib/Format/UnwrappedLineParser.cpp#L991
causing the preprocessor nesting to change in some cases. E.g., for the
added regression test, clang-format started incorrectly guessing the
language as C++.

This tries to address this by introducing an internal identifier info
element to use instead.

Reviewed By: curdeius, MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D120315
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp