Fix <rdar://problem/6150376> [sema] crash on invalid message send.
The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59639 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 793945b..9c97ea2 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1424,8 +1424,8 @@
// Parse receiver
if (isTokObjCMessageIdentifierReceiver()) {
IdentifierInfo *ReceiverName = Tok.getIdentifierInfo();
- ConsumeToken();
- return ParseObjCMessageExpressionBody(LBracLoc, ReceiverName, 0);
+ SourceLocation NameLoc = ConsumeToken();
+ return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, ReceiverName, 0);
}
ExprResult Res = ParseExpression();
@@ -1434,7 +1434,7 @@
return Res;
}
- return ParseObjCMessageExpressionBody(LBracLoc, 0, Res.Val);
+ return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0, Res.Val);
}
/// ParseObjCMessageExpressionBody - Having parsed "'[' objc-receiver", parse
@@ -1460,6 +1460,7 @@
///
Parser::ExprResult
Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
+ SourceLocation NameLoc,
IdentifierInfo *ReceiverName,
ExprTy *ReceiverExpr) {
// Parse objc-selector
@@ -1548,7 +1549,8 @@
// We've just parsed a keyword message.
if (ReceiverName)
return Actions.ActOnClassMessage(CurScope,
- ReceiverName, Sel, LBracLoc, RBracLoc,
+ ReceiverName, Sel,
+ LBracLoc, NameLoc, RBracLoc,
&KeyExprs[0], KeyExprs.size());
return Actions.ActOnInstanceMessage(ReceiverExpr, Sel, LBracLoc, RBracLoc,
&KeyExprs[0], KeyExprs.size());