I = CommentsBeforeNextToken.begin(),
E = CommentsBeforeNextToken.end();
I != E; ++I) {
- if (I->HasUnescapedNewline && JustComments) {
+ if (I->NewlinesBefore && JustComments) {
addUnwrappedLine();
}
pushToken(*I);
void UnwrappedLineParser::nextToken() {
if (eof())
return;
- flushComments(FormatTok.HasUnescapedNewline);
+ flushComments(FormatTok.NewlinesBefore > 0);
pushToken(FormatTok);
readToken();
}
}
if (!FormatTok.Tok.is(tok::comment))
return;
- if (FormatTok.HasUnescapedNewline || FormatTok.IsFirst) {
+ if (FormatTok.NewlinesBefore > 0 || FormatTok.IsFirst) {
CommentsInCurrentLine = false;
}
if (CommentsInCurrentLine) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaa;"));
}
+TEST_F(FormatTest, BlockCommentsInMacros) {
+ EXPECT_EQ("#define A \\\n"
+ " { \\\n"
+ " /* one line */ \\\n"
+ " someCall();",
+ format("#define A { \\\n"
+ " /* one line */ \\\n"
+ " someCall();", getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("#define A \\\n"
+ " { \\\n"
+ " /* previous */ \\\n"
+ " /* one line */ \\\n"
+ " someCall();",
+ format("#define A { \\\n"
+ " /* previous */ \\\n"
+ " /* one line */ \\\n"
+ " someCall();", getLLVMStyleWithColumns(20)));
+}
+
+TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
+ // FIXME: This is not what we want...
+ verifyFormat("{\n"
+ "// a"
+ "// b");
+}
+
TEST_F(FormatTest, FormatStarDependingOnContext) {
verifyFormat("void f(int *a);");
verifyFormat("void f() { f(fint * b); }");