unsigned ExtraSpaces) {
const FormatToken &Current = *State.NextToken;
- if (State.Stack.size() == 0 || Current.Type == TT_ImplicitStringLiteral) {
+ if (State.Stack.size() == 0 ||
+ (Current.Type == TT_ImplicitStringLiteral &&
+ (Current.Previous->Tok.getIdentifierInfo() == NULL ||
+ Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() ==
+ tok::pp_not_keyword))) {
// FIXME: Is this correct?
int WhitespaceLength = SourceMgr.getSpellingColumnNumber(
State.NextToken->WhitespaceRange.getEnd()) -
if (Current.Type != TT_BlockComment && Current.IsMultiline)
return addMultilineToken(Current, State);
+ // Don't break implicit string literals.
+ if (Current.Type == TT_ImplicitStringLiteral)
+ return 0;
+
if (!Current.isOneOf(tok::string_literal, tok::wide_string_literal,
tok::utf8_string_literal, tok::utf16_string_literal,
tok::utf32_string_literal, tok::comment))
Left.Previous->Type == TT_CastRParen))
return false;
}
-
+ if (Right.Type == TT_ImplicitStringLiteral)
+ return false;
if (Right.isTrailingComment())
// We rely on MustBreakBefore being set correctly here as we should not
// change the "binding" behavior of a comment.
"#include \"a/b/c\" // comment");
verifyFormat("#include <a> // comment\n"
"#include <a/b/c> // comment");
- EXPECT_EQ("#include \\\n"
- " \"a\" // comment\n"
+ EXPECT_EQ("#include \"a\" // comment\n"
"#include \"a/b/c\" // comment",
format("#include \\\n"
" \"a\" // comment\n"
"#include \"some long include\" // with a comment\n"
"#include \"some very long include paaaaaaaaaaaaaaaaaaaaaaath\"",
getLLVMStyleWithColumns(35));
+ EXPECT_EQ("#include \"a.h\"", format("#include \"a.h\""));
+ EXPECT_EQ("#include <a>", format("#include<a>"));
verifyFormat("#import <string>");
verifyFormat("#import <a/b/c.h>");