From: Chris Lattner Date: Fri, 25 Jan 2008 19:25:00 +0000 (+0000) Subject: Factor a complex predicate out to a helper method. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14dd98a7952c9559e0d17fff8272bf3be67135af;p=clang Factor a complex predicate out to a helper method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46365 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index 1bebe250af..e100c259f9 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -1267,9 +1267,7 @@ Parser::ExprResult Parser::ParseObjCMessageExpression() { SourceLocation LBracLoc = ConsumeBracket(); // consume '[' // Parse receiver - if (Tok.is(tok::identifier) && - (Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope) - || Tok.isNamedIdentifier("super"))) { + if (isTokObjCMessageIdentifierReceiver()) { IdentifierInfo *ReceiverName = Tok.getIdentifierInfo(); ConsumeToken(); return ParseObjCMessageExpressionBody(LBracLoc, ReceiverName, 0); diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index ba1597d3f8..379148b76d 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -362,6 +362,17 @@ private: //===--------------------------------------------------------------------===// // Objective-C Expressions + + bool isTokObjCMessageIdentifierReceiver() const { + if (!Tok.is(tok::identifier)) + return false; + + if (Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)) + return true; + + return Tok.isNamedIdentifier("super"); + } + ExprResult ParseObjCAtExpression(SourceLocation AtLocation); ExprResult ParseObjCStringLiteral(SourceLocation AtLoc); ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);