]> granicus.if.org Git - clang/commitdiff
Add 'ns_returns_not_retained' and 'cf_returns_not_retained' attributes to
authorTed Kremenek <kremenek@apple.com>
Thu, 18 Feb 2010 00:05:45 +0000 (00:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 18 Feb 2010 00:05:45 +0000 (00:05 +0000)
match 'ns_returns_retained' and 'cf_returns_retained' respectively.  These
are not yet hooked up to the static analyzer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96535 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Attr.h
include/clang/Parse/AttributeList.h
lib/AST/AttrImpl.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriter.cpp
lib/Parse/AttributeList.cpp
lib/Sema/SemaDeclAttr.cpp

index 8792bb2e850c549958e8bcc2548d852bd4614b60..dc44c266aaef6cbc0e4bfde38503ec268098b522 100644 (file)
@@ -73,8 +73,10 @@ public:
     ObjCException,
     ObjCNSObject,
     Override,
-    CFReturnsRetained,   // Clang/Checker-specific.
-    NSReturnsRetained,   // Clang/Checker-specific.
+    CFReturnsRetained,      // Clang/Checker-specific.
+    CFReturnsNotRetained,   // Clang/Checker-specific.
+    NSReturnsRetained,      // Clang/Checker-specific.
+    NSReturnsNotRetained,   // Clang/Checker-specific.
     Overloadable, // Clang-specific
     Packed,
     PragmaPack,
@@ -545,7 +547,9 @@ public:
 };
 
 // Checker-specific attributes.
+DEF_SIMPLE_ATTR(CFReturnsNotRetained);
 DEF_SIMPLE_ATTR(CFReturnsRetained);
+DEF_SIMPLE_ATTR(NSReturnsNotRetained);
 DEF_SIMPLE_ATTR(NSReturnsRetained);
 
 // C++0x member checking attributes.
index eab773e412a132adfe2804f6ccb5aff38ca5b3cf..030f88eca2645f8099251466d6349013911fa884 100644 (file)
@@ -89,8 +89,10 @@ public:
     AT_nsobject,
     AT_objc_exception,
     AT_override,
-    AT_cf_returns_retained,   // Clang-specific.
-    AT_ns_returns_retained,   // Clang-specific.
+    AT_cf_returns_not_retained, // Clang-specific.
+    AT_cf_returns_retained,     // Clang-specific.
+    AT_ns_returns_not_retained, // Clang-specific.
+    AT_ns_returns_retained,     // Clang-specific.
     AT_objc_gc,
     AT_overloadable,       // Clang-specific.
     AT_packed,
index dd6e3564a50238796df87a0406e9c321720e6148..fe7cb82b3610f9b146b516ea71509175a818b434 100644 (file)
@@ -74,37 +74,39 @@ void NonNullAttr::Destroy(ASTContext &C) {
 // FIXME: Can we use variadic macro to define DEF_SIMPLE_ATTR_CLONE for
 // "non-simple" classes?
 
-DEF_SIMPLE_ATTR_CLONE(Packed)
 DEF_SIMPLE_ATTR_CLONE(AlwaysInline)
-DEF_SIMPLE_ATTR_CLONE(Malloc)
-DEF_SIMPLE_ATTR_CLONE(NoReturn)
 DEF_SIMPLE_ATTR_CLONE(AnalyzerNoReturn)
+DEF_SIMPLE_ATTR_CLONE(BaseCheck)
+DEF_SIMPLE_ATTR_CLONE(CDecl)
+DEF_SIMPLE_ATTR_CLONE(CFReturnsNotRetained)
+DEF_SIMPLE_ATTR_CLONE(CFReturnsRetained)
+DEF_SIMPLE_ATTR_CLONE(Const)
+DEF_SIMPLE_ATTR_CLONE(DLLExport)
+DEF_SIMPLE_ATTR_CLONE(DLLImport)
 DEF_SIMPLE_ATTR_CLONE(Deprecated)
+DEF_SIMPLE_ATTR_CLONE(FastCall)
 DEF_SIMPLE_ATTR_CLONE(Final)
-DEF_SIMPLE_ATTR_CLONE(Unavailable)
-DEF_SIMPLE_ATTR_CLONE(Unused)
-DEF_SIMPLE_ATTR_CLONE(Used)
-DEF_SIMPLE_ATTR_CLONE(Weak)
-DEF_SIMPLE_ATTR_CLONE(WeakImport)
+DEF_SIMPLE_ATTR_CLONE(Hiding)
+DEF_SIMPLE_ATTR_CLONE(Malloc)
+DEF_SIMPLE_ATTR_CLONE(NSReturnsNotRetained)
+DEF_SIMPLE_ATTR_CLONE(NSReturnsRetained)
+DEF_SIMPLE_ATTR_CLONE(NoDebug)
+DEF_SIMPLE_ATTR_CLONE(NoInline)
+DEF_SIMPLE_ATTR_CLONE(NoReturn)
 DEF_SIMPLE_ATTR_CLONE(NoThrow)
-DEF_SIMPLE_ATTR_CLONE(Const)
+DEF_SIMPLE_ATTR_CLONE(ObjCException)
+DEF_SIMPLE_ATTR_CLONE(ObjCNSObject)
+DEF_SIMPLE_ATTR_CLONE(Override)
+DEF_SIMPLE_ATTR_CLONE(Packed)
 DEF_SIMPLE_ATTR_CLONE(Pure)
-DEF_SIMPLE_ATTR_CLONE(FastCall)
 DEF_SIMPLE_ATTR_CLONE(StdCall)
-DEF_SIMPLE_ATTR_CLONE(CDecl)
 DEF_SIMPLE_ATTR_CLONE(TransparentUnion)
-DEF_SIMPLE_ATTR_CLONE(ObjCNSObject)
-DEF_SIMPLE_ATTR_CLONE(ObjCException)
-DEF_SIMPLE_ATTR_CLONE(NoDebug)
+DEF_SIMPLE_ATTR_CLONE(Unavailable)
+DEF_SIMPLE_ATTR_CLONE(Unused)
+DEF_SIMPLE_ATTR_CLONE(Used)
 DEF_SIMPLE_ATTR_CLONE(WarnUnusedResult)
-DEF_SIMPLE_ATTR_CLONE(NoInline)
-DEF_SIMPLE_ATTR_CLONE(CFReturnsRetained)
-DEF_SIMPLE_ATTR_CLONE(NSReturnsRetained)
-DEF_SIMPLE_ATTR_CLONE(BaseCheck)
-DEF_SIMPLE_ATTR_CLONE(Hiding)
-DEF_SIMPLE_ATTR_CLONE(Override)
-DEF_SIMPLE_ATTR_CLONE(DLLImport)
-DEF_SIMPLE_ATTR_CLONE(DLLExport)
+DEF_SIMPLE_ATTR_CLONE(Weak)
+DEF_SIMPLE_ATTR_CLONE(WeakImport)
 DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer)
 
 Attr* PragmaPackAttr::clone(ASTContext &C) const {
index f47a60f2607ed74b2c3642dba1cec709d7b606c0..cadc5427658abc8252787a17658f70fb4d3da1f5 100644 (file)
@@ -550,7 +550,9 @@ Attr *PCHReader::ReadAttributes() {
 
     SIMPLE_ATTR(ObjCException);
     SIMPLE_ATTR(ObjCNSObject);
+    SIMPLE_ATTR(CFReturnsNotRetained);
     SIMPLE_ATTR(CFReturnsRetained);
+    SIMPLE_ATTR(NSReturnsNotRetained);
     SIMPLE_ATTR(NSReturnsRetained);
     SIMPLE_ATTR(Overloadable);
     SIMPLE_ATTR(Override);
index bd6463128bcf5d572b81dee82cd0efb0b9cbf8f8..15dbe6e18ed7bffea7ef6b644c0de8d2636ec66f 100644 (file)
@@ -1868,10 +1868,12 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
       break;
     }
 
-    case Attr::ObjCException:
-    case Attr::ObjCNSObject:
+    case Attr::CFReturnsNotRetained:
     case Attr::CFReturnsRetained:
+    case Attr::NSReturnsNotRetained:
     case Attr::NSReturnsRetained:
+    case Attr::ObjCException:
+    case Attr::ObjCNSObject:
     case Attr::Overloadable:
     case Attr::Override:
       break;
index 2321f1acb9d15348df6115517b89df57aa818d43..43722ad0dc9b2ec43fb5d9c9a744de4c6cc55827 100644 (file)
@@ -112,7 +112,9 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
     .Case("analyzer_noreturn", AT_analyzer_noreturn)
     .Case("warn_unused_result", AT_warn_unused_result)
     .Case("carries_dependency", AT_carries_dependency)
+    .Case("ns_returns_not_retained", AT_ns_returns_not_retained)
     .Case("ns_returns_retained", AT_ns_returns_retained)
+    .Case("cf_returns_not_retained", AT_cf_returns_not_retained)
     .Case("cf_returns_retained", AT_cf_returns_retained)
     .Case("reqd_work_group_size", AT_reqd_wg_size)
     .Case("no_instrument_function", AT_no_instrument_function)
index e0943274dac29bbe2540b3008c8c5964f5021827..bb47ae7ea803a79439e4aabfc9e80029b87ab46e 100644 (file)
@@ -1711,6 +1711,12 @@ static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr,
     default:
       assert(0 && "invalid ownership attribute");
       return;
+    case AttributeList::AT_cf_returns_not_retained:
+      d->addAttr(::new (S.Context) CFReturnsNotRetainedAttr());
+      return;
+    case AttributeList::AT_ns_returns_not_retained:
+      d->addAttr(::new (S.Context) NSReturnsNotRetainedAttr());
+      return;
     case AttributeList::AT_cf_returns_retained:
       d->addAttr(::new (S.Context) CFReturnsRetainedAttr());
       return;
@@ -1776,6 +1782,8 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D,
   case AttributeList::AT_override:    HandleOverrideAttr    (D, Attr, S); break;
 
   // Checker-specific.
+  case AttributeList::AT_ns_returns_not_retained:
+  case AttributeList::AT_cf_returns_not_retained:
   case AttributeList::AT_ns_returns_retained:
   case AttributeList::AT_cf_returns_retained:
     HandleNSReturnsRetainedAttr(D, Attr, S); break;