[cfe-commits] r140565 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/arc-unavailable-system-function.m

Fariborz Jahanian fjahanian at apple.com
Mon Sep 26 14:23:35 PDT 2011


Author: fjahanian
Date: Mon Sep 26 16:23:35 2011
New Revision: 140565

URL: http://llvm.org/viewvc/llvm-project?rev=140565&view=rev
Log:
objc-arc: mark functions which return types which can't be dealt with
in arc mode and are in system headers as unavailable. 
// rdar://10186625

Added:
    cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m
Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=140565&r1=140564&r2=140565&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Sep 26 16:23:35 2011
@@ -3758,7 +3758,9 @@
   // Private ivars are always okay.  Unfortunately, people don't
   // always properly make their ivars private, even in system headers.
   // Plus we need to make fields okay, too.
-  if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl))
+  // Function declarations in sys headers will be marked unavailable.
+  if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
+      !isa<FunctionDecl>(decl))
     return false;
 
   // Require it to be declared in a system header.

Added: cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m?rev=140565&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m (added)
+++ cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m Mon Sep 26 16:23:35 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin11 -fobjc-arc -fobjc-nonfragile-abi -verify %s
+// rdar://10186625
+
+# 1 "<command line>"
+# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3
+id * foo(); // expected-note {{function has been explicitly marked unavailable here}}
+
+# 1 "arc-unavailable-system-function.m" 2
+void ret() {
+  foo(); // expected-error {{'foo' is unavailable: this system declaration uses an unsupported type}}
+}
+
+





More information about the cfe-commits mailing list