Commit Graph

386 Commits

Author SHA1 Message Date
Doug Gregor
bf99f31d75 Revert "PrintAsObjc: expand module @imports to header #imports if modules are not supported"
This reverts commit a2534fa234.
2020-03-27 21:02:44 -07:00
Doug Gregor
6a7a7ff781 Revert "PrintAsObjc: strip Headers and PrivateHeaders component in header paths explicitly"
This reverts commit 411833d931.
2020-03-27 21:02:32 -07:00
Doug Gregor
ab97d50b0f Revert "PrintAsObjC: use header path relative to usr/include when importing non-framework headers"
This reverts commit ebe0a45583.
2020-03-27 21:00:51 -07:00
Xi Ge
ebe0a45583 PrintAsObjC: use header path relative to usr/include when importing non-framework headers
We could assume usr/include belongs to header search paths. If a header
is located in a deeper location inside this directory, we need to print
the additional path components.

rdar://60857172
2020-03-25 23:30:28 -07:00
Xi Ge
411833d931 PrintAsObjc: strip Headers and PrivateHeaders component in header paths explicitly
We use Header::NameAsWritten to collect the path of a header belongs to a module. Due
to an unclear clang-side issue, the path may contain "Headers/" and "PrivateHeaders/". To
walk-around this potential issue, we explicit check and remove these path components
from the Swift side.

rdar://problem/60249751
2020-03-10 14:30:09 -07:00
Xi Ge
a2534fa234 PrintAsObjc: expand module @imports to header #imports if modules are not supported
rdar://58284119
2020-03-03 11:54:14 -08:00
Xi Ge
fa659ede76 [PrintAsObjc] add macro guard against potential recursive definitions 2020-02-05 12:37:01 -08:00
Slava Pestov
eef1428a2b PrintAsObjC: Support for blocks with __owned parameters 2019-12-02 18:41:27 -05:00
Jordan Rose
83e7763e9f [PrintAsObjC] Separate out module contents printing too (#27184)
The top-level PrintAsObjC now just covers import printing and the
near-literal prologue/epilogue text, while the decl printing (and
import collecting) is in its own file. No functionality change.
2019-09-13 20:13:59 -07:00
Jordan Rose
efa350a05a [PrintAsObjC] Pull the actual decl/type printer out to a separate file
I've tried several times to separate the type printing from the
decl-printing and found it tricky, but at least both can be separated
from the logic of walking the top-level decls in a module and
scheduling them appropriately. No functionality change.
2019-09-12 20:17:02 -07:00
Slava Pestov
c450b45e89 AST: Clean up a couple of uses of UnqualifiedLookup
We can use type lookup in more places, and switch a couple of callers
to use qualified lookup instead.
2019-08-24 22:34:35 -04:00
Slava Pestov
2dbeeb0d3f AST: Make SubstFlags::UseErrorType the default behavior
We've fixed a number of bugs recently where callers did not expect
to get a null Type out of subst(). This occurs particularly often
in SourceKit, where the input AST is often invalid and the types
resulting from substitution are mostly used for display.

Let's fix all these potential problems in one fell swoop by changing
subst() to always return a Type, possibly one containing ErrorTypes.

Only a couple of places depended on the old behavior, and they were
easy enough to change from checking for a null Type to checking if
the result responds with true to hasError().

Also while we're at it, simplify a few call sites of subst().
2019-08-22 01:07:50 -04:00
Slava Pestov
80ccbe5116 AST: Stop passing around a LazyResolver in name lookup
Note that in all cases it was either nullptr or ctx.getLazyResolver().
While passing in nullptr might appear at first glance to mean something
("don't type check anything"), in practice we would check for a nullptr
value and pull out ctx.getLazyResolver() instead. Furthermore, with
the lazy resolver going away (at least for resolveDeclSignature() calls),
it won't make sense to do that anymore anyway.
2019-08-19 23:00:57 -04:00
Slava Pestov
1c3ac86796 AST: Banish OptionalTypeKind to ClangImporter.h
The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
2019-08-15 18:41:42 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
0c5d52d860 AST: Introduce AbstractStorageDecl::get{Parsed,Opaque}Accessor()
Also, change visitOpaqueAccessors() to call getOpaqueAccessor() instead of
asserting if the expected accessor does not exist.
2019-08-02 19:34:43 -04:00
Slava Pestov
64c32c695b AST: Remove a few utility methods from AbstractStorageDecl
Since the return value of getAccessor() depends on mutable state, it
does not make sense in the request evaluator world. Let's begin by
removing some utility methods derived from getAccessor(), replacing
calls to them with calls to getAccessor().
2019-08-01 18:31:58 -04:00
Slava Pestov
5826db5d56 AST: Add AbstractFunctionDecl::hasDynamicSelfResult() and use it
This calculates a result directly from the function's result type
instead of checking a bit that was previously set by the type
checker. Also, always returns true for constructors to simplify
some callers.
2019-06-26 01:10:12 -04:00
Slava Pestov
8f22da205a Sema: Stop wrapping Self returns in protocols with DynamicSelfType 2019-06-26 01:10:11 -04:00
Rintaro Ishizaki
db2c11787b [AST] Inherit doc-brief comment from protocol, superclass, and requirement
rdar://problem/38422822
2019-06-20 10:04:05 -07:00
Jordan Rose
406a9d9cf1 Add the notion of @_implementationOnly overrides
When an @_implementationOnly import includes Objective-C categories
for existing types, it's useful to be able to override the members
provided in those categories without exposing them to clients of the
framework being built. Allow this as long as the overriding
declaration is marked as @_implementationOnly itself, with an
additional check that the type of the declaration does not change.
(Normally overrides are allowed to change in covariant ways.)

Part of rdar://50827914
2019-06-17 17:48:40 -07:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
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
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
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