[clang] [clang-format] Refactor case and goto label parsing (PR #196815)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 16 00:22:23 PDT 2026
================
@@ -1714,9 +1714,32 @@ void UnwrappedLineParser::parseStructuralElement(
if (!Line->InMacroBody || CurrentLines->size() > 1)
Line->Tokens.begin()->Tok->MustBreakBefore = true;
FormatTok->setFinalizedType(TT_GotoLabelColon);
- parseLabel(Style.IndentGotoLabels);
+ const auto OldLineLevel = Line->Level;
+ switch (Style.IndentGotoLabels) {
+ case FormatStyle::IGLS_NoIndent:
+ Line->Level = 0;
+ break;
+ case FormatStyle::IGLS_OuterIndent:
+ if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0))
+ --Line->Level;
----------------
owenca wrote:
Duplicate code from `parseCaseLabel`.
https://github.com/llvm/llvm-project/pull/196815
More information about the cfe-commits
mailing list