[PATCH] D23024: [ObjC Availability] Fix false positive of -Wpartial-availability introduced in r277058

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 11:59:57 PDT 2016


erik.pilkington created this revision.
erik.pilkington added reviewers: manmanren, thakis.
erik.pilkington added a subscriber: cfe-commits.

´╗┐As of r277058, Clang would incorrectly emit -Wpartial-availability for the following (when compiled with -mmacosx-verison-min=10.6):
```
int fn_10_5() __attribute__((availablity(macos, introduced=10.5)));
int use() __attribute__((availability(macos, introduced=10.4))) {
  return fn_10_5(); // incorrect warning: fn_10_5 is partial
}
```
The problem is that I didn't consider the base deployment target when getting the context version, so the availability of the context of the call to `fn_10_5` was `10.4` (from the function), not `10.6` (from the deployment target). Therefore, a warning was emitted.

Thanks Nico Weber for pointing this out!

https://reviews.llvm.org/D23024

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/attr-availability.m

Index: test/SemaObjC/attr-availability.m
===================================================================
--- test/SemaObjC/attr-availability.m
+++ test/SemaObjC/attr-availability.m
@@ -297,6 +297,7 @@
 
 #if defined(WARN_PARTIAL)
 
+int fn_10_0() __attribute__((availability(macosx, introduced=10.0)));
 int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{marked partial here}}
 int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{marked partial here}}
   return fn_10_7();
@@ -324,4 +325,8 @@
 -(void)method4 { fn_10_8(); }
 @end
 
+int old_func() __attribute__((availability(macos, introduced=10.4))) {
+  fn_10_0();
+}
+
 #endif
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6505,5 +6505,5 @@
         DeclVersion = AA->getIntroduced();
   }
 
-  return DeclVersion;
+  return std::max(DeclVersion, Context.getTargetInfo().getPlatformMinVersion());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23024.66348.patch
Type: text/x-patch
Size: 1051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160801/49088a91/attachment.bin>


More information about the cfe-commits mailing list