[cfe-commits] r171732 - in /cfe/trunk: include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/UnwrappedLineParser.h unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Mon Jan 7 05:26:07 PST 2013
Author: djasper
Date: Mon Jan 7 07:26:07 2013
New Revision: 171732
URL: http://llvm.org/viewvc/llvm-project?rev=171732&view=rev
Log:
Reformat clang-formats source code.
All changes done by clang-format itself. No functional changes.
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/include/clang/Format/Format.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=171732&r1=171731&r2=171732&view=diff
==============================================================================
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Jan 7 07:26:07 2013
@@ -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
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=171732&r1=171731&r2=171732&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jan 7 07:26:07 2013
@@ -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
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=171732&r1=171731&r2=171732&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jan 7 07:26:07 2013
@@ -493,5 +493,5 @@
}
}
-} // end namespace format
-} // end namespace clang
+} // end namespace format
+} // end namespace clang
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=171732&r1=171731&r2=171732&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h Mon Jan 7 07:26:07 2013
@@ -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
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=171732&r1=171731&r2=171732&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 7 07:26:07 2013
@@ -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
More information about the cfe-commits
mailing list