[PATCH] D33250: [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 20:46:10 PDT 2017


erik.pilkington updated this revision to Diff 99235.
erik.pilkington added a comment.

Just noticed this can be simplified a bit, NFC compared to the last version of the diff.


https://reviews.llvm.org/D33250

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


Index: test/SemaObjC/unguarded-availability.m
===================================================================
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -135,6 +135,17 @@
     func_10_12();
 };
 
+AVAILABLE_10_12
+__attribute__((objc_root_class))
+ at interface InterWithProp // expected-note 2 {{marked partial here}}
+ at property int x;
+ at end
+
+void test_property(void) {
+  int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
+  InterWithProp.x = y; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
+}
+
 #ifdef OBJCPP
 
 int f(char) AVAILABLE_10_12;
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7370,7 +7370,8 @@
 
 bool DiagnoseUnguardedAvailability::VisitTypeLoc(TypeLoc Ty) {
   const Type *TyPtr = Ty.getTypePtr();
-  SourceRange Range{Ty.getBeginLoc(), Ty.getEndLoc()};
+  SourceRange Range(StmtStack.back()->getLocStart(),
+                    StmtStack.back()->getLocEnd());
 
   if (const TagType *TT = dyn_cast<TagType>(TyPtr)) {
     TagDecl *TD = TT->getDecl();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33250.99235.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170517/8e53ad1d/attachment.bin>


More information about the cfe-commits mailing list