Remove whitespace at end of file.
This fixes the rest of llvm.org/PR15062. llvm-svn: 176361
This commit is contained in:
parent
66fd4b1ab9
commit
a79064a88f
|
@ -1132,7 +1132,15 @@ public:
|
|||
IndentForLevel.resize(TheLine.Level + 1);
|
||||
bool WasMoved =
|
||||
PreviousLineWasTouched && TheLine.First.FormatTok.NewlinesBefore == 0;
|
||||
if (TheLine.Type != LT_Invalid && (WasMoved || touchesRanges(TheLine))) {
|
||||
if (TheLine.First.is(tok::eof)) {
|
||||
if (PreviousLineWasTouched) {
|
||||
unsigned NewLines =
|
||||
std::min(TheLine.First.FormatTok.NewlinesBefore, 1u);
|
||||
Whitespaces.replaceWhitespace(TheLine.First, NewLines, /*Indent*/ 0,
|
||||
/*WhitespaceStartColumn*/ 0, Style);
|
||||
}
|
||||
} else if (TheLine.Type != LT_Invalid &&
|
||||
(WasMoved || touchesRanges(TheLine))) {
|
||||
unsigned LevelIndent = getIndent(IndentForLevel, TheLine.Level);
|
||||
unsigned Indent = LevelIndent;
|
||||
if (static_cast<int>(Indent) + Offset >= 0)
|
||||
|
|
|
@ -138,6 +138,11 @@ bool UnwrappedLineParser::parse() {
|
|||
I != E; ++I) {
|
||||
Callback.consumeUnwrappedLine(*I);
|
||||
}
|
||||
|
||||
// Create line with eof token.
|
||||
pushToken(FormatTok);
|
||||
Callback.consumeUnwrappedLine(*Line);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
@ -776,14 +781,14 @@ void UnwrappedLineParser::addUnwrappedLine() {
|
|||
CurrentLines->push_back(*Line);
|
||||
Line->Tokens.clear();
|
||||
if (CurrentLines == &Lines && !PreprocessorDirectives.empty()) {
|
||||
for (std::vector<UnwrappedLine>::iterator I = PreprocessorDirectives
|
||||
.begin(), E = PreprocessorDirectives.end();
|
||||
for (std::vector<UnwrappedLine>::iterator
|
||||
I = PreprocessorDirectives.begin(),
|
||||
E = PreprocessorDirectives.end();
|
||||
I != E; ++I) {
|
||||
CurrentLines->push_back(*I);
|
||||
}
|
||||
PreprocessorDirectives.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool UnwrappedLineParser::eof() const {
|
||||
|
|
|
@ -166,6 +166,10 @@ TEST_F(FormatTest, OnlyGeneratesNecessaryReplacements) {
|
|||
|
||||
TEST_F(FormatTest, RemovesTrailingWhitespaceOfFormattedLine) {
|
||||
EXPECT_EQ("int a;\nint b;", format("int a; \nint b;", 0, 0, getLLVMStyle()));
|
||||
EXPECT_EQ("int a;", format("int a; "));
|
||||
EXPECT_EQ("int a;\n", format("int a; \n \n \n "));
|
||||
EXPECT_EQ("int a;\nint b; ",
|
||||
format("int a; \nint b; ", 0, 0, getLLVMStyle()));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, ReformatsMovedLines) {
|
||||
|
|
Loading…
Reference in New Issue