Commit Graph

1889 Commits

Author SHA1 Message Date
Brent Royal-Gordon
121fa9a058 Ignore transitive ObjC imports when cross-importing
This behavior change reduces the chance of unexpected and unwanted cross-imports being performed.

Fixes rdar://problem/60554019.
2020-04-05 19:06:59 -07:00
Nathan Lanza
a49bceeedf Convert a clang::Module to non-const to account for a clang API change
An upstream clang changed ASTSourceDescriptor to not have a const
Module pointer. const_cast here to make this agree.
2020-04-03 19:42:08 -04:00
swift_jenkins
14a14a232b Merge remote-tracking branch 'origin/master' into master-next 2020-04-01 09:00:36 -07:00
Anthony Latsis
c63b737e92 Collapse all indirect equivalents to ValueDecl::getBaseIdentifier 2020-03-29 00:36:01 +03:00
Michael Forster
345a9147ec Explicit SmallString->std::string conversion.
This is only needed temporarily until commit d7049213 from upstream
LLVM hits the swift/master branch.
2020-03-13 19:16:49 +01:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Adrian Prantl
1bd6a0a371 Adapt to upstream header file reshuffling in c915cb957dc37275ce1ca1a0b993239c82f12692. 2020-03-11 15:46:37 -07:00
Rintaro Ishizaki
a7cb72fe55 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	stdlib/public/Reflection/TypeRefBuilder.cpp
2020-03-10 12:46:49 -07:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08:00
swift_jenkins
23599f42a4 Merge remote-tracking branch 'origin/master' into master-next 2020-03-05 23:00:20 -08:00
Doug Gregor
c84bec752f [Clang importer] Suppress method imports found via selector lookup.
When we found Objective-C methods via selector lookup, we would skip the
“should we even try to import this?” check. If the Swift-name-as-derived-
from-Objective-C is different from the actual Swift name, we might try to
(redundantly) import something from the generated Objective-C header,
which can lead to crashes. The specific method causing problems was defined
like this in Swift:

    @objc public class func using(index: AnyObject) -> AnyObject? { return nil }

which produced an Objective-C method like this:

    + (id _Nullable)usingIndex:(id _Nonnull)index;

The Swift name derived from the Objective-C method is `usingIndex(_:)`, which
of course does not match `using(index:)`, meaning that we think these two
methods are different (they aren’t).

The safe fix is to check whether we should import a given Objective-C method
declaration along the found-via-Objective-C-selector path, like we do with
normal name lookup. A longer term fix is to emit swift_name attributes for
such methods.

Fixes the fiendish Clang importer crash in rdar://problem/60046206.
2020-03-05 18:34:29 -08:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
swift_jenkins
2bcdc4c0c8 Merge remote-tracking branch 'origin/master' into master-next 2020-02-26 15:59:46 -08:00
Xi Ge
e50096fe22 Merge pull request #30080 from nkcsgexi/ObjCCategoryDecl-canonical
ClangImporter: import non-canonical ObjCCategoryDecl after recent clang changes
2020-02-26 15:49:12 -08:00
Xi Ge
3fe4b89dbf ClangImporter: import non-canonical ObjCCategoryDecl after recent clang changes
Recent clang side change merges ObjCCategoryDecl with the same name. All re-declarations
of a category points to the first category as the canonical one. This patch keeps these
non-canonical redeclarations as separate extensions in Swift.

rdar://problem/59744309
2020-02-26 13:41:09 -08:00
swift_jenkins
28961d1da5 Merge remote-tracking branch 'origin/master' into master-next 2020-02-25 16:40:26 -08:00
Hamish Knight
d9182af63d [AST] Introduce ModuleDecl::getTopLevelModule
This can be used to retrieve the Swift module
wrapper for a Clang submodule's top-level module.
2020-02-24 20:10:13 -08:00
swift_jenkins
a2e41771fc Merge remote-tracking branch 'origin/master' into master-next 2020-02-19 09:19:25 -08:00
Brent Royal-Gordon
e248f82773 Add support for loading cross-import files 2020-02-18 11:06:12 -08:00
swift_jenkins
3c5f01d13b Merge remote-tracking branch 'origin/master' into master-next 2020-02-12 19:17:13 -08:00
Slava Pestov
0b502d8c84 AST: loadNamedMembers() never fails
This allows us to simplify lookupDirect() a fair bit as well.
2020-02-12 18:32:46 -05:00
Robert Widmann
86ea1912c4 Merge remote-tracking branch 'upstream/master' into HEAD 2020-02-11 23:03:59 -08:00
swift-ci
b8eceebd6d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-08 21:43:28 -08:00
Slava Pestov
7c3cf1d17b ClangImporter: Fix mirroring of instance properties as static methods on NSObject
Because all metaclasses ultimately inherit from NSObject, instance
members of NSObject are also visible as static members of NSObject.

If the instance member is a property, we import the getter as an
ordinary static method, and not a static property.

The lazy loading path normally checks for the presence of alternate
decls with the same name, but it was failing to do this check if the
imported decl was a property and the alternate decl was attached to
the accessor and not the property itself.

This wasn't a problem until recently, because we weren't lazy loading
members of NSObject itself, since it had protocol conformances; now
that we are, this problem was exposed.

Fixes <rdar://problem/59170514>.
2020-02-08 00:06:21 -05:00
swift_jenkins
df468386e8 Merge remote-tracking branch 'origin/master' into master-next 2020-02-04 11:58:45 -08:00
swift-ci
6ab5fec4f2 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 11:44:06 -08:00
Slava Pestov
d76a8ce920 ClangImporter: Lazily load mirrored protocol members in classes 2020-02-04 09:54:06 -05:00
Slava Pestov
6ba379f3b9 ClangImporter: Refactor loadObjCMethods() to not call CollectMultipleMethodsInGlobalPool()
Let's try calling ObjCInterface::lookupMethod() instead. This also
eliminates an order dependency between selector conflict checking
and protocol member mirroring, which fixes a diagnostics regression
once lazy loading is enabled for mirrored protocol members.
2020-02-04 09:54:06 -05:00
Slava Pestov
c8f990b800 ClangImporter: Don't force loading of all superclass members in loadNamedMembers() 2020-02-04 09:54:06 -05:00
Fred Riss
a3afd8b155 Adapt to llvm.org StringRef API change 2020-01-31 15:36:19 -08:00
swift-ci
72229ba355 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-24 16:43:36 -08:00
swift_jenkins
d7506614d3 Merge remote-tracking branch 'origin/master' into master-next 2020-01-24 16:38:09 -08:00
Slava Pestov
305620b354 ClangImporter: Reconcile Clang declaration hidden-ness between loadAllMembers() and lazy loading
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.
2020-01-24 17:07:08 -05:00
Erik Eckstein
59035faf1b Merge remote-tracking branch 'origin/master' into master-next 2020-01-22 10:26:14 +01:00
Erik Eckstein
bbfaccda4b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 08:25:23 +01:00
Devin Coughlin
082421048a [AST/Sema] Add availability attributes for macCatalyst
Add a platform kind and availability attributes for macCatalyst. macCatalyst
uses iOS version numbers and inherits availability from iOS attributes unless
a macCatalyst attribute is explicitly provided.
2020-01-21 20:27:14 -08:00
swift-ci
04e29f0878 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 15:23:13 -08:00
swift_jenkins
5084d32414 Merge remote-tracking branch 'origin/master' into master-next 2020-01-16 15:17:50 -08:00
Robert Widmann
e79281d86c Nail Down The Emergent Behaviors of the ClangImporter's Override Checking
The Clang Importer allows for the creation of otherwise illegal Swift
ASTs because it does not run redeclaration checking or override
checking. These behaviors are also not a part of our test suite.

Correct the first issue by re-instating the old emergent behavior of
member loading occurring at all points in the class hierarchy before
a (lazy) lookup.

Correct the second issue by adding a regression test for a common
failure mode in the post-re-entrant-lookup Clang Importer.

We cannot stop accepting these cases, but a future compiler will warn
about them.

Attacks rdar://58493370
2020-01-16 13:18:52 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
swift_jenkins
c4e328580e Merge remote-tracking branch 'origin/master' into master-next 2020-01-15 07:57:48 -08:00
Robert Widmann
1f59f10f44 Unwind the Bogus Delayed Categories Hack
Delayed categories only existed to keep
ClangImporter/objc_redeclared_properties passing.  But this test
appears to exhibit incorrect behavior as written.

The clang importer implements limited behavior for overwriting
variable declarations. If that overwrite occurs somewhere else in the
class hierarchy, the declaration is rewritten as a Swift override.  The
remaining case is categories, which enable all sorts of awful
redeclaration behaviors.  When a bridging header declares a category
that tries to stomp the API surface of another category, we need to
import that category first, and we would import that category first - by
accident.  Re-entrancy does have its upsides.

In order to keep the tests passing post re-entrant lookup, we stubbed in a hack that delayed
categories in the bridging header so they were installed last, which
meant the variable merging logic would mostly decline to import those
properties.  But the rest of the world expects the opposite: Bridging
header contents are more sacred than the rest of the SDK and must be
installed *first* in order for a number of nightmarish header hacks to
go through.

Unwind the old, incorrect emergent behavior and re-establish the
correct behavior as the way the world ought to work.

Resolves rdar://58493356, rdar://58493357, rdar://58493362, rdar://58493370
2020-01-14 21:42:52 -08:00
Arnold Schwaighofer
0c99cd9734 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 08:00:41 -08:00
swift_jenkins
24eb03c663 Merge remote-tracking branch 'origin/master' into master-next 2020-01-08 23:17:22 -08:00
Robert Widmann
b05a6223da Merge pull request #29090 from CodaFi/globe-up
[NFC] Unblock Lazy Member Loading For Import-As-Member
2020-01-08 23:09:56 -08:00
Robert Widmann
518ab9f22f [NFC] Unblock Lazy Member Loading For Import-As-Member
Lazy member loading had an antagonistic relationship with the import-as-member facilities. The member tables were stored in a hash map that is keyed by serialized declaration context.  While this was good for importing the entire member set of a given extension, it's in the complete wrong order for lazy member loading, which wants the same data keyed by base name.

Given that it is annoying to redo the globals-as-member tables to support one use case or the other, coupled with the fact that optimizing for one use-case automatically pessimizes the other, just take a page from rdar://18696086 and store the same information twice in two separate formats each optimized for the task at hand.

Preliminary benchmarks indicate that this leads to a 5% reduction in Clang-Imported entities which will drastically speed up most apps that use Dispatch and CoreGraphics.
2020-01-08 21:25:00 -08:00
swift_jenkins
8a3c5c753b Merge remote-tracking branch 'origin/master' into master-next 2020-01-08 09:57:24 -08:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Varun Gandhi
afc6ccdeb5 Re-land parsing and printing for Clang function types.
This reverts commit e805fe486e, which reverted
the change earlier. The problem was caused due to a simultaneous change to some
code by the PR with parsing and printing for Clang function types (#28737)
and the PR which introduced Located<T> (#28643).

This commit also includes a small change to make sure the intersecting region
is fixed: the change is limited to using the fields of Located<T> in the
`tryParseClangType` lambda.
2020-01-07 15:58:32 -08:00
Saleem Abdulrasool
e805fe486e Revert "Clang function types v2: Electric Boogaloo (parsing + printing)" 2020-01-06 16:26:08 -08:00