[clang-format] Properly handle the C11 _Generic keyword.
This patch properly recognizes the generic selection expression introduced in C11, by adding an additional token type for the colons present in such expressions. Previously, they would be recognized as "inline ASM colons" purely by the fact that those are the last thing checked for. I tried to avoid adding an addition token type, but since colons by default like having spaces around them, I chose to add a new type so that no space is added after the type selector. Currently, no aspect of the formatting of these expressions in able to be configured, as I'm not sure what could even be configured here. One notable thing is that association list is always formatted as either entirely on one line, if it can fit, or with line breaks after every comma in the expression (also after the controlling expr.) This visually makes them more similar to switch statements when long, matching the behaviour of the selection expression, being that of a sort of switch on types, but also allows for terseness when only selecting for a few things. Fixes https://github.com/llvm/llvm-project/issues/18080 Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D139211
Loading
Please sign in to comment