[cfe-commits] r96623 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Index/c-index-api-loadTU-test.m

Ted Kremenek kremenek at apple.com
Thu Feb 18 15:05:17 PST 2010


Author: kremenek
Date: Thu Feb 18 17:05:16 2010
New Revision: 96623

URL: http://llvm.org/viewvc/llvm-project?rev=96623&view=rev
Log:
Allow GNU attributes to appear in an Objective-C method declaration
before the selector name (but after the return type).  Among other things,
this allows IBAction to be implemented with an attribute.

Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/test/Index/c-index-api-loadTU-test.m

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Feb 18 17:05:16 2010
@@ -772,6 +772,12 @@
   if (Tok.is(tok::l_paren))
     ReturnType = ParseObjCTypeName(DSRet);
 
+  // If attributes exist before the method, parse them.
+  llvm::OwningPtr<AttributeList> MethodAttrs;
+  if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
+    MethodAttrs.reset(ParseGNUAttributes());
+
+  // Now parse the selector.
   SourceLocation selLoc;
   IdentifierInfo *SelIdent = ParseObjCSelectorPiece(selLoc);
 
@@ -787,9 +793,9 @@
   llvm::SmallVector<Declarator, 8> CargNames;
   if (Tok.isNot(tok::colon)) {
     // If attributes exist after the method, parse them.
-    llvm::OwningPtr<AttributeList> MethodAttrs;
     if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
-      MethodAttrs.reset(ParseGNUAttributes());
+      MethodAttrs.reset(addAttributeLists(MethodAttrs.take(),
+                                          ParseGNUAttributes()));
 
     Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
     DeclPtrTy Result
@@ -863,9 +869,9 @@
 
   // FIXME: Add support for optional parmameter list...
   // If attributes exist after the method, parse them.
-  llvm::OwningPtr<AttributeList> MethodAttrs;
   if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
-    MethodAttrs.reset(ParseGNUAttributes());
+    MethodAttrs.reset(addAttributeLists(MethodAttrs.take(),
+                                        ParseGNUAttributes()));
 
   if (KeyIdents.size() == 0)
     return DeclPtrTy();

Modified: cfe/trunk/test/Index/c-index-api-loadTU-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-api-loadTU-test.m?rev=96623&r1=96622&r2=96623&view=diff

==============================================================================
--- cfe/trunk/test/Index/c-index-api-loadTU-test.m (original)
+++ cfe/trunk/test/Index/c-index-api-loadTU-test.m Thu Feb 18 17:05:16 2010
@@ -5,7 +5,7 @@
 {
   __attribute__((iboutlet)) id myoutlet;
 }
-
+- (void) __attribute__((ibaction)) myMessage:(id)msg;
 - foo;
 + fooC;
 
@@ -58,6 +58,10 @@
 // CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:32 - 6:40]
 // CHECK: c-index-api-loadTU-test.m:6:32: attribute(iboutlet)= Extent=[6:32 - 6:40]
 // CHECK: c-index-api-loadTU-test.m:6:29: TypeRef=id:0:0 Extent=[6:29 - 6:31]
+// CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=myMessage::8:1 Extent=[8:1 - 8:54]
+// CHECK: c-index-api-loadTU-test.m:8:1: attribute(ibaction)= Extent=[8:1 - 8:54]
+// CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53]
+// CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49]
 // CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 Extent=[9:1 - 9:7]
 // CHECK: c-index-api-loadTU-test.m:10:1: ObjCClassMethodDecl=fooC:10:1 Extent=[10:1 - 10:8]
 // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5]





More information about the cfe-commits mailing list