Fix handling of fake parenthesis during formatting.

They are much easier to handle when attached to the previous token.

Before:
unsigned Indent =
    formatFirstToken(TheLine.First, IndentForLevel[TheLine.Level] >=
                                    0 ? IndentForLevel[TheLine.Level]
: TheLine.Level * 2, TheLine.InPPDirective, PreviousEndOfLineColumn);

After:
unsigned Indent = formatFirstToken(
    TheLine.First, IndentForLevel[TheLine.Level] >= 0
                       ? IndentForLevel[TheLine.Level] : TheLine.Level * 2,
    TheLine.InPPDirective, PreviousEndOfLineColumn);

llvm-svn: 174718
This commit is contained in:
Daniel Jasper 2013-02-08 16:49:27 +00:00
parent a6016e4351
commit 8360a86c8c
3 changed files with 7 additions and 2 deletions

View File

@ -722,7 +722,7 @@ public:
if (OperatorFound) {
++Start->FakeLParens;
if (Current != NULL)
++Current->FakeRParens;
++Current->Parent->FakeRParens;
}
return;
}

View File

@ -121,7 +121,7 @@ public:
/// \brief Insert this many fake ( before this token for correct indentation.
unsigned FakeLParens;
/// \brief Insert this many fake ) before this token for correct indentation.
/// \brief Insert this many fake ) after this token for correct indentation.
unsigned FakeRParens;
const AnnotatedToken *getPreviousNoneComment() const {

View File

@ -1271,6 +1271,11 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat(
"unsigned Indent = formatFirstToken(\n"
" TheLine.First, IndentForLevel[TheLine.Level] >= 0\n"
" ? IndentForLevel[TheLine.Level] : TheLine * 2,\n"
" TheLine.InPPDirective, PreviousEndOfLineColumn);");
}
TEST_F(FormatTest, DeclarationsOfMultipleVariables) {