summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-14 02:22:16 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-14 02:22:16 +0000
commita148a1d40e8605efc2ae8a9e711aa72e35a9758c (patch)
tree7114b12b0d9508bd4d33f6e6c3617b2fe4867ea8 /clang/lib/Parse
parent9162fb07be75bec8db4476d0f3acc4d662672e4a (diff)
downloadbcm5719-llvm-a148a1d40e8605efc2ae8a9e711aa72e35a9758c.tar.gz
bcm5719-llvm-a148a1d40e8605efc2ae8a9e711aa72e35a9758c.zip
Introduce a parsing action to distinguish between class, instance, and
super message sends in Objective-C. No actual functionality change here, but it provides a hook so that Sema can typo-correct the receiver in some cases. llvm-svn: 101207
Diffstat (limited to 'clang/lib/Parse')
-rw-r--r--clang/lib/Parse/MinimalAction.cpp14
-rw-r--r--clang/lib/Parse/ParseObjc.cpp21
2 files changed, 25 insertions, 10 deletions
diff --git a/clang/lib/Parse/MinimalAction.cpp b/clang/lib/Parse/MinimalAction.cpp
index e75569231c7..fc06a0d6a52 100644
--- a/clang/lib/Parse/MinimalAction.cpp
+++ b/clang/lib/Parse/MinimalAction.cpp
@@ -26,6 +26,20 @@ ActionBase::~ActionBase() {}
/// Out-of-line virtual destructor to provide home for Action class.
Action::~Action() {}
+Action::ObjCMessageKind Action::getObjCMessageKind(Scope *S,
+ IdentifierInfo *&Name,
+ SourceLocation NameLoc,
+ bool IsSuper,
+ bool HasTrailingDot) {
+ if (IsSuper && !HasTrailingDot && S->isInObjcMethodScope())
+ return ObjCSuperMessage;
+
+ if (getTypeName(*Name, NameLoc, S))
+ return ObjCClassMessage;
+
+ return ObjCInstanceMessage;
+}
+
// Defined out-of-line here because of dependecy on AttributeList
Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope,
SourceLocation UsingLoc,
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 6c5053d4fbc..6a20a089f78 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -1719,17 +1719,18 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
SourceLocation LBracLoc = ConsumeBracket(); // consume '['
if (Tok.is(tok::identifier)) {
- IdentifierInfo *II = Tok.getIdentifierInfo();
-
- // If this is '[' 'super', then this is a magic superclass message.
- // We parse '[' 'super' '.' 'foo' as an expression?
- if ((II == Ident_super && GetLookAheadToken(1).isNot(tok::period) &&
- CurScope->isInObjcMethodScope()) ||
- // Check to see if this is a typename. If so, it is a class message.
- Actions.getTypeName(*II, Tok.getLocation(), CurScope)) {
- SourceLocation NameLoc = ConsumeToken();
- return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, II,
+ IdentifierInfo *Name = Tok.getIdentifierInfo();
+ SourceLocation NameLoc = Tok.getLocation();
+ switch (Actions.getObjCMessageKind(CurScope, Name, NameLoc,
+ Name == Ident_super,
+ NextToken().is(tok::period))) {
+ case Action::ObjCSuperMessage:
+ case Action::ObjCClassMessage:
+ return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), Name,
ExprArg(Actions));
+
+ case Action::ObjCInstanceMessage:
+ break;
}
}
OpenPOWER on IntegriCloud