Commit Graph

378 Commits

Author SHA1 Message Date
Slava Pestov
6e3609dc22 AST: ProtocolConformanceRef::getTypeWitnessByName() should be an instance method 2019-05-14 19:28:55 -04:00
Slava Pestov
644b6adcd2 AST: Simplify ProtocolConformanceRef::getTypeWitnessByName() 2019-05-10 15:00:48 -04:00
Slava Pestov
52fbe642ed Fix REQUIRES lines on class stubs tests
We use the just-built clang without any -target or -sdk flags. Keep things
simple and limit the test to macOS for now.

Fixes <rdar://problem/50586614>.
2019-05-08 22:22:27 -04:00
Nathan Hawes
af3fbc52b3 Revert "Add tests for weak-linked class stubs" 2019-05-08 10:55:00 -07:00
Slava Pestov
1b4f171fd4 PrintAsObjC: Add support for @_weakLinked attribute
Clang already takes availability into account when checking if a
declaration is weak imported, so this is only needed for testing.
2019-05-07 16:32:01 -04:00
Slava Pestov
2ad15fec3d PrintAsObjC: Add support for classes with resilient ancestry
Without -enable-resilient-objc-class-stubs, don't print classes with
resilient ancestry at all, since they're not actually visible to
Clang and referencing one will not actually work.

When the flag is specified, such classes do appear in the generated
header with the new objc_class_stub Clang attribute.
2019-03-26 18:58:13 -04:00
Saleem Abdulrasool
9934532e07 cmake: switch host libraries to use target_link_libraries
This is a follow up to the discussion on #22740 to switch the host
libraries to use the `target_link_libraries` rather than the
`LINK_LIBRARIES` special handling.  This allows the dependency to be
properly tracked by CMake and allows us to use the more modern syntax.
2019-02-22 15:28:07 -08:00
Pavel Yaskevich
ddc2fa415e [AST] NFC: introduce ASTContext::isAccessControlDisabled 2019-01-11 17:30:10 -08:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Brent Royal-Gordon
1a6ca82d6b [NFC] Extract helper for making NSError domains
Avoids having to coordinate changes in two different parts of the compiler.
2018-12-21 15:30:35 -08:00
Pitiphong Phongpattranont
c52b9f927d Run clang-format on the PrintAsObjC.cpp file 2018-12-14 14:22:02 +07:00
Pitiphong Phongpattranont
611b1fe55f Change the isa<FuncDecl> checking to be AbstractFunctionDecl instead 2018-12-13 14:04:32 +07:00
Pitiphong Phongpattranont
96094ac545 Fixed: Build failed due to the merging/rebasing 2018-12-13 13:49:07 +07:00
Pitiphong Phongpattranont
b0ce3406eb Ignore the Context Name in the rename declaration on most of the cases 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
1ced4b3c83 Check the function parameter type only for the rename to overloaded methods 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
7b76115788 Remove the parent/sub type lookup logic 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
aa72ea8347 Run clang-format on the Print Availability and its related methods 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
198f8e9f9b Run clang-format on the Print Availability and its related methods 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
ba52903d35 Reduce the Type Match scope when comparing the method parameters 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
3f6a741a90 Introduce an ASTContext local variable in the method 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
1d6f4923af Extract the finding the proper objc renamed Decl into getRenameDecl method 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
c0e887d98b Remove unnecsessary TypeMatchFlags::AllowTopLevelOptionalMismatch matching option 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
ac3a4122fd Remove debugging print statements 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
c23230c1e7 Revert part of the Follow the base type to follow only in its own superclasses 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
f1729c3d14 Use the matchesParameter method instead of direct comparison to check the type of the parameter 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
e6a056d27e Checking if the ContextName of the Renamed Decl is empty or not instead of checking if it’s a special decl instead 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
293d3d1033 Find the renamed overloading method by looking at the type of method parameters 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
a505202e6d Follow the base type if the renamed attribute is point to another type 2018-12-13 12:16:57 +07:00
Michael Gottesman
a761d7c0ba Revert "Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library"""
This reverts commit 121f5b64be.

Sorry to revert this again. This commit makes some pretty big changes. After
messing with the merge-conflict created by this internally, I did not feel
comfortable landing this now. I talked with Saleem and he agreed with me that
this was the right thing to do.
2018-11-06 13:24:00 -08:00
Saleem Abdulrasool
121f5b64be Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library""
This reverts commit 103f9a8246.
2018-11-05 14:37:40 -08:00
Brent Royal-Gordon
746fb2864e [PrintAsObjC] Disable -Watimport-in-framework-header warning in generated headers (#20086)
This is a new warning in clang when you use @import in a framework header. That’s often a mistake, but it isn’t in our generated -Swift.h headers. If we’re building with a clang that supports this warning, we’ll now emit a pragma to disable it.
2018-11-02 19:02:17 -07:00
Xi Ge
103f9a8246 Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library" 2018-11-02 12:49:07 -07:00
Saleem Abdulrasool
39dde93c88 add_swift_host_library: rename LINK_LIBRARIES to LINK_LIBS 2018-10-31 12:46:31 -07:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Jordan Rose
e34a6a1105 [PrintAsObjC] Look through "compatibility" typealiases (#20027)
These handle imported types that have been renamed in a /later/ Swift
version than the one being used; for consistency when deserializing
from a swiftmodule, the latest name is always used. This is important
because it might mean we can avoid importing the framework that a name
comes from; a forward declaration might be sufficient if it's an ObjC
class or protocol.

rdar://problem/45491607
2018-10-25 08:26:17 -07:00
Slava Pestov
3b60ae153d AST: Rename AnyFunctionType::Param::getType() to getOldType() 2018-09-26 11:05:23 -07:00
Jordan Rose
71760bcc4e Replace StringMap with DenseMap when the keys don't need to be owned
StringMap always copies its strings into its own storage. A DenseMap
of StringRefs has the same caveats as any other use of StringRef, but
in the cases I've changed the string has very clear ownership that
outlives the map.

No functionality change, but should reduce memory usage and malloc
traffic a little.
2018-09-13 15:15:27 -07:00
Jordan Rose
f68054470d Merge pull request #19167 from jrose-apple/proper-property-properties
[PrintAsObjC] Use 'unsafe_unretained' to print 'unowned', not 'assign'
2018-09-10 16:14:57 -07:00
Jordan Rose
340090c6af [PrintAsObjC] Refactor printing of property ownership attributes
Exhaustively switch over reference types, so that we'll know if any
new ones are added, and factor out a repeated check to see if
something's a retainable object type.

No functionality change.
2018-09-10 14:33:05 -07:00
Jordan Rose
0bcf355bc8 [PrintAsObjC] Use 'unsafe_unretained' to print 'unowned', not 'assign'
The ObjC generator previously preserved a subtle difference between
'unowned' and 'unowned(unsafe)' / Unmanaged by printing the former as
'assign' and the latter as 'unsafe_unretained'. Upstream Clang,
however, has gotten a new warning to discourage the use of 'assign'
with reference-countable types at all. Since it was always a subtle
distinction, just go with the new convention and print
'unsafe_unretained' for 'unowned' properties as well.

rdar://problem/44290715
2018-09-10 14:32:32 -07:00
Jordan Rose
37ec248823 Add ModuleDecl::ReverseFullNameIterator
Package up the logic that generates a full Clang module name, so that
(a) we don't have to deal with clang::Module in quite as many places
in the /Swift/ compiler, and (b) we can avoid the cost of a temporary
string in a few places.

The main places where this is /not/ adopted is where we don't just
want to know the parent module name, but actually the module itself.
This is mostly indexing-related queries, which use the very similar
ModuleEntity class also defined in Module.h. I didn't quite see an
obvious way to unify these, but that might be where we want to go.

No functionality change.
2018-09-06 19:53:59 -07:00
Jordan Rose
ad7bbdfbd6 [PrintAsObjC] Handle generic typealiases (#18941)
(either explicitly generic ones, or those embedded in generic contexts)

Previously we tried to look at the typealias decl's underlying type,
but that might have generic parameters in it. Oops. Use the
NameAliasType's desugared type instead.

Also, drop half-baked support for `@objc typealias`, which isn't
supported. (It's not an unreasonable feature, but the bits that were
there weren't implemented correctly.)

rdar://problem/43347303
2018-08-24 08:57:22 -07:00
Jordan Rose
537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07:00
Doug Gregor
2c519b8b53 Eliminate two trivial uses of lookupQualified(Type, ...). 2018-08-14 01:05:43 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
7e623dd927 Merge remote-tracking branch 'origin/master' into master-next 2018-08-01 11:09:11 -07:00
Jordan Rose
2dcac4bcb2 Merge pull request #18408 from jrose-apple/default-on-your-futures
[SIL] Don't drop a default when switching on a non-exhaustive enum

rdar://problem/42775178
2018-08-01 10:54:19 -07:00
Jordan Rose
b25e561e82 Rename EnumDecl::isExhaustive to isFormallyExhaustive
...in preparation for an isEffectivelyExhaustive coming in the next
commit.
2018-07-31 19:01:00 -07:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00