[clang] c5755f4 - [clang-format] Handle unions like structs and classes

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 24 12:28:21 PDT 2022


Author: Björn Schäpers
Date: 2022-10-24T21:28:12+02:00
New Revision: c5755f44f0cfcd90aa130497eb114f94182ebc69

URL: https://github.com/llvm/llvm-project/commit/c5755f44f0cfcd90aa130497eb114f94182ebc69
DIFF: https://github.com/llvm/llvm-project/commit/c5755f44f0cfcd90aa130497eb114f94182ebc69.diff

LOG: [clang-format] Handle unions like structs and classes

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

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 076ceb72dd33..944bea5f1a7f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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;


        


More information about the cfe-commits mailing list