if (Current.is(tok::identifier) && Current.Next &&
Current.Next->is(TT_DictLiteral))
return State.Stack.back().Indent;
- if (NextNonComment->isStringLiteral() && State.StartOfStringLiteral != 0)
+ if ((NextNonComment->isStringLiteral() ||
+ NextNonComment->is(TT_ObjCStringLiteral)) &&
+ State.StartOfStringLiteral != 0)
return State.StartOfStringLiteral;
if (NextNonComment->is(tok::lessless) &&
State.Stack.back().FirstLessLess != 0)
moveStatePastScopeCloser(State);
moveStatePastFakeRParens(State);
- if (Current.isStringLiteral() && State.StartOfStringLiteral == 0) {
+ if ((Current.isStringLiteral() || Current.is(TT_ObjCStringLiteral)) &&
+ State.StartOfStringLiteral == 0) {
State.StartOfStringLiteral = State.Column;
} else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) &&
!Current.isStringLiteral()) {
if (rParenEndsCast(Current))
Current.Type = TT_CastRParen;
} else if (Current.is(tok::at) && Current.Next) {
- switch (Current.Next->Tok.getObjCKeywordID()) {
- case tok::objc_interface:
- case tok::objc_implementation:
- case tok::objc_protocol:
- Current.Type = TT_ObjCDecl;
- break;
- case tok::objc_property:
- Current.Type = TT_ObjCProperty;
- break;
- default:
- break;
+ if (Current.Next->isStringLiteral()) {
+ Current.Type = TT_ObjCStringLiteral;
+ } else {
+ switch (Current.Next->Tok.getObjCKeywordID()) {
+ case tok::objc_interface:
+ case tok::objc_implementation:
+ case tok::objc_protocol:
+ Current.Type = TT_ObjCDecl;
+ break;
+ case tok::objc_property:
+ Current.Type = TT_ObjCProperty;
+ break;
+ default:
+ break;
+ }
}
} else if (Current.is(tok::period)) {
FormatToken *PreviousNoComment = Current.getPreviousNonComment();
return Left.BlockKind != BK_BracedInit &&
Left.isNot(TT_CtorInitializerColon) &&
(Right.NewlinesBefore > 0 && Right.HasUnescapedNewline);
- if (Right.Previous->isTrailingComment() ||
- (Right.isStringLiteral() && Right.Previous->isStringLiteral()))
+ if (Left.isTrailingComment())
+ return true;
+ if (Left.isStringLiteral() &&
+ (Right.isStringLiteral() || Right.is(TT_ObjCStringLiteral)))
return true;
if (Right.Previous->IsUnterminatedLiteral)
return true;
" \"jkl\");");
verifyFormat("f(L\"a\"\n"
- " L\"b\")");
+ " L\"b\");");
verifyFormat("#define A(X) \\\n"
" L\"aaaaa\" #X L\"bbbbbb\" \\\n"
" L\"ccccc\"",
getLLVMStyleWithColumns(25));
+
+ verifyFormat("f(@\"a\"\n"
+ " @\"b\");");
+ verifyFormat("NSString s = @\"a\"\n"
+ " @\"b\";");
}
TEST_F(FormatTest, AlwaysBreakAfterDefinitionReturnType) {
// Exempt ObjC strings for now.
EXPECT_EQ("NSString *const kString = @\"aaaa\"\n"
- " \"bbbb\";",
+ " @\"bbbb\";",
format("NSString *const kString = @\"aaaa\"\n"
- "\"bbbb\";",
+ "@\"bbbb\";",
Break));
Break.ColumnLimit = 0;