[clang-format] Fix C# nullable-related errors
authorEliza Velasquez <exv@google.com>
Thu, 6 May 2021 10:06:00 +0000 (12:06 +0200)
committerMarek Kurdej <marek.kurdej+llvm.org@gmail.com>
Thu, 6 May 2021 10:11:15 +0000 (12:11 +0200)
commitec725b307f3fdc5656459047bab6e69669d9534f
tree8d93bc2541a6038bc0c9f005e231ff836deefc47
parenta437befa8f8580b3b4f2226b208a05da078c8b20
[clang-format] Fix C# nullable-related errors

This fixes two errors:

Previously, clang-format was splitting up type identifiers from the
nullable ?. This changes this behavior so that the type name sticks with
the operator.

Additionally, nullable operators attached to return types in interface
functions were not parsed correctly. Digging deeper, it looks like
interface bodies were being parsed differently than classes and structs,
causing MustBeDeclaration to be incorrect for interface members. They
now share the same logic.

One other change is reintroducing the CSharpNullable type independent of
JsTypeOptionalQuestion. Despite having a similar semantic purpose, their
actual syntax differs quite a bit.

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D101860
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTestCSharp.cpp