forked from OSchip/llvm-project
clang-format: Fix incorrect handling of leading whitespace.
Added an assertion that triggered in an existing test case (without observable differences) and fixed the code. llvm-svn: 227677
This commit is contained in:
parent
9fee8ab4f9
commit
30526e79e8
|
@ -245,12 +245,18 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline,
|
||||||
(Current.Previous->Tok.getIdentifierInfo() == nullptr ||
|
(Current.Previous->Tok.getIdentifierInfo() == nullptr ||
|
||||||
Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() ==
|
Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() ==
|
||||||
tok::pp_not_keyword))) {
|
tok::pp_not_keyword))) {
|
||||||
// FIXME: Is this correct?
|
unsigned EndColumn =
|
||||||
int WhitespaceLength = SourceMgr.getSpellingColumnNumber(
|
SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getEnd());
|
||||||
State.NextToken->WhitespaceRange.getEnd()) -
|
if (Current.LastNewlineOffset != 0) {
|
||||||
SourceMgr.getSpellingColumnNumber(
|
// If there is a newline within this token, the final column will solely
|
||||||
State.NextToken->WhitespaceRange.getBegin());
|
// determined by the current end column.
|
||||||
State.Column += WhitespaceLength;
|
State.Column = EndColumn;
|
||||||
|
} else {
|
||||||
|
unsigned StartColumn =
|
||||||
|
SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getBegin());
|
||||||
|
assert(EndColumn >= StartColumn);
|
||||||
|
State.Column += EndColumn - StartColumn;
|
||||||
|
}
|
||||||
moveStateToNextToken(State, DryRun, /*Newline=*/false);
|
moveStateToNextToken(State, DryRun, /*Newline=*/false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue