`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.
rdar://106123303
```
@protocol DeclarationOnly;
@protocol DeclarationOnlyUser<DeclarationOnly>
- (void) printIt;
@end
```
This should not be neccessary, but the compiler currently accepts cases
like the one in the test case added.
rdar://101828847
Add a new frontend option (called `-trap-function <name>`, similar to Clang’s existing `-ftrap-function`) that specifies a function to call instead of trapping.
When the option is used, the compiler will emit a call to the specified function every time it would have otherwise emitted a trap instruction. The function must have no parameters and it must never return.
rdar://89125883
Sema allows you to pass type-pinning parameters into an extension of an Objective-C generic class, but IRGen did not properly handle erasing these types to existential types in runtime metadata. This commit corrects that mistake.
This reverts commit f0cdd76f18, reversing
changes made to 703fe0f1a1.
Revert "IRGen: Refactor getObjCEncodingForMethod and getObjectEncodingFromClangNode into one"
This reverts commit 0082682b0d.
Revert "Merge pull request #30438 from aschwaighofer/irgen_prefer_clang_type_encoding"
This reverts commit eeb7fa52b2, reversing
changes made to 77af77fa8a.
Revert "Merge pull request #30433 from aschwaighofer/irgen_no_duplicate_objc_method_descriptor_entries"
This reverts commit 77af77fa8a, reversing
changes made to 841eeb05b0.
This reverts the changes for
rdar://60461850, rdar://60474785, rdar://60778637
There is still at least an issue that we address with PR#30654.
Revert until we have confidence that this is the right fix set.
Lazy loading checked if the ClangDecl was hidden, but loading all
members did not. Let's make loadAllMembers() behave like the lazy
path, and fix some of the mock SDKs in the test suite.
- Instead of keeping multiple flags in the type descriptor flags,
just keep a single flag indicating the presence of additional
import information after the name.
- That import information consists of a sequence of null-terminated
C strings, terminated by an empty string (i.e. by a double null
terminator), each prefixed with a character describing its purpose.
- In addition to the symbol namespace and related entity name,
include the ABI name if it differs from the user-facing name of the
type, and make the name the user-facing Swift name.
There's a remaining issue here that isn't great: we don't correctly
represent the parent relationship between error types and their codes,
and instead we just use the Clang module as the parent. But I'll
leave that for a later commit.
Windows does not have unsigned enumerations by default. Use a typed
enum to ensure that we get unsigned enumerations on Windows. Fixes the
handling for tests on Windows.
Swift complains about redundant inheritance of a protocol, and
canonicalizes away such redundancies in its metadata. Clang does not
warn about such redundancies, nor does the Objective-C "conforms to
protocol" check take inheritance into account. Extend the existing
"redundant inheritance" hack (designed for JSExport) to cover all
protocols defined in Objective-C, so we match Clang's output of
Objective-C metadata.
Fixes SR-7130 / rdar://problem/38394637.
When emitting foreign class metadata (e.g., for an imported CF type), fill
in the superclass when we have one. The superclass will itself be a foreign
metadata candidate, so also register an initialization function that uniques
the superclass metadata once we've picked the canonical foreign class
metadata.
Adjust the IRGen for ObjC interop to ensure that the section that
metadata is emitted into the correct section for non-MachO targets.
This also adds a more comprehensive test for ensuring that the IRGen can
now be tested on all targets. Since the ObjC interop is now
controllable via the driver, this test does not require that the
objc_interop feature is present as it is a IRGen test.
This is the first step to remove the `REQUIRES: objc_interop` from the
IRGen tests.
Use the modern spelling for the nullability attributes in the test mock
headers. Currently, this was relying on the predefined macros from
clang to work. However, those are only available on Darwin targets.
This is needed to make the mock environments more portable.
When lowering the arguments for the FFI call on certain targets, LLVM
expects that the parameter be passed as a structure rather than the
extracted values. Enhance the argument lowering for the call and the
function construction to ensure that the type can be flattened according
to the ABI for the target before attempting to explode it for the SIL
IRGen lowering. This allows building for targets such as Linux ARM HF
and Linux ARM SF target with the HF floating point ABI.
Addresses SR-6142!
They need external linkage not linkonce_odr which can only be used by defintions
not declarations.
This got exposed by clang imported protocol witness table declarations.
They get assigned shared linkage since they are potentially not unique.
rdar://26563441
The framework versions already superseded the files here, so let's not
even bother building and packaging them. There /are/ still a few
frameworks that aren't shipping their own API notes at the moment,
however, though some of them are deprecated in their entirety.
rdar://problem/32908357
Under ARC, methods in the "init" family are considered to have
NS_REPLACES_RECEIVER semantics ("consumes" self and returning a
value at +1). This is correct for Objective-C "init methods",
which are equivalent for Swift's initializers, but almost never
correct for any other methods that happen to start with the word
"init".
Note that Swift still follows all the other ARC conventions, so
if you name a method or property, say, "newItemController", the
value will be returned at +1. For methods this is probably
desirable, but for properties maybe not. We could do something
similar for property accessors to make sure they always have
the default "no method family" semantics in Objective-C.
rdar://problem/25759260
When importing C functions with availability attributes, we don't
properly use that information to decide whether a symbol should be
weak_extern, causing load failures in dylibs that reference these
symbols when deployed to an older OS.
This is a very targeted fix and we need a better architecture for
deciding this.
rdar://problem/26359452
Sema was dutifully tracking conformances that were "used" as part of
type checking, so it could make sure that those conformances got
completed for SILGen to use. However, this information never actually
made it to SILGen, which included its own (more conservative, not
broad enough) heuristics for finding "used" conformances. Teach Sema
to record conformances within the appropriate source file, and have
SILGen reference the conformances when it emits SIL for the source
file.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md
- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
(like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.
I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)
The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
Most of this is in updating the standard library, SDK overlays, and
piles of test cases to use the new names. No surprises here, although
this shows us some potential heuristic tweaks.
There is one substantive compiler change that needs to be factored out
involving synthesizing calls to copyWithZone()/copy(zone:). Aside from
that, there are four failing tests:
Swift :: ClangModules/objc_parse.swift
Swift :: Interpreter/SDK/Foundation_test.swift
Swift :: Interpreter/SDK/archiving_generic_swift_class.swift
Swift :: Interpreter/SDK/objc_currying.swift
due to two independent remaining compiler bugs:
* We're not getting partial ordering between NSCoder's
encode(AnyObject, forKey: String) and NSKeyedArchiver's version of
that method, and
* Dynamic lookup (into AnyObject) doesn't know how to find the new
names. We need the Swift name lookup tables enabled to address this.
We certainly can't import them as stored properties, and it's too late to try to bridge them as computed property, so restore the old behavior of importing them as unbridged object types. The types still come in as strong managed reference types, which is still wrong, but seems to be right enough for Khan Academy and potentially other existing apps for now, and I don't want to introduce additional source-breaking changes and instability this late in the game. Fixes rdar://problem/19789023, leaving rdar://problem/19790608 to be done when we can afford more churn.
Swift SVN r25158
attribute or appear in a whitelist.
The initial whitelist is based on an audit I performed of our current
public SDKs. If there are CF types which appear only in our internal
SDKs, and somebody urgently needs to use them from Swift, they can
adopt the bridging attributes. The goal is to eventually eliminate
the whitelist and rely solely on bridging attributes anyway.
Sadly, CoreCooling was not included in my SDK audit and must be
explicitly annotated. :(
I've left the main database organized by framework, but I wanted
a quasi-lexicographically sorted version to permit efficient lookup.
We generate that copy automatically with gyb. I ended up having
to tweak handle_gyb_sources to allow it to drop the result in
CMAKE_CURRENT_BINARY_DIR instead of CMAKE_CURRENT_BINARY_DIR/{4,8}
if an architecture is not provided. I think this is abstractly
reasonable for generated includes, which have independent ability
to detect the target word size. But just between you and me,
I did it because I couldn't figure out how to add
"-I${CMAKE_CURRENT_BINARY_DIR/{4,8}" as a compile flag;
the obvious thing didn't work. Anyway, I'd appreciate it if
someone double-checked my cmake hackery here.
Swift SVN r24850
They don't work properly, and if we want eager static initialization,
we'll add a Swift feature for it. Fixes rdar://problem/18423731.
Swift SVN r24814
User-written functions can trigger the use of delayed protocols on imported
types. In the case of enums and structs, it's possible that we need to
synthesize a conformance for one of these protocols. We were failing to do
so because we were checking imported types before looking at any user code,
and deciding not to bother with the delayed protocols because no one had
referenced them yet.
This isn't necessarily a good long-term solution because it doesn't handle
implicitly-defined functions triggering the use of implicit conformances
on imported types. The general problem of "this enum was never compared
so I never made an Equatable performance" is still there, just much less
likely (since our synthesized declarations are usually quite simple). We
may want to revisit this later to make it more robust.
I also couldn't find a reduced test case that triggered this issue. The
reported code looks very similar to the test case I added, but the one I
added doesn't actually fail before this commit. I'm including it anyway to
guard against regressions.
rdar://problem/18198880
Swift SVN r21840
This handles things like NSSwapHostLongLongToBig and MKMapRectMake that
are static inline functions that themselves call other static inline
functions.
<rdar://problem/17227237>
Swift SVN r21080
This is a simple, trivialy, not-even-half-way-there solution to weak
leaking of Objective-C classes introduced after the deployment
target. It only works for Objective-C classes and C global variables
that Clang consideres to be "weak imported". However, this bare
minimum should be enough to develop an app (by jumping through various
hoops) that uses new functionality when its
available. <rdar://problem/17296490>, which I've restricted in scope
to capture this.
Swift SVN r20956
We were neglecting to include initializers and accessors for vars and subscripts, and we were mingling instance and class methods, causing the ObjC runtime to associate the wrong extended type information with methods. Fixes <rdar://problem/17791953>.
Swift SVN r20513