The argument passed to the preprocessor macros NS_SWIFT_NAME(x) and
CF_SWIFT_NAME(x) is stringified before passing to
__attribute__((swift_name("x"))).
ClangFormat didn't know about this stringification, so its custom parser
tried to parse the argument(s) passed to the macro as if they were
normal function arguments.
That means ClangFormat currently incorrectly inserts whitespace
between NS_SWIFT_NAME arguments with colons and dots, so:
extern UIWindow *MainWindow(void) NS_SWIFT_NAME(getter:MyHelper.mainWindow());
becomes:
extern UIWindow *MainWindow(void) NS_SWIFT_NAME(getter : MyHelper.mainWindow());
which clang treats as a parser error:
error: 'swift_name' attribute has invalid identifier for context name [-Werror,-Wswift-name-attribute]
Thankfully, D82620 recently added the ability to treat specific macros
as "whitespace sensitive", meaning their arguments are implicitly
treated as strings (so whitespace is not added anywhere inside).
This diff adds NS_SWIFT_NAME and CF_SWIFT_NAME to
WhitespaceSensitiveMacros so their arguments are implicitly treated
as whitespace-sensitive.
Test Plan:
New tests added. Ran tests with: % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests