diff options
author | Daniel Jasper <djasper@google.com> | 2014-12-12 09:40:58 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-12-12 09:40:58 +0000 |
commit | 11a0ac66e10658f9eec87db0e846f6f5eaafc9cf (patch) | |
tree | 762746194ec8f9c799b260bea96a55d2f67a9930 /clang/lib/Format/ContinuationIndenter.h | |
parent | 9e3a60769fe93241ee1bcdd711a1d38b014c15a6 (diff) | |
download | bcm5719-llvm-11a0ac66e10658f9eec87db0e846f6f5eaafc9cf.tar.gz bcm5719-llvm-11a0ac66e10658f9eec87db0e846f6f5eaafc9cf.zip |
clang-format: Revamp nested block formatting.
This fixed llvm.org/PR21804 and hopefully a few other strange cases.
Before:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
After:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
llvm-svn: 224112
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.h')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.h b/clang/lib/Format/ContinuationIndenter.h index 004ddebac4a..36691d945b4 100644 --- a/clang/lib/Format/ContinuationIndenter.h +++ b/clang/lib/Format/ContinuationIndenter.h @@ -148,7 +148,8 @@ struct ParenState { ParenState(unsigned Indent, unsigned IndentLevel, unsigned LastSpace, bool AvoidBinPacking, bool NoLineBreak) : Indent(Indent), IndentLevel(IndentLevel), LastSpace(LastSpace), - FirstLessLess(0), BreakBeforeClosingBrace(false), QuestionColumn(0), + NestedBlockIndent(Indent), FirstLessLess(0), + BreakBeforeClosingBrace(false), QuestionColumn(0), AvoidBinPacking(AvoidBinPacking), BreakBeforeParameter(false), NoLineBreak(NoLineBreak), LastOperatorWrapped(true), ColonPos(0), StartOfFunctionCall(0), StartOfArraySubscripts(0), @@ -171,6 +172,10 @@ struct ParenState { /// OtherParameter)); unsigned LastSpace; + /// \brief If a block relative to this parenthesis level gets wrapped, indent + /// it this much. + unsigned NestedBlockIndent; + /// \brief The position the first "<<" operator encountered on each level. /// /// Used to align "<<" operators. 0 if no such operator has been encountered @@ -265,6 +270,8 @@ struct ParenState { return Indent < Other.Indent; if (LastSpace != Other.LastSpace) return LastSpace < Other.LastSpace; + if (NestedBlockIndent != Other.NestedBlockIndent) + return NestedBlockIndent < Other.NestedBlockIndent; if (FirstLessLess != Other.FirstLessLess) return FirstLessLess < Other.FirstLessLess; if (BreakBeforeClosingBrace != Other.BreakBeforeClosingBrace) |