Commit Graph

601 Commits

Author SHA1 Message Date
Nadav Rotem
32211041d2 Rename @semantics -> @_semantics.
Swift SVN r27533
2015-04-21 17:10:06 +00:00
Doug Gregor
4e0e32197f Extend 'availability' attribute with an unconditional 'deprecated' option.
Allow an unversioned 'deprecated' attribute to specify unconditional
deprecation of an API, e.g.,

  @availability(*, deprecated, message="sorry")
  func foo() { }

Also support platform-specific deprecation, e.g.,

  @availability(iOS, deprecated, message="don't use this on iOS")
  func bar() { }

Addresses rdar://problem/20562871.

Swift SVN r27355
2015-04-16 06:36:45 +00:00
Doug Gregor
921855ee0d Revert "Extend 'availability' attribute with an unconditional 'deprecated' option."
This reverts r27339; it broke an iOS test.

Swift SVN r27343
2015-04-16 03:36:40 +00:00
Doug Gregor
b4b5dbb5d8 Extend 'availability' attribute with an unconditional 'deprecated' option.
Allow an unversioned 'deprecated' attribute to specify unconditional
deprecation of an API, e.g.,

  @availability(*, deprecated, message="sorry")
  func foo() { }

Also support platform-specific deprecation, e.g.,

  @availability(iOS, deprecated, message="don't use this on iOS")
  func bar() { }

Addresses rdar://problem/20562871.

Swift SVN r27339
2015-04-15 23:59:20 +00:00
Xi Ge
c53aefb874 [ModulePrint] Skip user inaccessible decl attrs when printing module interfaces.
Not skipping them may cause internal-used attributes' leaking to external developers.
rdar://19903962

Swift SVN r27324
2015-04-15 20:06:08 +00:00
Joe Groff
e4e0f35aed IRGen: Implement an @_alignment attribute.
This is an internal-only affordance for the numerics team to be able to work on SIMD-compatible types. For now, it can only increase alignment of fixed-layout structs and enums; dynamic layout, classes, and other obvious extensions are left to another day when we can design a proper layout control design.

Swift SVN r27323
2015-04-15 17:23:30 +00:00
Jordan Rose
182ef27f95 [ClangImporter] Handle __attribute__((availability(swift, unavailable))).
This is the new and improved version of
__attribute__((annotate("swift1_unavailable"))), with the "improved" being
specifically that the 'availability' attribute supports a message.

This requires a corresponding Clang commit.

Swift side of rdar://problem/18768673.

Swift SVN r27053
2015-04-07 02:40:22 +00:00
Doug Gregor
f2eac29017 Revert "Put the actual protocol in the synthesized attribute name."
This reverts r26326.

Swift SVN r26334
2015-03-19 23:38:10 +00:00
Doug Gregor
4ae060f817 Put the actual protocol in the synthesized attribute name.
Mainly a debugging aid; users should never see these.

Swift SVN r26326
2015-03-19 22:10:07 +00:00
Doug Gregor
dc27688eca Generalize the importer-only RawOptionSet attribute to a SynthesizedProtocol attribute.
This lets us tag imported declarations with arbitrary synthesized
protocols. Use it to handle imported raw option sets as well as the
RawRepresentable conformances of enums that come in as structs.

Swift SVN r26298
2015-03-19 06:35:25 +00:00
Xi Ge
737f0ca6a6 [CodeCompletion] Using canAttributeAppearOnDecl() to decide whether an attribute is applicable.
Swift SVN r25961
2015-03-10 22:31:43 +00:00
Doug Gregor
3638f78723 Fix the Fix-It location for insertion of @objc (rdar://problem/19879598).
This is a band-aid; all declarations should consider attributes in
their source range calculations.

Swift SVN r25379
2015-02-18 23:00:20 +00:00
Devin Coughlin
503e824e12 Warn on uses of deprecated APIs
Emit a warning when the developer uses an API that has been marked deprecated with an
availability attribute. Following the Clang behavior, we will only warn if the API is
deprecated on all deployment targets. For example, if an API is deprecated as of
OS X 10.11 but the minimum deployment target is 10.10 then no warning will be emitted.

rdar://problem/17406050

Swift SVN r25288
2015-02-13 23:44:28 +00:00
Doug Gregor
954b4e4d83 Implement @autoclosure(escaping).
Addresses rdar://problem/19499207.

Swift SVN r25249
2015-02-12 21:09:47 +00:00
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Andrew Trick
32b104abb2 Silence unannotated fall-through warnings.
Swift SVN r23342
2014-11-15 00:37:35 +00:00
Greg Parker
eef633d732 Replace assert(0) with llvm_unreachable() or llvm::report_fatal_error().
Swift SVN r23340
2014-11-15 00:24:32 +00:00
Doug Gregor
9e08c0b719 Initialize ObjCAttrBits.ImplicitName in all ObjCAttr constructors.
Swift SVN r23158
2014-11-07 17:54:39 +00:00
Doug Gregor
89e5e5b6fa Diagnose redeclarations of Objective-C methods.
@objc methods, initializers, deinitializers, properties, and
subscripts all produce Objective-C methods. Diagnose cases where two
such entities (which may be of different kinds) produce the same
Objective-C method in the same class.

As a special exception, one can have an Objective-C method in an
extension that conflicts with an Objective-C method in the original
class definition, so long as the original class definition is from a
different model. This reflects the reality in Objective-C that the
category definition wins over the original definition, and is used in
at least one overlay (SpriteKit).

This is the first part of rdar://problem/18391046; the second part
involves checking that overrides are sane.

Swift SVN r23147
2014-11-07 01:15:14 +00:00
Manman Ren
c406e3b3af [SILPrinter] do not print implicit @objc.
They will not parse. Another option is to differentiate implicit vs
explicit attribute when printing and parsing.

rdar://18540877


Swift SVN r22587
2014-10-08 00:20:45 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Dmitri Hrybenko
8fdd6aca87 Fix warnings about falling off the end of a function without a return
Swift SVN r22317
2014-09-27 23:34:22 +00:00
Devin Coughlin
c9d7e6f898 Move AvailabilityAttr::isActivePlatform reasoning to a helper in PlatformKind. NFC.
Swift SVN r21948
2014-09-15 18:21:32 +00:00
Devin Coughlin
5a9ccc5ab2 Add ASTDumper support for AvailabilityQueryExpr
This patch also moves some static utility methods involving PlatformKind out of Attr.h and into PlatformKind.h.


Swift SVN r21896
2014-09-12 00:13:48 +00:00
Devin Coughlin
1b8ed882d3 Move AvailabilityAttr::PlatformKind into its own file
Swift SVN r21728
2014-09-04 23:34:19 +00:00
Erik Eckstein
99cc7603be Add an @inline(__always) function attribute.
This will let the performance inliner inline a function even if the costs are too high.
This attribute is only a hint to the inliner.
If the inliner has other good reasons not to inline a function,
it will ignore this attribute. For example if it is a recursive function (which is
currently not supported by the inliner).

Note that setting the inline threshold to 0 does disable performance inlining at all and in
this case also the @inline(__always) has no effect.



Swift SVN r21452
2014-08-26 00:56:34 +00:00
Doug Gregor
17716524c5 Handle CF <-> Objective-C toll-free-bridged conversions in the type checker.
Introduce an attribute that describes when a given CF type is
toll-free-bridged to an Objective-C class, and which class that
is. Use that information in the type checker to provide the CF <->
Objective-C toll-free-bridged conversions directly, rather than using
the user-defined conversion machinery.

Swift SVN r21376
2014-08-21 21:36:05 +00:00
Arnold Schwaighofer
cd799f8e46 Revert "Add an inline(late) attribute"
This reverts commit r21286.

Discussions ongoing.

Swift SVN r21289
2014-08-19 18:15:25 +00:00
Arnold Schwaighofer
7aa62ce835 Add an inline(late) attribute
This disables inlining at the SIL level. LLVM inlining is still enabled. We can
use this to expose one function at the SIL level - which can participate in
dominance based optimizations but which is implemented in terms of a cheap check
and an expensive check (function call) that benefits from LLVM's inlining.

Example:

The inline(late) in the example below prevents inlining of the two checks. We
can now perform dominance based optimizations on isClassOrObjExistential.
Without blocking inlining the optimizations would apply to the sizeof check
only and we would have multiple expensive function calls.

@inline(late)
func isClassOrObjExistential(t: Type) -> Bool{
  return sizeof(t) == sizeof(AnyObject) &&
    swift_isClassOrObjExistential(t)
}

We do want inlining of this function to happen at the LLVM level because the
first check is constant folded away - IRGen replaces sizeof by constants.

rdar://17961249

Swift SVN r21286
2014-08-19 18:05:44 +00:00
Manman Ren
ef3a5cbe2c Parser: round-trip @effects.
Swift SVN r21148
2014-08-12 16:41:04 +00:00
Nadav Rotem
33159056e9 Catch fallthrough cases in the handling of InlineAttr.
Swift SVN r21086
2014-08-07 07:19:22 +00:00
Nadav Rotem
8dd52d63cd Add the @effects(readonly/readnone/readwrite) attribute.
Swift SVN r21070
2014-08-06 18:48:20 +00:00
Doug Gregor
63304b57b4 Introduce AvailabilityAttr::prettyPlatformName() to improve diagnostics.
Swift SVN r20958
2014-08-02 21:06:30 +00:00
Doug Gregor
f52c6789db Track the minimum deployment target and use it for 'unavailable' computations.
Swift SVN r20955
2014-08-02 18:05:45 +00:00
Jordan Rose
9f64db085a Fill out the implementation of AvailabilityAttr.
This includes proper printing support as well as proper platform checking
when seeing if a decl is unavailable. A few other places in the code will
now use AvailabilityAttr::isUnavailable instead of just checking the
is-unavailable-always flag (and not always checking the platform).

No new tests yet because this doesn't include /parsing/ the other fields
of AvailabilityAttr. That will come next, at which point we'll test each
of the cases that has been switched over to use
AvailabilityAttr::isUnavailable.

Part of <rdar://problem/17024498>

Swift SVN r20844
2014-07-31 18:58:17 +00:00
Jordan Rose
5257550f13 [ClangImporter] Don't mark generated 'unavailable' attributes as implicit.
Nearly all of them come from some annotation written explicitly in the
Objective-C header, and all of them should be shown in the generated
interface for an imported module.

Part of <rdar://problem/17024498>

Swift SVN r20841
2014-07-31 18:58:14 +00:00
Jordan Rose
1a65ce0c16 Print @availability and @asmname on their own line.
These attributes are too long and would mess up the flow of the line if
placed directly before the decl introducer.

Swift SVN r20840
2014-07-31 18:58:13 +00:00
Chris Lattner
1436c35eb4 now that Beta 5 has branched, we can remove some migration stuff from
what will become beta 6.  This resolves:

<rdar://problem/17662823> Beta 6: remove "operator infix" -> "infix operator" rewrite
<rdar://problem/17670579> Remove @assignment fixit upgrade logic
<rdar://problem/17747208> remove auto_closure upgrade logic after Beta 5 branches



Swift SVN r20629
2014-07-28 16:38:31 +00:00
Chris Lattner
6d0934d33d Introduce a new 'renamed' modifier on unavailable attributes. This allows Xcode
to emit fixit's when we rename something, e.g.:

t.swift:6:9: error: 'float' has been renamed to Float
var y : float
        ^~~~~
        Float

Adopt this in the stdlib.



Swift SVN r20549
2014-07-25 18:00:37 +00:00
Doug Gregor
eee00ca58b Require 'required' keyword when overriding a required initializer.
Swift SVN r20489
2014-07-24 15:30:15 +00:00
Jordan Rose
00b6a5cb08 Import Objective-C properties marked weak/copy as weak/@NSCopying.
...and 'assign' and 'unsafe_unretained' as 'unowned(unsafe)', if the
property is a class type.

This isn't important for the compiler, but it is documentation for users
when they look at the generated interface for an Objective-C module.

Note that this actually produces a decl users can't yet write:

  unowned(unsafe) var foo: UIView!

That's <rdar://problem/17277899> unowned pointers can't be optional.

<rdar://problem/17245555>

Swift SVN r20433
2014-07-23 22:29:01 +00:00
Jordan Rose
a2af37a19b Split PrintOptions::printEverything into printEverything and printVerbose.
The former is for debugging, the latter is for detailed presentation to users.
swift -print-ast will continue using printEverything, as will swift-ide-test,
but all other features should use printVerbose.

Swift SVN r20432
2014-07-23 22:28:55 +00:00
Michael Ilseman
6043c29faf Don't print implicit attributes unless requested
Swift SVN r20336
2014-07-22 21:31:55 +00:00
Chris Lattner
bc481f0fe1 implement <rdar://problem/16859927> remove the underscore in "auto_closure"
autoclosure is one work, not two.



Swift SVN r20253
2014-07-21 15:23:50 +00:00
Chris Lattner
48687380b7 now that DeclAttributes is a single word, there is no reason to deal with
it indirectly through another pointer from Decl, just embed DeclAttributes
directly into Decl and get rid of the "getMutableAttrs" nonsense.



Swift SVN r20216
2014-07-20 04:09:42 +00:00
Chris Lattner
6fb46992f2 move the utility functions that map a string to a type/decl attribute ID out of ParseDecl into Attr.cpp,
allowing us to give them a better name and dox comment them.  This elimiantes a duplicate copy from the IDE layer as well, ensuring consistency.


Swift SVN r20075
2014-07-17 05:28:34 +00:00
Chris Lattner
fdaa28ce16 fix a warning about a zero length array, by ripping out all of the old declattributes code. :-)
Swift SVN r20071
2014-07-17 04:48:34 +00:00
Jordan Rose
31c1c20a89 Print attributes in the order they were written.
Also, don't print accessibility attributes twice. (Chris's general
modifier-handling code subsumes my accessibility-specific special cases.)

Swift SVN r20043
2014-07-16 21:39:10 +00:00
Chris Lattner
6592366f23 switch weak/unowned/unowned(unsafe) to the new declattributes machinery.
Swift SVN r20032
2014-07-16 19:46:00 +00:00
Chris Lattner
2825b9f5f8 move @transparent and @requires_stored_property_inits to the new attribute model.
All that is left is unowned(unsafe) & weak.



Swift SVN r20012
2014-07-16 06:14:19 +00:00