Skip to content

Commit cf2dce9

Browse files
committed
Merge branch 'master' of https://github.com/apple/swift into swift5-verison
# Conflicts: # test/api-digester/Outputs/stability-stdlib-source.swift.expected
2 parents bd703b7 + 5ea1e12 commit cf2dce9

File tree

206 files changed

+2169
-2383
lines changed

Some content is hidden

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

206 files changed

+2169
-2383
lines changed

benchmark/utils/TestsUtils.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public func Random() -> Int64 {
221221
return lfsrRandomGenerator.randInt()
222222
}
223223

224+
@inlinable // FIXME(inline-always)
224225
@inline(__always)
225226
public func CheckResults(
226227
_ resultsMatch: Bool,

cmake/modules/SwiftComponents.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
# * stdlib -- the Swift standard library.
5757
# * stdlib-experimental -- the Swift standard library module for experimental
5858
# APIs.
59-
# * swift-syntax -- the Swift module for the libSyntax Swift API
6059
# * sdk-overlay -- the Swift SDK overlay.
6160
# * editor-integration -- scripts for Swift integration in IDEs other than
6261
# Xcode;
@@ -66,7 +65,7 @@
6665
# * toolchain-dev-tools -- install development tools useful in a shared toolchain
6766
# * dev -- headers and libraries required to use Swift compiler as a library.
6867
set(_SWIFT_DEFINED_COMPONENTS
69-
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;swift-syntax;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
68+
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
7069

7170
macro(swift_configure_components)
7271
# Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D

cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ function(_compile_swift_files
243243

244244
if(SWIFTFILE_IS_STDLIB)
245245
list(APPEND swift_flags "-Xfrontend" "-enable-sil-ownership")
246+
list(APPEND swift_flags "-Xfrontend" "-enable-mandatory-semantic-arc-opts")
246247
endif()
247248

248249
if(NOT SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING AND SWIFTFILE_IS_STDLIB)

docs/ABI/Mangling.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ types where the metadata itself has unknown layout.)
195195
global ::= protocol 'TL' // protocol requirements base descriptor
196196
global ::= assoc-type-name 'Tl' // associated type descriptor
197197
global ::= assoc-type-name 'TM' // default associated type witness accessor (HISTORICAL)
198-
global ::= type assoc-type-path protocol 'Tn' // associated conformance descriptor
199-
global ::= type assoc-type-path protocol 'TN' // default associated conformance witness accessor
198+
global ::= type assoc-type-list protocol 'Tn' // associated conformance descriptor
199+
global ::= type assoc-type-list protocol 'TN' // default associated conformance witness accessor
200200

201201
REABSTRACT-THUNK-TYPE ::= 'R' // reabstraction thunk helper function
202202
REABSTRACT-THUNK-TYPE ::= 'r' // reabstraction thunk

include/swift/ABI/Enum.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===--- Enum.h - Enum implementation runtime declarations ------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Enum implementation details declarations relevant to the ABI.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_ABI_ENUM_H
18+
#define SWIFT_ABI_ENUM_H
19+
20+
#include <stdlib.h>
21+
22+
namespace swift {
23+
24+
struct EnumTagCounts {
25+
unsigned numTags, numTagBytes;
26+
};
27+
28+
inline EnumTagCounts
29+
getEnumTagCounts(size_t size, unsigned emptyCases, unsigned payloadCases) {
30+
// We can use the payload area with a tag bit set somewhere outside of the
31+
// payload area to represent cases. See how many bytes we need to cover
32+
// all the empty cases.
33+
unsigned numTags = payloadCases;
34+
if (emptyCases > 0) {
35+
if (size >= 4)
36+
// Assume that one tag bit is enough if the precise calculation overflows
37+
// an int32.
38+
numTags += 1;
39+
else {
40+
unsigned bits = size * 8U;
41+
unsigned casesPerTagBitValue = 1U << bits;
42+
numTags += ((emptyCases + (casesPerTagBitValue-1U)) >> bits);
43+
}
44+
}
45+
unsigned numTagBytes = (numTags <= 1 ? 0 :
46+
numTags < 256 ? 1 :
47+
numTags < 65536 ? 2 : 4);
48+
return {numTags, numTagBytes};
49+
}
50+
51+
} // namespace swift
52+
53+
#endif // SWIFT_ABI_ENUM_H

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ SIMPLE_DECL_ATTR(unsafe_no_objc_tagged_pointer, UnsafeNoObjCTaggedPointer,
179179
UserInaccessible,
180180
19)
181181
DECL_ATTR(inline, Inline,
182-
OnFunc | OnAccessor | OnConstructor,
182+
OnVar | OnSubscript | OnAbstractFunction,
183183
20)
184184
DECL_ATTR(_semantics, Semantics,
185185
OnAbstractFunction | OnSubscript |

include/swift/AST/Decl.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ class alignas(1 << DeclAlignInBits) Decl {
570570
HasAnyUnavailableValues : 1
571571
);
572572

573-
SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1,
573+
SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1+1,
574574
/// If the module was or is being compiled with `-enable-testing`.
575575
TestingEnabled : 1,
576576

@@ -586,7 +586,10 @@ class alignas(1 << DeclAlignInBits) Decl {
586586
HasResolvedImports : 1,
587587

588588
// If the module was or is being compiled with `-enable-private-imports`.
589-
PrivateImportsEnabled : 1
589+
PrivateImportsEnabled : 1,
590+
591+
// If the module is compiled with `-enable-implicit-dynamic`.
592+
ImplicitDynamicEnabled : 1
590593
);
591594

592595
SWIFT_INLINE_BITFIELD(PrecedenceGroupDecl, Decl, 1+2,
@@ -2594,6 +2597,10 @@ class ValueDecl : public Decl {
25942597
return isObjC() && isDynamic();
25952598
}
25962599

2600+
bool isNativeDynamic() const {
2601+
return !isObjC() && isDynamic();
2602+
}
2603+
25972604
/// Set whether this type is 'dynamic' or not.
25982605
void setIsDynamic(bool value);
25992606

include/swift/AST/DiagnosticConsumer.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace swift {
2727
class DiagnosticArgument;
28+
class DiagnosticEngine;
2829
class SourceManager;
2930
enum class DiagID : uint32_t;
3031

@@ -122,6 +123,19 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
122123
const DiagnosticInfo &Info) override;
123124
};
124125

126+
/// \brief DiagnosticConsumer that forwards diagnostics to the consumers of
127+
// another DiagnosticEngine.
128+
class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
129+
DiagnosticEngine &TargetEngine;
130+
public:
131+
ForwardingDiagnosticConsumer(DiagnosticEngine &Target);
132+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
133+
DiagnosticKind Kind,
134+
StringRef FormatString,
135+
ArrayRef<DiagnosticArgument> FormatArgs,
136+
const DiagnosticInfo &Info) override;
137+
};
138+
125139
/// \brief DiagnosticConsumer that funnels diagnostics in certain files to
126140
/// particular sub-consumers.
127141
///

include/swift/AST/DiagnosticEngine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ namespace swift {
604604
return Result;
605605
}
606606

607+
/// \brief Return all \c DiagnosticConsumers.
608+
ArrayRef<DiagnosticConsumer *> getConsumers() {
609+
return Consumers;
610+
}
611+
607612
/// \brief Emit a diagnostic using a preformatted array of diagnostic
608613
/// arguments.
609614
///

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,17 @@ WARNING(parseable_interface_scoped_import_unsupported,none,
265265
())
266266
ERROR(error_extracting_version_from_parseable_interface,none,
267267
"error extracting version from parseable module interface", ())
268+
ERROR(unsupported_version_of_parseable_interface,none,
269+
"unsupported version of parseable module interface '%0': '%1'",
270+
(StringRef, llvm::VersionTuple))
268271
ERROR(error_extracting_flags_from_parseable_interface,none,
269272
"error extracting flags from parseable module interface", ())
273+
ERROR(missing_dependency_of_parseable_module_interface,none,
274+
"missing dependency '%0' of parseable module interface '%1': %2",
275+
(StringRef, StringRef, StringRef))
276+
ERROR(error_extracting_dependencies_from_cached_module,none,
277+
"error extracting dependencies from cached module '%0'",
278+
(StringRef))
270279

271280
#ifndef DIAG_NO_UNDEF
272281
# if defined(DIAG)

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4097,7 +4097,6 @@ ERROR(usable_from_inline_attr_in_protocol,none,
40974097

40984098
#define FRAGILE_FUNC_KIND \
40994099
"%select{a '@_transparent' function|" \
4100-
"an '@inline(__always)' function|" \
41014100
"an '@inlinable' function|" \
41024101
"a default argument value|" \
41034102
"a property initializer in a '@_fixed_layout' type}"
@@ -4126,7 +4125,7 @@ NOTE(resilience_decl_declared_here,
41264125

41274126
ERROR(class_designated_init_inlinable_resilient,none,
41284127
"initializer for class %0 is "
4129-
"'%select{@_transparent|@inline(__always)|@inlinable|%error}1' and must "
4128+
"'%select{@_transparent|@inlinable|%error}1' and must "
41304129
"delegate to another initializer", (Type, unsigned))
41314130

41324131
ERROR(attribute_invalid_on_stored_property,

include/swift/AST/Module.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ class ModuleDecl : public DeclContext, public TypeDecl {
283283
Bits.ModuleDecl.TestingEnabled = enabled;
284284
}
285285

286+
// Returns true if this module is compiled with implicit dynamic.
287+
bool isImplicitDynamicEnabled() const {
288+
return Bits.ModuleDecl.ImplicitDynamicEnabled;
289+
}
290+
void setImplicitDynamicEnabled(bool enabled = true) {
291+
Bits.ModuleDecl.ImplicitDynamicEnabled = enabled;
292+
}
293+
286294
/// Returns true if this module was or is begin compile with
287295
/// `-enable-private-imports`.
288296
bool arePrivateImportsEnabled() const {
@@ -990,7 +998,18 @@ class SourceFile final : public FileUnit {
990998

991999
void addImports(ArrayRef<ImportedModuleDesc> IM);
9921000

993-
bool hasTestableOrPrivateImport(AccessLevel accessLevel, const ValueDecl *ofDecl) const;
1001+
enum ImportQueryKind {
1002+
/// Return the results for testable or private imports.
1003+
TestableAndPrivate,
1004+
/// Return the results only for testable imports.
1005+
TestableOnly,
1006+
/// Return the results only for private imports.
1007+
PrivateOnly
1008+
};
1009+
1010+
bool
1011+
hasTestableOrPrivateImport(AccessLevel accessLevel, const ValueDecl *ofDecl,
1012+
ImportQueryKind kind = TestableAndPrivate) const;
9941013

9951014
void clearLookupCache();
9961015

include/swift/AST/ModuleLoader.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,12 @@ class DependencyTracker {
6363

6464
/// \brief Abstract interface that loads named modules into the AST.
6565
class ModuleLoader {
66-
DependencyTracker * const dependencyTracker;
6766
virtual void anchor();
6867

6968
protected:
69+
DependencyTracker * const dependencyTracker;
7070
ModuleLoader(DependencyTracker *tracker) : dependencyTracker(tracker) {}
7171

72-
void addDependency(StringRef file, bool IsSystem=false) {
73-
if (dependencyTracker)
74-
dependencyTracker->addDependency(file, IsSystem);
75-
}
76-
7772
public:
7873
virtual ~ModuleLoader() = default;
7974

include/swift/Basic/FileTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ TYPE("sil", SIL, "sil", "")
4141
TYPE("sib", SIB, "sib", "")
4242

4343
// Output types
44+
TYPE("ast-dump", ASTDump, "ast", "")
4445
TYPE("image", Image, "out", "")
4546
TYPE("object", Object, "o", "")
4647
TYPE("dSYM", dSYM, "dSYM", "")

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ namespace swift {
144144
/// was not compiled with -enable-testing.
145145
bool EnableTestableAttrRequiresTestableModule = true;
146146

147-
/// If true, the 'dynamic' attribute is added to all applicable
148-
/// declarations.
149-
bool EnableImplicitDynamic = false;
150-
151147
///
152148
/// Flags for developers
153149
///

include/swift/Basic/PrimarySpecificPaths.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ namespace swift {
2727
class PrimarySpecificPaths {
2828
public:
2929
/// The name of the main output file,
30-
/// that is, the .o file for this input. If there is no such file, contains an
31-
/// empty string. If the output is to be written to stdout, contains "-".
30+
/// that is, the .o file for this input (or a file specified by -o).
31+
/// If there is no such file, contains an empty string. If the output
32+
/// is to be written to stdout, contains "-".
3233
std::string OutputFilename;
3334

3435
SupplementaryOutputPaths SupplementaryOutputs;

include/swift/ClangImporter/ClangImporter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ class ClangImporter final : public ClangModuleLoader {
326326
/// Writes the mangled name of \p clangDecl to \p os.
327327
void getMangledName(raw_ostream &os, const clang::NamedDecl *clangDecl) const;
328328

329-
using ClangModuleLoader::addDependency;
330-
331329
// Print statistics from the Clang AST reader.
332330
void printStatistics() const override;
333331

include/swift/Frontend/FrontendOptions.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ class FrontendOptions {
146146
/// Indicates that the input(s) should be parsed as the Swift stdlib.
147147
bool ParseStdlib = false;
148148

149-
/// If set, emitted module files will always contain options for the
150-
/// debugger to use.
151-
bool AlwaysSerializeDebuggingOptions = false;
149+
/// When true, emitted module files will always contain options for the
150+
/// debugger to use. When unset, the options will only be present if the
151+
/// module appears to not be a public module.
152+
Optional<bool> SerializeOptionsForDebugging;
152153

153154
/// If set, inserts instrumentation useful for testing the debugger.
154155
bool DebuggerTestingTransform = false;
@@ -197,6 +198,12 @@ class FrontendOptions {
197198
/// \see ModuleDecl::arePrivateImportsEnabled
198199
bool EnablePrivateImports = false;
199200

201+
202+
/// Indicates whether we add implicit dynamic.
203+
///
204+
/// \see ModuleDecl::isImplicitDynamicEnabled
205+
bool EnableImplicitDynamic = false;
206+
200207
/// Enables the "fully resilient" resilience strategy.
201208
///
202209
/// \see ResilienceStrategy::Resilient

include/swift/Frontend/ParseableInterfaceSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct ParseableInterfaceOptions {
2929
std::string ParseableInterfaceFlags;
3030
};
3131

32-
llvm::Regex getSwiftInterfaceToolsVersionRegex();
32+
llvm::Regex getSwiftInterfaceFormatVersionRegex();
3333
llvm::Regex getSwiftInterfaceModuleFlagsRegex();
3434

3535
/// Emit a stable, parseable interface for \p M, which can be used by a client

include/swift/IDE/CodeCompletionCache.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class CodeCompletionCache {
4141
std::vector<std::string> AccessPath;
4242
bool ResultsHaveLeadingDot;
4343
bool ForTestableLookup;
44+
bool ForPrivateImportLookup;
4445
bool CodeCompleteInitsInPostfixExpr;
4546

4647
friend bool operator==(const Key &LHS, const Key &RHS) {
@@ -49,6 +50,7 @@ class CodeCompletionCache {
4950
LHS.AccessPath == RHS.AccessPath &&
5051
LHS.ResultsHaveLeadingDot == RHS.ResultsHaveLeadingDot &&
5152
LHS.ForTestableLookup == RHS.ForTestableLookup &&
53+
LHS.ForPrivateImportLookup == RHS.ForPrivateImportLookup &&
5254
LHS.CodeCompleteInitsInPostfixExpr == RHS.CodeCompleteInitsInPostfixExpr;
5355
}
5456
};
@@ -106,10 +108,10 @@ template<>
106108
struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
107109
using KeyTy = swift::ide::CodeCompletionCache::Key;
108110
static inline KeyTy getEmptyKey() {
109-
return KeyTy{"", "", {}, false, false, false};
111+
return KeyTy{"", "", {}, false, false, false, false};
110112
}
111113
static inline KeyTy getTombstoneKey() {
112-
return KeyTy{"", "", {}, true, false, false};
114+
return KeyTy{"", "", {}, true, false, false, false};
113115
}
114116
static unsigned getHashValue(const KeyTy &Val) {
115117
size_t H = 0;
@@ -119,6 +121,7 @@ struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
119121
H ^= std::hash<std::string>()(Piece);
120122
H ^= std::hash<bool>()(Val.ResultsHaveLeadingDot);
121123
H ^= std::hash<bool>()(Val.ForTestableLookup);
124+
H ^= std::hash<bool>()(Val.ForPrivateImportLookup);
122125
return static_cast<unsigned>(H);
123126
}
124127
static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {

include/swift/IRGen/Linking.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ struct IRLinkage {
10121012
llvm::GlobalValue::LinkageTypes Linkage;
10131013
llvm::GlobalValue::VisibilityTypes Visibility;
10141014
llvm::GlobalValue::DLLStorageClassTypes DLLStorage;
1015+
1016+
static const IRLinkage InternalLinkOnceODR;
1017+
static const IRLinkage Internal;
10151018
};
10161019

10171020
class ApplyIRLinkage {

0 commit comments

Comments
 (0)