[clang-format] Handle unions like structs and classes
authorBjörn Schäpers <bjoern@hazardy.de>
Tue, 11 Oct 2022 07:04:28 +0000 (09:04 +0200)
committerBjörn Schäpers <bjoern@hazardy.de>
Mon, 24 Oct 2022 19:28:12 +0000 (21:28 +0200)
There is no reason why unions should be handled differently, I think
they are just forgotten since they are not used that often.

No test case added, since that would be complicated to produce.

Differential Revision: https://reviews.llvm.org/D135872

clang/lib/Format/TokenAnnotator.cpp

index 076ceb7..944bea5 100644 (file)
@@ -3157,7 +3157,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     return 160;
   if (Left.is(TT_CastRParen))
     return 100;
-  if (Left.isOneOf(tok::kw_class, tok::kw_struct))
+  if (Left.isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union))
     return 5000;
   if (Left.is(tok::comment))
     return 1000;