[llvm-branch-commits] [cfe-branch] r71310 - in /cfe/branches/Apple/Dib: include/clang/AST/Attr.h include/clang/Parse/AttributeList.h lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriter.cpp lib/Sema/SemaDeclAttr.cpp

Mike Stump mrs at apple.com
Fri May 8 20:04:17 PDT 2009


Author: mrs
Date: Fri May  8 22:04:16 2009
New Revision: 71310

URL: http://llvm.org/viewvc/llvm-project?rev=71310&view=rev
Log:
Merge in 71308:

Add back Parse/Sema support for attributes cf_returns_retained and
ns_returns_retained, but do not include the other ownership attributes
we previously had.

Modified:
    cfe/branches/Apple/Dib/include/clang/AST/Attr.h
    cfe/branches/Apple/Dib/include/clang/Parse/AttributeList.h
    cfe/branches/Apple/Dib/lib/Frontend/PCHReaderDecl.cpp
    cfe/branches/Apple/Dib/lib/Frontend/PCHWriter.cpp
    cfe/branches/Apple/Dib/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/branches/Apple/Dib/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/include/clang/AST/Attr.h?rev=71310&r1=71309&r2=71310&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/include/clang/AST/Attr.h (original)
+++ cfe/branches/Apple/Dib/include/clang/AST/Attr.h Fri May  8 22:04:16 2009
@@ -59,6 +59,8 @@
     NonNull,
     ObjCException,
     ObjCNSObject,
+    CFReturnsRetained,   // Clang/Checker-specific.
+    NSReturnsRetained,   // Clang/Checker-specific.
     Overloadable, // Clang-specific
     Packed,
     Pure,
@@ -459,6 +461,10 @@
   static bool classof(const RegparmAttr *A) { return true; }
 };
 
+// Checker-specific attributes.
+DEF_SIMPLE_ATTR(CFReturnsRetained);
+DEF_SIMPLE_ATTR(NSReturnsRetained);
+
 #undef DEF_SIMPLE_ATTR
   
 }  // end namespace clang

Modified: cfe/branches/Apple/Dib/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/include/clang/Parse/AttributeList.h?rev=71310&r1=71309&r2=71310&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/include/clang/Parse/AttributeList.h (original)
+++ cfe/branches/Apple/Dib/include/clang/Parse/AttributeList.h Fri May  8 22:04:16 2009
@@ -76,6 +76,8 @@
     AT_nothrow,
     AT_nsobject,
     AT_objc_exception,
+    AT_cf_returns_retained,   // Clang-specific.
+    AT_ns_returns_retained,   // Clang-specific.
     AT_objc_gc,
     AT_overloadable,       // Clang-specific.
     AT_packed,

Modified: cfe/branches/Apple/Dib/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Frontend/PCHReaderDecl.cpp?rev=71310&r1=71309&r2=71310&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Frontend/PCHReaderDecl.cpp Fri May  8 22:04:16 2009
@@ -475,6 +475,8 @@
 
     SIMPLE_ATTR(ObjCException);
     SIMPLE_ATTR(ObjCNSObject);
+    SIMPLE_ATTR(CFReturnsRetained);
+    SIMPLE_ATTR(NSReturnsRetained);
     SIMPLE_ATTR(Overloadable);
     UNSIGNED_ATTR(Packed);
     SIMPLE_ATTR(Pure);

Modified: cfe/branches/Apple/Dib/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Frontend/PCHWriter.cpp?rev=71310&r1=71309&r2=71310&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Frontend/PCHWriter.cpp Fri May  8 22:04:16 2009
@@ -1549,6 +1549,8 @@
 
     case Attr::ObjCException:
     case Attr::ObjCNSObject:
+    case Attr::CFReturnsRetained:
+    case Attr::NSReturnsRetained:
     case Attr::Overloadable:
       break;
 

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaDeclAttr.cpp?rev=71310&r1=71309&r2=71310&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaDeclAttr.cpp Fri May  8 22:04:16 2009
@@ -1544,6 +1544,44 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Checker-specific attribute handlers.
+//===----------------------------------------------------------------------===//
+
+static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr,
+                                        Sema &S) {
+
+  if (!isa<ObjCMethodDecl>(d) && !isa<FunctionDecl>(d)) {
+    const char *name;
+    
+    switch (Attr.getKind()) {
+      default:
+        assert(0 && "invalid ownership attribute");
+        return;
+      case AttributeList::AT_cf_returns_retained:
+        name = "cf_returns_retained"; break;
+      case AttributeList::AT_ns_returns_retained:
+        name = "ns_returns_retained"; break;
+    };
+
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
+      name << 3 /* function or method */;
+    return;
+  }
+  
+  switch (Attr.getKind()) {
+    default:
+      assert(0 && "invalid ownership attribute");
+      return;
+    case AttributeList::AT_cf_returns_retained:
+      d->addAttr(::new (S.Context) CFReturnsRetainedAttr());
+      return;
+    case AttributeList::AT_ns_returns_retained:
+      d->addAttr(::new (S.Context) NSReturnsRetainedAttr());
+      return;
+  };
+}
+
+//===----------------------------------------------------------------------===//
 // Top Level Sema Entry Points
 //===----------------------------------------------------------------------===//
 
@@ -1579,6 +1617,12 @@
   case AttributeList::AT_nonnull:     HandleNonNullAttr   (D, Attr, S); break;
   case AttributeList::AT_noreturn:    HandleNoReturnAttr  (D, Attr, S); break;
   case AttributeList::AT_nothrow:     HandleNothrowAttr   (D, Attr, S); break;
+
+  // Checker-specific.
+  case AttributeList::AT_ns_returns_retained:
+  case AttributeList::AT_cf_returns_retained:
+    HandleNSReturnsRetainedAttr(D, Attr, S); break;
+
   case AttributeList::AT_packed:      HandlePackedAttr    (D, Attr, S); break;
   case AttributeList::AT_section:     HandleSectionAttr   (D, Attr, S); break;
   case AttributeList::AT_stdcall:     HandleStdCallAttr   (D, Attr, S); break;





More information about the llvm-branch-commits mailing list