Reformat clang-formats source code.
All changes done by clang-format itself. No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171732 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h
index f8ec26a..32bb53c 100644
--- a/include/clang/Format/Format.h
+++ b/include/clang/Format/Format.h
@@ -78,7 +78,7 @@
SourceManager &SourceMgr,
std::vector<CharSourceRange> Ranges);
-} // end namespace format
-} // end namespace clang
+} // end namespace format
+} // end namespace clang
-#endif // LLVM_CLANG_FORMAT_FORMAT_H
+#endif // LLVM_CLANG_FORMAT_FORMAT_H
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 471021a..4a34ad8 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -263,7 +263,7 @@
// constructs.
State.Column = Line.Level * 2 + 2;
} else if (Current.Tok.is(tok::string_literal) &&
- Previous.Tok.is(tok::string_literal)) {
+ Previous.Tok.is(tok::string_literal)) {
State.Column = State.Column - Previous.TokenLength;
} else if (Current.Tok.is(tok::lessless) &&
State.FirstLessLess[ParenLevel] != 0) {
@@ -484,17 +484,17 @@
unsigned Spaces, unsigned WhitespaceStartColumn) {
std::string NewLineText;
if (NewLines > 0) {
- unsigned Offset =
- std::min<int>(Style.ColumnLimit - 1, WhitespaceStartColumn);
+ unsigned Offset = std::min<int>(Style.ColumnLimit - 1,
+ WhitespaceStartColumn);
for (unsigned i = 0; i < NewLines; ++i) {
NewLineText += std::string(Style.ColumnLimit - Offset - 1, ' ');
NewLineText += "\\\n";
Offset = 0;
}
}
- Replaces.insert(tooling::Replacement(
- SourceMgr, Tok.WhiteSpaceStart, Tok.WhiteSpaceLength,
- NewLineText + std::string(Spaces, ' ')));
+ Replaces.insert(tooling::Replacement(SourceMgr, Tok.WhiteSpaceStart,
+ Tok.WhiteSpaceLength, NewLineText +
+ std::string(Spaces, ' ')));
}
/// \brief Add a new line and the required indent before the first Token
@@ -505,8 +505,8 @@
if (!Token.WhiteSpaceStart.isValid() || StructuralError)
return SourceMgr.getSpellingColumnNumber(Token.Tok.getLocation()) - 1;
- unsigned Newlines =
- std::min(Token.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
+ unsigned Newlines = std::min(Token.NewlinesBefore,
+ Style.MaxEmptyLinesToKeep + 1);
if (Newlines == 0 && !Token.IsFirst)
Newlines = 1;
unsigned Indent = Line.Level * 2;
@@ -1084,8 +1084,8 @@
// Consume and record whitespace until we find a significant token.
while (FormatTok.Tok.is(tok::unknown)) {
FormatTok.NewlinesBefore += Text.count('\n');
- FormatTok.HasUnescapedNewline =
- Text.count("\\\n") != FormatTok.NewlinesBefore;
+ FormatTok.HasUnescapedNewline = Text.count("\\\n") !=
+ FormatTok.NewlinesBefore;
FormatTok.WhiteSpaceLength += FormatTok.Tok.getLength();
if (FormatTok.Tok.is(tok::eof))
@@ -1157,8 +1157,8 @@
for (std::vector<UnwrappedLine>::iterator I = UnwrappedLines.begin(),
E = UnwrappedLines.end();
I != E; ++I)
- PreviousEndOfLineColumn =
- formatUnwrappedLine(*I, PreviousEndOfLineColumn);
+ PreviousEndOfLineColumn = formatUnwrappedLine(*I,
+ PreviousEndOfLineColumn);
return Replaces;
}
@@ -1170,11 +1170,11 @@
unsigned formatUnwrappedLine(const UnwrappedLine &TheLine,
unsigned PreviousEndOfLineColumn) {
if (TheLine.Tokens.empty())
- return 0; // FIXME: Find out how this can ever happen.
+ return 0; // FIXME: Find out how this can ever happen.
- CharSourceRange LineRange =
- CharSourceRange::getTokenRange(TheLine.Tokens.front().Tok.getLocation(),
- TheLine.Tokens.back().Tok.getLocation());
+ CharSourceRange LineRange = CharSourceRange::getTokenRange(
+ TheLine.Tokens.front().Tok.getLocation(),
+ TheLine.Tokens.back().Tok.getLocation());
for (unsigned i = 0, e = Ranges.size(); i != e; ++i) {
if (SourceMgr.isBeforeInTranslationUnit(LineRange.getEnd(),
@@ -1218,5 +1218,5 @@
return formatter.format();
}
-} // namespace format
-} // namespace clang
+} // namespace format
+} // namespace clang
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 4066b55..52717e1 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -493,5 +493,5 @@
}
}
-} // end namespace format
-} // end namespace clang
+} // end namespace format
+} // end namespace clang
diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h
index 59844e4..c3adc4c 100644
--- a/lib/Format/UnwrappedLineParser.h
+++ b/lib/Format/UnwrappedLineParser.h
@@ -144,7 +144,7 @@
UnwrappedLineConsumer &Callback;
};
-} // end namespace format
-} // end namespace clang
+} // end namespace format
+} // end namespace clang
-#endif // LLVM_CLANG_FORMAT_UNWRAPPED_LINE_PARSER_H
+#endif // LLVM_CLANG_FORMAT_UNWRAPPED_LINE_PARSER_H
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d9ad620..2d6a142 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -30,8 +30,8 @@
LangOpts.CPlusPlus = 1;
LangOpts.CPlusPlus11 = 1;
Lexer Lex(ID, Context.Sources.getBuffer(ID), Context.Sources, LangOpts);
- tooling::Replacements Replace =
- reformat(Style, Lex, Context.Sources, Ranges);
+ tooling::Replacements Replace = reformat(Style, Lex, Context.Sources,
+ Ranges);
EXPECT_TRUE(applyAllReplacements(Replace, Context.Rewrite));
return Context.getRewrittenText(ID);
}
@@ -110,7 +110,6 @@
verifyFormat("Method(f1(f2, f3()));");
}
-
//===----------------------------------------------------------------------===//
// Tests for control statements.
//===----------------------------------------------------------------------===//
@@ -264,7 +263,6 @@
"some_other_code();");
}
-
//===----------------------------------------------------------------------===//
// Tests for comments.
//===----------------------------------------------------------------------===//
@@ -301,7 +299,6 @@
verifyFormat("f(/*test=*/ true);");
}
-
//===----------------------------------------------------------------------===//
// Tests for classes, namespaces, etc.
//===----------------------------------------------------------------------===//
@@ -395,9 +392,8 @@
}
TEST_F(FormatTest, DoesNotBreakPureVirtualFunctionDefinition) {
- verifyFormat(
- "virtual void write(ELFWriter *writerrr,\n"
- " OwningPtr<FileOutputBuffer> &buffer) = 0;");
+ verifyFormat("virtual void write(ELFWriter *writerrr,\n"
+ " OwningPtr<FileOutputBuffer> &buffer) = 0;");
}
TEST_F(FormatTest, BreaksOnHashWhenDirectiveIsInvalid) {
@@ -496,9 +492,9 @@
}
TEST_F(FormatTest, EscapedNewlineAtStartOfTokenInMacroDefinition) {
- EXPECT_EQ("#define A \\\n int i; \\\n int j;",
- format("#define A \\\nint i;\\\n int j;",
- getLLVMStyleWithColumns(11)));
+ EXPECT_EQ(
+ "#define A \\\n int i; \\\n int j;",
+ format("#define A \\\nint i;\\\n int j;", getLLVMStyleWithColumns(11)));
}
TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) {
@@ -618,24 +614,21 @@
" aaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n"
" (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
- verifyFormat(
- "{\n {\n {\n"
- " Annotation.SpaceRequiredBefore =\n"
- " Line.Tokens[i - 1].Tok.isNot(tok::l_paren) &&\n"
- " Line.Tokens[i - 1].Tok.isNot(tok::l_square);\n"
- " }\n }\n}");
+ verifyFormat("{\n {\n {\n"
+ " Annotation.SpaceRequiredBefore =\n"
+ " Line.Tokens[i - 1].Tok.isNot(tok::l_paren) &&\n"
+ " Line.Tokens[i - 1].Tok.isNot(tok::l_square);\n"
+ " }\n }\n}");
}
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
verifyFormat(
"if (aaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
" bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) {\n}");
- verifyFormat(
- "if (aaaaaaaaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbbbbbbbb ||\n"
- " ccccccccccccccccccccccccc) {\n}");
- verifyFormat(
- "if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb ||\n"
- " ccccccccccccccccccccccccc) {\n}");
+ verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbbbbbbbb ||\n"
+ " ccccccccccccccccccccccccc) {\n}");
+ verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb ||\n"
+ " ccccccccccccccccccccccccc) {\n}");
verifyFormat(
"if ((aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb) &&\n"
" ccccccccccccccccccccccccc) {\n}");
@@ -898,9 +891,8 @@
}
TEST_F(FormatTest, DoesNotBreakBeforePointerOrReference) {
- verifyFormat(
- "int *someFunction(int LoooooooooooooooongParam1,\n"
- " int LoooooooooooooooongParam2) {\n}");
+ verifyFormat("int *someFunction(int LoooooooooooooooongParam1,\n"
+ " int LoooooooooooooooongParam2) {\n}");
verifyFormat(
"TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,\n"
" SourceLocation L, IdentifierIn *II,\n"
@@ -926,7 +918,6 @@
EXPECT_EQ("#import \"string.h\"\n", format("#import \"string.h\"\n"));
}
-
//===----------------------------------------------------------------------===//
// Error recovery tests.
//===----------------------------------------------------------------------===//
@@ -998,8 +989,7 @@
verifyFormat("- (void)sendAction:(SEL)aSelector to:(BOOL)anObject;");
EXPECT_EQ("- (NSUInteger)indexOfObject:(id)anObject;",
format("-(NSUInteger)indexOfObject:(id)anObject;"));
- EXPECT_EQ("- (NSInteger)Mthod1;",
- format("-(NSInteger)Mthod1;"));
+ EXPECT_EQ("- (NSInteger)Mthod1;", format("-(NSInteger)Mthod1;"));
EXPECT_EQ("+ (id)Mthod2;", format("+(id)Mthod2;"));
EXPECT_EQ("- (NSInteger)Method3:(id)anObject;",
format("-(NSInteger)Method3:(id)anObject;"));
@@ -1009,24 +999,26 @@
format("-(NSInteger)Method5:(id)anObject:(id)AnotherObject;"));
EXPECT_EQ("- (id)Method6:(id)A:(id)B:(id)C:(id)D;",
format("- (id)Method6:(id)A:(id)B:(id)C:(id)D;"));
- EXPECT_EQ("- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;",
- format("- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;"));
+ EXPECT_EQ(
+ "- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;",
+ format("- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;"));
// Very long objectiveC method declaration.
- EXPECT_EQ("- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range\n "
- "outRange:(NSRange)out_range outRange1:(NSRange)out_range1\n "
- "outRange2:(NSRange)out_range2 outRange3:(NSRange)out_range3\n "
- "outRange4:(NSRange)out_range4 outRange5:(NSRange)out_range5\n "
- "outRange6:(NSRange)out_range6 outRange7:(NSRange)out_range7\n "
- "outRange8:(NSRange)out_range8 outRange9:(NSRange)out_range9;",
-
- format("- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range "
- "outRange:(NSRange) out_range outRange1:(NSRange) out_range1 "
- "outRange2:(NSRange) out_range2 outRange3:(NSRange) out_range3 "
- "outRange4:(NSRange) out_range4 outRange5:(NSRange) out_range5 "
- "outRange6:(NSRange) out_range6 outRange7:(NSRange) out_range7 "
- "outRange8:(NSRange) out_range8 outRange9:(NSRange) out_range9;"));
+ EXPECT_EQ(
+ "- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range\n "
+ "outRange:(NSRange)out_range outRange1:(NSRange)out_range1\n "
+ "outRange2:(NSRange)out_range2 outRange3:(NSRange)out_range3\n "
+ "outRange4:(NSRange)out_range4 outRange5:(NSRange)out_range5\n "
+ "outRange6:(NSRange)out_range6 outRange7:(NSRange)out_range7\n "
+ "outRange8:(NSRange)out_range8 outRange9:(NSRange)out_range9;",
+ format(
+ "- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range "
+ "outRange:(NSRange) out_range outRange1:(NSRange) out_range1 "
+ "outRange2:(NSRange) out_range2 outRange3:(NSRange) out_range3 "
+ "outRange4:(NSRange) out_range4 outRange5:(NSRange) out_range5 "
+ "outRange6:(NSRange) out_range6 outRange7:(NSRange) out_range7 "
+ "outRange8:(NSRange) out_range8 outRange9:(NSRange) out_range9;"));
}
-} // end namespace tooling
-} // end namespace clang
+} // end namespace tooling
+} // end namespace clang