bool parseParens(bool LookForDecls = false) {
if (CurrentToken == NULL)
return false;
+ bool AfterCaret = Contexts.back().CaretFound;
+ Contexts.back().CaretFound = false;
+
ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
// FIXME: This is a bit of a hack. Do better.
Left->Previous->MatchingParen->Type == TT_LambdaLSquare) {
// This is a parameter list of a lambda expression.
Contexts.back().IsExpression = false;
- } else if (Left->Previous && Left->Previous->is(tok::caret) &&
- Left->Previous->Type == TT_UnaryOperator) {
+ } else if (AfterCaret) {
// This is the parameter list of an ObjC block.
Contexts.back().IsExpression = false;
}
ColonIsForRangeExpr(false), ColonIsDictLiteral(false),
ColonIsObjCMethodExpr(false), FirstObjCSelectorName(NULL),
FirstStartOfName(NULL), IsExpression(IsExpression),
- CanBeExpression(true), InCtorInitializer(false) {}
+ CanBeExpression(true), InCtorInitializer(false), CaretFound(false) {}
tok::TokenKind ContextKind;
unsigned BindingStrength;
bool IsExpression;
bool CanBeExpression;
bool InCtorInitializer;
+ bool CaretFound;
};
/// \brief Puts a new \c Context onto the stack \c Contexts for the lifetime
Contexts.back().IsExpression);
} else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) {
Current.Type = determinePlusMinusCaretUsage(Current);
- if (Current.Type == TT_UnaryOperator)
+ if (Current.Type == TT_UnaryOperator) {
++Contexts.back().NumBlockParameters;
+ if (Current.is(tok::caret))
+ Contexts.back().CaretFound = true;
+ }
} else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
Current.Type = determineIncrementUsage(Current);
} else if (Current.is(tok::exclaim)) {
verifyFormat("int i = {[operation setCompletionBlock : ^{ [self "
"onOperationDone]; }] };");
verifyFormat("[operation setCompletionBlock:^(int *i) { f(); }];");
+ verifyFormat("int a = [operation block:^int(int *i) { return 1; }];");
+ verifyFormat("[myObject doSomethingWith:arg1\n"
+ " aaa:^int(int *a) { return 1; }\n"
+ " bbb:f(a * b)];");
verifyFormat("[operation setCompletionBlock:^{\n"
" [self.delegate newDataAvailable];\n"