diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.h | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 90745b6e0a6..81fdab4ed70 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -453,6 +453,7 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("IncludeCategories", Style.IncludeStyle.IncludeCategories); IO.mapOptional("IncludeIsMainRegex", Style.IncludeStyle.IncludeIsMainRegex); IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels); + IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels); IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives); IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("IndentWrappedFunctionNames", @@ -725,6 +726,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.IncludeStyle.IncludeIsMainRegex = "(Test)?$"; LLVMStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve; LLVMStyle.IndentCaseLabels = false; + LLVMStyle.IndentGotoLabels = true; LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None; LLVMStyle.IndentWrappedFunctionNames = false; LLVMStyle.IndentWidth = 2; diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index bbb243dd329..e552a055b04 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1351,7 +1351,7 @@ void UnwrappedLineParser::parseStructuralElement() { (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) { if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) { Line->Tokens.begin()->Tok->MustBreakBefore = true; - parseLabel(); + parseLabel(!Style.IndentGotoLabels); return; } // Recognize function-like macro usages without trailing semicolon as @@ -1970,11 +1970,13 @@ void UnwrappedLineParser::parseDoWhile() { parseStructuralElement(); } -void UnwrappedLineParser::parseLabel() { +void UnwrappedLineParser::parseLabel(bool LeftAlignLabel) { nextToken(); unsigned OldLineLevel = Line->Level; if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0)) --Line->Level; + if (LeftAlignLabel) + Line->Level = 0; if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) { CompoundStatementIndenter Indenter(this, Line->Level, Style.BraceWrapping.AfterCaseLabel, diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index e1b35317c7c..5d9bafc429a 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -106,7 +106,7 @@ private: void parseTryCatch(); void parseForOrWhileLoop(); void parseDoWhile(); - void parseLabel(); + void parseLabel(bool LeftAlignLabel = false); void parseCaseLabel(); void parseSwitch(); void parseNamespace(); |