summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/attr-availability.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve a -Wunguarded-availability noteErik Pilkington2019-01-141-3/+3
| | | | | | | | | | | Mention the deployment target, and don't say "partial" which doesn't really mean anything to users. rdar://problem/33601513 Differential revision: https://reviews.llvm.org/D56523 llvm-svn: 351108
* Append new attributes to the end of an AttributeList.Michael Kruse2018-08-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommit of r335084 after revert in r335516. ... instead of prepending it at the beginning (the original behavior since implemented in r122535 2010-12-23). This builds up an AttributeList in the the order in which the attributes appear in the source. The reverse order caused nodes for attributes in the AST (e.g. LoopHint) to be in the reverse order, and therefore printed in the wrong order in -ast-dump. Some TODO comments mention this. The order was explicitly reversed for enable_if attribute overload resolution and name mangling, which is not necessary anymore with this patch. The change unfortunately has some secondary effect, especially on diagnostic output. In the simplest cases, the CHECK lines or expected diagnostic were changed to the the new output. If the kind of error/warning changed, the attributes' order was changed instead. This unfortunately causes some 'previous occurrence here' hints to be textually after the main marker. This typically happens when attributes are merged, but are incompatible to each other. Interchanging the role of the the main and note SourceLocation will also cause the case where two different declaration's attributes (in contrast to multiple attributes of the same declaration) are merged to be reverse. There is no easy fix because sometimes previous attributes are merged into a new declaration's attribute list, sometimes new attributes are added to a previous declaration's attribute list. Since 'previous occurrence here' pointing to locations after the main marker is not rare, I left the markers as-is; it is only relevant when the attributes are declared in the same declaration anyway. Differential Revision: https://reviews.llvm.org/D48100 llvm-svn: 338800
* Revert "Append new attributes to the end of an AttributeList."Michael Kruse2018-06-251-2/+2
| | | | | | | This reverts commit r335084 as requested by David Jones and Eric Christopher because of differences of emitted warnings. llvm-svn: 335516
* Append new attributes to the end of an AttributeList.Michael Kruse2018-06-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... instead of prepending it at the beginning (the original behavior since implemented in r122535 2010-12-23). This builds up an AttributeList in the the order in which the attributes appear in the source. The reverse order caused nodes for attributes in the AST (e.g. LoopHint) to be in the reverse, and therefore printed in the wrong order by -ast-dump. Some TODO comments mention this. The order was explicitly reversed for enable_if attribute overload resolution and name mangling, which is not necessary anymore with this patch. The change unfortunately has some secondary effects, especially for diagnostic output. In the simplest cases, the CHECK lines or expected diagnostic were changed to the the new output. If the kind of error/warning changed, the attribute's order was changed instead. It also causes some 'previous occurrence here' hints to be textually after the main marker. This typically happens when attributes are merged, but are incompatible. Interchanging the role of the the main and note SourceLocation will also cause the case where two different declaration's attributes (in contrast to multiple attributes of the same declaration) are merged to be reversed. There is no easy fix because sometimes previous attributes are merged into a new declaration's attribute list, sometimes new attributes are added to a previous declaration's attribute list. Since 'previous occurrence here' pointing to locations after the main marker is not rare, I left the markers as-is; it is only relevant when the attributes are declared in the same declaration anyway, which often is on the same line. Differential Revision: https://reviews.llvm.org/D48100 llvm-svn: 335084
* [Sema] Don't allow -Wunguarded-availability to be silenced with redeclsErik Pilkington2017-07-051-7/+18
| | | | | | Differential revision: https://reviews.llvm.org/D33816 llvm-svn: 307175
* Add a fix-it for -Wunguarded-availabilityAlex Lorenz2017-05-051-1/+1
| | | | | | | | | | | | | This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it is similar to the Swift one: it suggests that you wrap the statement in an `if (@available)` check. The produced fixits are indented (just like the Swift ones) to make them look nice in Xcode's fix-it preview. rdar://31680358 Differential Revision: https://reviews.llvm.org/D32424 llvm-svn: 302253
* Add #pragma clang attribute support to the availability attributeAlex Lorenz2017-04-201-1/+1
| | | | | | rdar://31707804 llvm-svn: 300826
* [ObjC] Warn on unguarded use of partial declarationErik Pilkington2016-08-161-1/+1
| | | | | | | | | | | | | | This commit adds a traversal of the AST after Sema of a function that diagnoses unguarded references to declarations that are partially available (based on availability attributes). This traversal is only done when we would otherwise emit -Wpartial-availability. This commit is part of a feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D23003 llvm-svn: 278826
* AvailabilityAttr: we accept "macos" as the platform name.Manman Ren2016-06-281-4/+4
| | | | | | | | | | | | | | We continue accepting "macosx" but canonicalize it to "macos", When emitting diagnostics, we use "macOS" instead of "OS X". The PlatformName in TargetInfo is changed from "macosx" to "macos" so we can directly compare the Platform in AvailabilityAttr with the PlatformName in TargetInfo. rdar://26795172 rdar://26800775 llvm-svn: 274064
* Don't warn about use of deprecated API when the containing context is ↵Jordan Rose2015-04-301-6/+6
| | | | | | | | | | unavailable. This probably won't come up much, but it seems tidier. Related to rdar://problem/20713550 llvm-svn: 236242
* Batch up access-related diagnostics on enum constants until the whole enum ↵Jordan Rose2015-04-301-0/+81
| | | | | | | | | | is parsed. That way we can take any trailing availability attributes into account. rdar://problem/20713550 llvm-svn: 236241
* Add -Wpartial-availability.Nico Weber2015-03-191-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This warns when using decls that are not available on all deployment targets. For example, a call to - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8))); will warn if -mmacosx-version-min is set to less than 10.8. To silence the warning, one has to explicitly redeclare the method like so: @interface Whatever(MountainLionAPI) - (void)ppartialMethod; @end This way, one cannot accidentally call a function that isn't available everywhere. Having to add the redeclaration will hopefully remind the user to add an explicit respondsToSelector: call as well. Some projects build against old SDKs to get this effect, but building against old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples. The hope is that SDK headers are annotated well enough with availability attributes that new SDK + this warning offers the same amount of protection as using an old SDK. llvm-svn: 232750
* Implemented delayed processing of 'unavailable' checking, just like with ↵Ted Kremenek2013-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 'deprecated'. Fixes <rdar://problem/15584219> and <rdar://problem/12241361>. This change looks large, but all it does is reuse and consolidate the delayed diagnostic logic for deprecation warnings with unavailability warnings. By doing so, it showed various inconsistencies between the diagnostics, which were close, but not consistent. It also revealed some missing "note:"'s in the deprecated diagnostics that were showing up in the unavailable diagnostics, etc. This change also changes the wording of the core deprecation diagnostics. Instead of saying "function has been explicitly marked deprecated" we now saw "'X' has been been explicitly marked deprecated". It turns out providing a bit more context is useful, and often we got the actual term wrong or it was not very precise (e.g., "function" instead of "destructor"). By just saying the name of the thing that is deprecated/deleted/unavailable we define this issue away. This diagnostic can likely be further wordsmithed to be shorter. llvm-svn: 197627
* As Aaron pointed out it's simpler to reject wide string availability attr ↵Benjamin Kramer2013-09-131-2/+0
| | | | | | messages in the parser. llvm-svn: 190706
* Guard availability and thread safety attributes against wide strings.Benjamin Kramer2013-09-131-0/+2
| | | | | | Found by inspection. llvm-svn: 190701
* Clear LV cache when dropping availability attributes.Rafael Espindola2013-01-081-0/+3
| | | | llvm-svn: 171906
* Don't crash when trying to apply the availability attribute to a block.Rafael Espindola2013-01-081-1/+6
| | | | llvm-svn: 171899
* Clear the LV cache when merging the availability attribute.Rafael Espindola2013-01-081-0/+3
| | | | | | | The availability implies default visibility, so it can change the computed visibility. llvm-svn: 171840
* availability in structured documents. TakesFariborz Jahanian2012-10-011-3/+3
| | | | | | care of comments by Dimitri and Doug. llvm-svn: 164957
* Add __has_feature(attribute_availability_with_message).Jordan Rose2012-07-241-0/+6
| | | | | | | | | | | | | | | | | This tests for the ability to include a "message" field in availability attributes, like so: extern void ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); This was actually supported in Clang 3.1, but we got a request for a __has_feature so that header files can use this more safely. It's unfortunate that the 3.1 release doesn't include this, however. <rdar://problem/11886458> llvm-svn: 160699
* Process attributes in the order they appear in the source code. This make clangRafael Espindola2012-05-071-2/+2
| | | | | | | | | | | | | | match gcc behavior for two conflicting visibilities in the same decl. It also makes handling of dllimport/dllexport more natural. As a bonus we now warn on the dllimport in void __attribute__((dllimport)) foo13(); void __attribute__((dllexport)) foo13(); as does gcc. llvm-svn: 156343
* Split mergeAvailabilityAttr out of handleAvailabilityAttr. This is importantRafael Espindola2012-05-061-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | for having a uniform logic for adding attributes to a decl. This in turn is needed to fix the FIXME: // FIXME: This needs to happen before we merge declarations. Then, // let attribute merging cope with attribute conflicts. ProcessDeclAttributes(S, NewFD, D, /*NonInheritable=*/false, /*Inheritable=*/true); The idea is that mergeAvailabilityAttr will become a method. Once attributes are processed before merging, it will be called from handleAvailabilityAttr to handle multiple attributes in one decl: void f(int) __attribute__((availability(ios,deprecated=3.0), availability(ios,introduced=2.0))); and from SemaDecl.cpp to handle multiple decls: void f(int) __attribute__((availability(ios,deprecated=3.0))); void f(int) __attribute__((availability(ios,introduced=2.0))); As a bonus, use the new structure to diagnose incompatible availability attributes added to different decls (see included testcases). llvm-svn: 156269
* with -Wdeprecated, include a note to its deprecated declarationFariborz Jahanian2012-04-231-1/+1
| | | | | | location. // rdar://10893232 llvm-svn: 155385
* fixes location of "availability" attribute so warning is displayed atFariborz Jahanian2012-01-231-0/+7
| | | | | | its line. // rdar://10711037 llvm-svn: 148747
* test/Sema/attr-availability.c: Add explicit -triple x86_64-apple-darwin9, ↵NAKAMURA Takumi2011-12-101-1/+1
| | | | | | for now. llvm-svn: 146321
* Add ability to supply additional message to availability macros,Fariborz Jahanian2011-12-101-0/+12
| | | | | | // rdar://10095131 llvm-svn: 146304
* For the availability attribute, allow a declaration to be deprecatedDouglas Gregor2011-08-101-1/+2
| | | | | | in the same version that it is introduced. Stuff happens. llvm-svn: 137214
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-0/+6
which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
OpenPOWER on IntegriCloud