[cfe-commits] r43022 - in /cfe/trunk: Parse/ParseObjc.cpp clang.xcodeproj/project.pbxproj include/clang/Parse/Action.h include/clang/Parse/Parser.h test/Parser/selector-1.m

Fariborz Jahanian fjahanian at apple.com
Mon Oct 15 16:39:14 PDT 2007


Author: fjahanian
Date: Mon Oct 15 18:39:13 2007
New Revision: 43022

URL: http://llvm.org/viewvc/llvm-project?rev=43022&view=rev
Log:
Patch to parse @selector expressions.

Added:
    cfe/trunk/test/Parser/selector-1.m
Modified:
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/Parser.h

Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43022&r1=43021&r2=43022&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Mon Oct 15 18:39:13 2007
@@ -1129,6 +1129,8 @@
       return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression());
     case tok::objc_protocol:
       return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression());
+    case tok::objc_selector:
+      return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression());
     default:
       Diag(AtLoc, diag::err_unexpected_at);
       SkipUntil(tok::semi);
@@ -1304,3 +1306,43 @@
   // FIXME 
   return 0;
 }
+
+///     objc-selector-expression
+///       @selector '(' objc-keyword-selector ')'
+Parser::ExprResult Parser::ParseObjCSelectorExpression()
+{
+  SourceLocation SelectorLoc = ConsumeToken();
+  
+  if (Tok.isNot(tok::l_paren)) {
+    Diag(Tok, diag::err_expected_lparen_after, "@selector");
+    return 0;
+  }
+  
+  SourceLocation LParenLoc = ConsumeParen();
+  SourceLocation sLoc;
+  IdentifierInfo *SelIdent = ParseObjCSelector(sLoc);
+  if (!SelIdent && Tok.isNot(tok::colon)) {
+    
+    Diag(Tok, diag::err_expected_ident); // missing selector name.
+    return 0;
+  }
+  if (Tok.isNot(tok::r_paren))
+    while (1) {
+      if (Tok.isNot(tok::colon)) {
+        Diag(Tok, diag::err_expected_colon);
+        break;
+      }
+      ConsumeToken(); // Eat the ':'.
+      if (Tok.is(tok::r_paren))
+        break;
+      // Check for another keyword selector.
+      SourceLocation Loc;
+      SelIdent = ParseObjCSelector(Loc);
+      if (!SelIdent && Tok.isNot(tok::colon))
+        break;
+    }
+  SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+  
+  // FIXME 
+  return 0;
+}
\ No newline at end of file

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43022&r1=43021&r2=43022&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Mon Oct 15 18:39:13 2007
@@ -742,6 +742,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=43022&r1=43021&r2=43022&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Mon Oct 15 18:39:13 2007
@@ -594,6 +594,13 @@
     return 0;
   }
   
+  virtual ExprResult ParseObjCSelectorExpression(SourceLocation EncLoc,
+                                               SourceLocation LParenLoc,
+                                               TypeTy *Ty,
+                                               SourceLocation RParenLoc) {
+    return 0;
+  }
+  
 };
 
 /// MinimalAction - Minimal actions are used by light-weight clients of the

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=43022&r1=43021&r2=43022&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Oct 15 18:39:13 2007
@@ -363,6 +363,7 @@
   ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
   ExprResult ParseObjCStringLiteral();
   ExprResult ParseObjCEncodeExpression();
+  ExprResult ParseObjCSelectorExpression();
   ExprResult ParseObjCProtocolExpression();
   ExprResult ParseObjCMessageExpression();
 

Added: cfe/trunk/test/Parser/selector-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/selector-1.m?rev=43022&view=auto

==============================================================================
--- cfe/trunk/test/Parser/selector-1.m (added)
+++ cfe/trunk/test/Parser/selector-1.m Mon Oct 15 18:39:13 2007
@@ -0,0 +1,16 @@
+// RUN: clang -parse-noop %s 
+
+typedef struct objc_selector *SEL;
+
+int main() {
+ SEL s = @selector(retain);
+ SEL s1 = @selector(meth1:);
+ SEL s2 = @selector(retainArgument::);
+ SEL s3 = @selector(retainArgument:::::);
+ SEL s4 = @selector(retainArgument:with:);
+ SEL s5 = @selector(meth1:with:with:);
+ SEL s6 = @selector(getEnum:enum:bool:);
+ SEL s7 = @selector(char:float:double:unsigned:short:long:);
+
+ SEL s9 = @selector(:enum:bool:);
+}





More information about the cfe-commits mailing list