Skip to content

Commit cd1400d

Browse files
committed
Merge branch 'master' of github.com:apple/swift into upstream-transpose-attr
2 parents aecf9a1 + fdb1926 commit cd1400d

File tree

105 files changed

+2035
-1500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2035
-1500
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
8686

8787
#### macOS
8888

89-
To build for macOS, you need [Xcode 11.2](https://developer.apple.com/xcode/downloads/).
89+
To build for macOS, you need [Xcode 11.3](https://developer.apple.com/xcode/downloads/).
9090
The required version of Xcode changes frequently, and is often a beta release.
9191
Check this document or the host information on <https://ci.swift.org> for the
9292
current required version.

benchmark/utils/DriverUtils.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,10 @@ final class TestRunner {
412412
private static func getExecutedInstructions() -> UInt64 {
413413
if #available(OSX 10.9, iOS 7.0, *) {
414414
var u = rusage_info_v4()
415-
let p = UnsafeMutablePointer(&u)
416-
p.withMemoryRebound(to: Optional<rusage_info_t>.self, capacity: 1) { up in
417-
let _ = proc_pid_rusage(getpid(), RUSAGE_INFO_V4, up)
415+
withUnsafeMutablePointer(to: &u) { p in
416+
p.withMemoryRebound(to: Optional<rusage_info_t>.self, capacity: 1) { up in
417+
let _ = proc_pid_rusage(getpid(), RUSAGE_INFO_V4, up)
418+
}
418419
}
419420
return u.ri_instructions
420421
} else {

docs/CompilerPerformance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ performance between two compilers, say `${OLD}/swiftc` and `${NEW}/swiftc`:
793793
```
794794
$ mkdir stats-old stats-new
795795
$ ${OLD}/swiftc -stats-output-dir stats-old test.swift
796-
$ ${OLD}/swiftc -stats-output-dir stats-new test.swift
796+
$ ${NEW}/swiftc -stats-output-dir stats-new test.swift
797797
$ utils/process-stats-dir.py --compare-stats-dirs stats-old stats-new
798798
old new delta_pct name
799799
1402939 1430732 1.98 AST.NumASTBytesAllocated

include/swift/ABI/Metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ using TargetRelativeIndirectablePointer
160160

161161
struct HeapObject;
162162
class WeakReference;
163+
struct UnownedReference;
163164

164165
template <typename Runtime> struct TargetMetadata;
165166
using Metadata = TargetMetadata<InProcess>;
@@ -645,6 +646,9 @@ struct TargetMetadata {
645646
// NOTE: This *is* a box for copy-on-write existentials.
646647
OpaqueValue *allocateBoxForExistentialIn(ValueBuffer *Buffer) const;
647648

649+
// Deallocate an out-of-line buffer box if one is present.
650+
void deallocateBoxForExistentialIn(ValueBuffer *Buffer) const;
651+
648652
/// Get the nominal type descriptor if this metadata describes a nominal type,
649653
/// or return null if it does not.
650654
ConstTargetMetadataPointer<Runtime, TargetTypeContextDescriptor>

include/swift/ABI/MetadataValues.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -913,55 +913,6 @@ class TargetTupleTypeFlags {
913913
};
914914
using TupleTypeFlags = TargetTupleTypeFlags<size_t>;
915915

916-
/// Field types and flags as represented in a nominal type's field/case type
917-
/// vector.
918-
class FieldType {
919-
typedef uintptr_t int_type;
920-
// Type metadata is always at least pointer-aligned, so we get at least two
921-
// low bits to stash flags. We could use three low bits on 64-bit, and maybe
922-
// some high bits as well.
923-
enum : int_type {
924-
Indirect = 1,
925-
Weak = 2,
926-
927-
TypeMask = ((uintptr_t)-1) & ~(alignof(void*) - 1),
928-
};
929-
int_type Data;
930-
931-
constexpr FieldType(int_type Data) : Data(Data) {}
932-
public:
933-
constexpr FieldType() : Data(0) {}
934-
FieldType withType(const Metadata *T) const {
935-
return FieldType((Data & ~TypeMask) | (uintptr_t)T);
936-
}
937-
938-
constexpr FieldType withIndirect(bool indirect) const {
939-
return FieldType((Data & ~Indirect)
940-
| (indirect ? Indirect : 0));
941-
}
942-
943-
constexpr FieldType withWeak(bool weak) const {
944-
return FieldType((Data & ~Weak)
945-
| (weak ? Weak : 0));
946-
}
947-
948-
bool isIndirect() const {
949-
return bool(Data & Indirect);
950-
}
951-
952-
bool isWeak() const {
953-
return bool(Data & Weak);
954-
}
955-
956-
const Metadata *getType() const {
957-
return (const Metadata *)(Data & TypeMask);
958-
}
959-
960-
int_type getIntValue() const {
961-
return Data;
962-
}
963-
};
964-
965916
/// Flags for exclusivity-checking operations.
966917
enum class ExclusivityFlags : uintptr_t {
967918
Read = 0x0,

include/swift/AST/Expr.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,17 +1741,6 @@ class DynamicSubscriptExpr final
17411741
llvm::function_ref<Type(const Expr *)> getType =
17421742
[](const Expr *E) -> Type { return E->getType(); });
17431743

1744-
/// Create a new dynamic subscript.
1745-
static DynamicSubscriptExpr *create(ASTContext &ctx, Expr *base,
1746-
SourceLoc lSquareLoc,
1747-
ArrayRef<Expr *> indexArgs,
1748-
ArrayRef<Identifier> indexArgLabels,
1749-
ArrayRef<SourceLoc> indexArgLabelLocs,
1750-
SourceLoc rSquareLoc,
1751-
Expr *trailingClosure,
1752-
ConcreteDeclRef decl,
1753-
bool implicit);
1754-
17551744
/// getIndex - Retrieve the index of the subscript expression, i.e., the
17561745
/// "offset" into the base value.
17571746
Expr *getIndex() const { return Index; }
@@ -3748,7 +3737,8 @@ class AutoClosureExpr : public AbstractClosureExpr {
37483737
DeclContext *Parent)
37493738
: AbstractClosureExpr(ExprKind::AutoClosure, ResultTy, /*Implicit=*/true,
37503739
Discriminator, Parent) {
3751-
setBody(Body);
3740+
if (Body != nullptr)
3741+
setBody(Body);
37523742
}
37533743

37543744
SourceRange getSourceRange() const;

include/swift/AST/Module.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ inline bool DeclContext::isModuleScopeContext() const {
629629
return isModuleContext();
630630
}
631631

632+
/// Extract the source location from the given module declaration.
633+
inline SourceLoc extractNearestSourceLoc(const ModuleDecl *mod) {
634+
return extractNearestSourceLoc(static_cast<const Decl *>(mod));
635+
}
636+
632637
} // end namespace swift
633638

634639
namespace llvm {

include/swift/AST/NameLookupRequests.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,45 @@ class AnyObjectLookupRequest
405405
NLOptions options) const;
406406
};
407407

408+
class ModuleQualifiedLookupRequest
409+
: public SimpleRequest<ModuleQualifiedLookupRequest,
410+
QualifiedLookupResult(const DeclContext *,
411+
ModuleDecl *, DeclNameRef,
412+
NLOptions),
413+
CacheKind::Uncached> {
414+
public:
415+
using SimpleRequest::SimpleRequest;
416+
417+
private:
418+
friend SimpleRequest;
419+
420+
// Evaluation.
421+
llvm::Expected<QualifiedLookupResult> evaluate(Evaluator &evaluator,
422+
const DeclContext *DC,
423+
ModuleDecl *mod, DeclNameRef name,
424+
NLOptions opts) const;
425+
};
426+
427+
class QualifiedLookupRequest
428+
: public SimpleRequest<QualifiedLookupRequest,
429+
QualifiedLookupResult(const DeclContext *,
430+
SmallVector<NominalTypeDecl *, 4>,
431+
DeclNameRef, NLOptions),
432+
CacheKind::Uncached> {
433+
public:
434+
using SimpleRequest::SimpleRequest;
435+
436+
private:
437+
friend SimpleRequest;
438+
439+
// Evaluation.
440+
llvm::Expected<QualifiedLookupResult>
441+
evaluate(Evaluator &evaluator, const DeclContext *DC,
442+
SmallVector<NominalTypeDecl *, 4> decls,
443+
DeclNameRef name,
444+
NLOptions opts) const;
445+
};
446+
408447
#define SWIFT_TYPEID_ZONE NameLookup
409448
#define SWIFT_TYPEID_HEADER "swift/AST/NameLookupTypeIDZone.def"
410449
#include "swift/Basic/DefineTypeIDZone.h"

include/swift/AST/NameLookupTypeIDZone.def

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18+
SWIFT_REQUEST(NameLookup, AnyObjectLookupRequest,
19+
QualifiedLookupResult(const DeclContext *, DeclName, NLOptions),
20+
Uncached, NoLocationInfo)
1821
SWIFT_REQUEST(NameLookup, CustomAttrNominalRequest,
1922
NominalTypeDecl *(CustomAttr *, DeclContext *), Cached,
2023
NoLocationInfo)
@@ -34,6 +37,20 @@ SWIFT_REQUEST(NameLookup, InheritedDeclsReferencedRequest,
3437
DirectlyReferencedTypeDecls(
3538
llvm::PointerUnion<TypeDecl *, ExtensionDecl *>, unsigned),
3639
Uncached, HasNearestLocation)
40+
SWIFT_REQUEST(NameLookup, LookupInModuleRequest,
41+
QualifiedLookupResult(const DeclContext *, DeclName, NLKind,
42+
namelookup::ResolutionKind,
43+
const DeclContext *),
44+
Uncached, NoLocationInfo)
45+
SWIFT_REQUEST(NameLookup, ModuleQualifiedLookupRequest,
46+
QualifiedLookupResult(
47+
const DeclContext *, ModuleDecl *, DeclNameRef, NLOptions),
48+
Uncached, NoLocationInfo)
49+
SWIFT_REQUEST(NameLookup, QualifiedLookupRequest,
50+
QualifiedLookupResult(
51+
const DeclContext *, SmallVector<NominalTypeDecl *, 4>,
52+
DeclNameRef, NLOptions),
53+
Uncached, NoLocationInfo)
3754
SWIFT_REQUEST(NameLookup, SelfBoundsFromWhereClauseRequest,
3855
SelfBounds(llvm::PointerUnion<TypeDecl *, ExtensionDecl *>),
3956
Uncached, NoLocationInfo)
@@ -48,11 +65,3 @@ SWIFT_REQUEST(NameLookup, UnderlyingTypeDeclsReferencedRequest,
4865
SWIFT_REQUEST(NameLookup, UnqualifiedLookupRequest,
4966
LookupResult(UnqualifiedLookupDescriptor), Uncached,
5067
NoLocationInfo)
51-
SWIFT_REQUEST(NameLookup, LookupInModuleRequest,
52-
QualifiedLookupResult(const DeclContext *, DeclName, NLKind,
53-
namelookup::ResolutionKind,
54-
const DeclContext *),
55-
Uncached, NoLocationInfo)
56-
SWIFT_REQUEST(NameLookup, AnyObjectLookupRequest,
57-
QualifiedLookupResult(const DeclContext *, DeclName, NLOptions),
58-
Uncached, NoLocationInfo)

include/swift/AST/ParameterList.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ class alignas(ParamDecl *) ParameterList final :
103103
/// Change the DeclContext of any contained parameters to the specified
104104
/// DeclContext.
105105
void setDeclContextOfParamDecls(DeclContext *DC);
106-
107-
106+
108107
/// Flags used to indicate how ParameterList cloning should operate.
109108
enum CloneFlags {
110109
/// The cloned ParamDecls should be marked implicit.
111110
Implicit = 0x01,
112-
/// The cloned pattern is for an inherited constructor; mark default
113-
/// arguments as inherited, and mark unnamed arguments as named.
111+
/// Mark default arguments as inherited.
114112
Inherited = 0x02,
113+
/// Mark unnamed arguments as named.
114+
NamedArguments = 0x04,
115115
};
116116

117117
friend OptionSet<CloneFlags> operator|(CloneFlags flag1, CloneFlags flag2) {

include/swift/AST/Type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ class Type {
371371
void operator!=(Type T) const = delete;
372372
};
373373

374+
/// Extract the source location from a given type.
375+
SourceLoc extractNearestSourceLoc(Type ty);
376+
374377
/// CanType - This is a Type that is statically known to be canonical. To get
375378
/// one of these, use Type->getCanonicalType(). Since all CanType's can be used
376379
/// as 'Type' (they just don't have sugar) we derive from Type.

include/swift/AST/TypeCheckRequests.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,29 @@ class TypeCheckSourceFileRequest :
19681968
void cacheResult(bool result) const;
19691969
};
19701970

1971+
/// Computes whether the specified type or a super-class/super-protocol has the
1972+
/// @dynamicMemberLookup attribute on it.
1973+
class HasDynamicMemberLookupAttributeRequest
1974+
: public SimpleRequest<HasDynamicMemberLookupAttributeRequest,
1975+
bool(CanType), CacheKind::Cached> {
1976+
public:
1977+
using SimpleRequest::SimpleRequest;
1978+
1979+
private:
1980+
friend SimpleRequest;
1981+
1982+
// Evaluation.
1983+
llvm::Expected<bool> evaluate(Evaluator &evaluator, CanType ty) const;
1984+
1985+
public:
1986+
bool isCached() const {
1987+
// Don't cache types containing type variables, as they must not outlive
1988+
// the constraint system that created them.
1989+
auto ty = std::get<0>(getStorage());
1990+
return !ty->hasTypeVariable();
1991+
}
1992+
};
1993+
19711994
// Allow AnyValue to compare two Type values, even though Type doesn't
19721995
// support ==.
19731996
template<>

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ SWIFT_REQUEST(TypeChecker, HasCircularInheritedProtocolsRequest,
7373
bool(ProtocolDecl *), Cached, NoLocationInfo)
7474
SWIFT_REQUEST(TypeChecker, HasCircularRawValueRequest,
7575
bool(EnumDecl *), Cached, NoLocationInfo)
76+
SWIFT_REQUEST(TypeChecker, HasDynamicMemberLookupAttributeRequest,
77+
bool(CanType), Cached, NoLocationInfo)
7678
SWIFT_REQUEST(TypeChecker, InferredGenericSignatureRequest,
7779
GenericSignature (ModuleDecl *, GenericSignatureImpl *,
7880
GenericParamList *,

include/swift/AST/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
829829
/// check access control.
830830
bool isCallableNominalType(DeclContext *dc);
831831

832+
/// Return true if the specified type or a super-class/super-protocol has the
833+
/// @dynamicMemberLookup attribute on it.
834+
bool hasDynamicMemberLookupAttribute();
835+
832836
/// Retrieve the superclass of this type.
833837
///
834838
/// \param useArchetypes Whether to use context archetypes for outer generic

include/swift/Basic/Statistics.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ FRONTEND_STATISTIC(AST, NumPrefixOperators)
138138
/// Number of precedence groups in the AST context.
139139
FRONTEND_STATISTIC(AST, NumPrecedenceGroups)
140140

141-
/// Number of qualified lookups into a nominal type.
142-
FRONTEND_STATISTIC(AST, NumLookupQualifiedInNominal)
143-
144-
/// Number of qualified lookups into a module.
145-
FRONTEND_STATISTIC(AST, NumLookupQualifiedInModule)
146-
147141
/// Number of local lookups into a module.
148142
FRONTEND_STATISTIC(AST, NumModuleLookupValue)
149143

include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ class ClangImporterOptions {
9999
/// When set, don't enforce warnings with -Werror.
100100
bool DebuggerSupport = false;
101101

102+
/// When set, ClangImporter is disabled, and all requests go to the
103+
/// DWARFImporter delegate.
104+
bool DisableSourceImport = false;
105+
102106
/// Return a hash code of any components from these options that should
103107
/// contribute to a Swift Bridging PCH hash.
104108
llvm::hash_code getPCHHashComponents() const {

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ def debug_crash_after_parse : Flag<["-"], "debug-crash-after-parse">,
268268
def debugger_support : Flag<["-"], "debugger-support">,
269269
HelpText<"Process swift code as if running in the debugger">;
270270

271+
def disable_clangimporter_source_import : Flag<["-"],
272+
"disable-clangimporter-source-import">,
273+
HelpText<"Disable ClangImporter and forward all requests straight the DWARF importer.">;
274+
271275
def disable_arc_opts : Flag<["-"], "disable-arc-opts">,
272276
HelpText<"Don't run SIL ARC optimization passes.">;
273277
def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">,

0 commit comments

Comments
 (0)