Skip to content

Commit 28df967

Browse files
authored
---
yaml --- r: 319423 b: refs/heads/master-rebranch c: cdfd836 h: refs/heads/master i: 319421: 6c5c818 319419: 36eefed 319415: 52fb7ef 319407: 55d5171 319391: be1ea5e 319359: f217dc4
1 parent dc04ef0 commit 28df967

File tree

139 files changed

+3275
-954
lines changed

Some content is hidden

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

139 files changed

+3275
-954
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 67cfef2d60e489e9d9eb03ce1396e78af0fc59b5
1460+
refs/heads/master-rebranch: cdfd83628c02840c9c20e0a822f4d71d7b3df10a

branches/master-rebranch/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SR-8974][]:
30+
31+
Duplicate tuple element labels are no longer allowed, because it leads
32+
to incorrect behavior. For example:
33+
34+
```
35+
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
36+
37+
enum Foo { case bar(x: Int, x: Int) }
38+
let f: Foo = .bar(x: 0, x: 1)
39+
```
40+
41+
will now be diagnosed as an error.
42+
43+
Note: You can still use duplicate labels when declaring functions and
44+
subscripts, as long as the internal labels are different. For example:
45+
46+
```
47+
func foo(bar x: Int, bar y: Int) {}
48+
subscript(a x: Int, a y: Int) -> Int {}
49+
```
50+
2951
* [SR-6118][]:
3052

3153
Subscripts can now declare default arguments:
@@ -7696,5 +7718,6 @@ Swift 1.0
76967718
[SR-7799]: <https://bugs.swift.org/browse/SR-7799>
76977719
[SR-8109]: <https://bugs.swift.org/browse/SR-8109>
76987720
[SR-8546]: <https://bugs.swift.org/browse/SR-8546>
7721+
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
76997722
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
77007723
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>

branches/master-rebranch/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ endif()
117117

118118
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
119119
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
120-
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
121-
STRINGS FALSE "NOT-MERGED" "MERGED")
122120

123121
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
124122
# can be reused when a new version of Swift comes out (assuming the user hasn't
@@ -171,8 +169,20 @@ endif()
171169

172170
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
173171
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
174-
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
175-
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")
172+
# Allow the user to specify the standard library CMAKE_MSVC_RUNTIME_LIBRARY
173+
# value. The following values are valid:
174+
# - MultiThreaded (/MT)
175+
# - MultiThreadedDebug (/MTd)
176+
# - MultiThreadedDLL (/MD)
177+
# - MultiThreadedDebugDLL (/MDd)
178+
if(CMAKE_BUILD_TYPE STREQUAL Debug)
179+
set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default MultiThreadedDebugDLL)
180+
else()
181+
set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default MultiThreadedDLL)
182+
endif()
183+
set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY
184+
${SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default}
185+
CACHE STRING "MSVC Runtime Library for the standard library")
176186

177187
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
178188
if(swift_optimized)

branches/master-rebranch/cmake/modules/AddSwift.cmake

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,6 @@ function(_add_variant_swift_compile_flags
400400
list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS")
401401
endif()
402402

403-
if(sdk STREQUAL WINDOWS)
404-
list(APPEND result "-Xcc" "-D_MT")
405-
# TODO(compnerd) handle /MT /MTd
406-
list(APPEND result "-Xcc" "-D_DLL")
407-
endif()
408-
409403
set("${result_var_name}" "${result}" PARENT_SCOPE)
410404
endfunction()
411405

@@ -873,13 +867,8 @@ function(_add_swift_library_single target name)
873867
if("${SWIFTLIB_SINGLE_ARCHITECTURE}" MATCHES arm)
874868
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xcc;-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
875869
endif()
876-
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xfrontend;-autolink-library;-Xfrontend;oldnames)
877-
# TODO(compnerd) handle /MT and /MTd
878-
if(CMAKE_BUILD_TYPE MATCHES Debug)
879-
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xfrontend;-autolink-library;-Xfrontend;msvcrtd)
880-
else()
881-
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xfrontend;-autolink-library;-Xfrontend;msvcrt)
882-
endif()
870+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS
871+
-libc;${SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY})
883872
endif()
884873

885874
# FIXME: don't actually depend on the libraries in SWIFTLIB_SINGLE_LINK_LIBRARIES,
@@ -1925,6 +1914,20 @@ function(add_swift_target_library name)
19251914
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19261915
)
19271916

1917+
if(sdk STREQUAL WINDOWS)
1918+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
1919+
if (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebugDLL)
1920+
target_compile_options(${VARIANT_NAME} PRIVATE /MDd /D_DLL /D_DEBUG)
1921+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
1922+
target_compile_options(${VARIANT_NAME} PRIVATE /MTd /U_DLL /D_DEBUG)
1923+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDLL)
1924+
target_compile_options(${VARIANT_NAME} PRIVATE /MD /D_DLL /U_DEBUG)
1925+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreaded)
1926+
target_compile_options(${VARIANT_NAME} PRIVATE /MT /U_DLL /U_DEBUG)
1927+
endif()
1928+
endif()
1929+
endif()
1930+
19281931
if(NOT SWIFTLIB_OBJECT_LIBRARY)
19291932
# Add dependencies on the (not-yet-created) custom lipo target.
19301933
foreach(DEP ${SWIFTLIB_LINK_LIBRARIES})

branches/master-rebranch/cmake/modules/StandaloneOverlay.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
6565
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
6666
"Build type for the Swift standard library and SDK overlays.")
6767

68-
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
69-
STRINGS
70-
"Debug" "RelWithDebInfo" "Release" "MinSizeRel")
71-
7268
# -----------------------------------------------------------------------------
7369
# Constants
7470

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ ERROR(cannot_convert_sequence_element_value,none,
452452
"cannot convert sequence element type %0 to expected type %1",
453453
(Type, Type))
454454
ERROR(cannot_convert_sequence_element_protocol,none,
455-
"sequence element type %0 does not conform to expected type %1",
455+
"sequence element type %0 does not conform to expected protocol %1",
456456
(Type, Type))
457457

458458
ERROR(throws_functiontype_mismatch,none,
@@ -3523,6 +3523,8 @@ ERROR(tuple_single_element,none,
35233523
"cannot create a single-element tuple with an element label", ())
35243524
ERROR(tuple_ellipsis,none,
35253525
"cannot create a variadic tuple", ())
3526+
ERROR(tuple_duplicate_label,none,
3527+
"cannot create a tuple with a duplicate element label", ())
35263528
ERROR(enum_element_ellipsis,none,
35273529
"variadic enum cases are not supported", ())
35283530

branches/master-rebranch/include/swift/AST/Expr.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,15 +953,25 @@ class TapExpr : public Expr {
953953
class InterpolatedStringLiteralExpr : public LiteralExpr {
954954
/// Points at the beginning quote.
955955
SourceLoc Loc;
956+
/// Points at the ending quote.
957+
/// Needed for the upcoming \c ASTScope subsystem because lookups can be
958+
/// targeted to inside an \c InterpolatedStringLiteralExpr. It would be nicer
959+
/// to use \c EndLoc for this value, but then \c Lexer::getLocForEndOfToken()
960+
/// would not work for \c stringLiteral->getEndLoc().
961+
SourceLoc TrailingQuoteLoc;
956962
TapExpr *AppendingExpr;
957963
Expr *SemanticExpr;
958964

959965
public:
960-
InterpolatedStringLiteralExpr(SourceLoc Loc, unsigned LiteralCapacity,
966+
InterpolatedStringLiteralExpr(SourceLoc Loc,
967+
SourceLoc TrailingQuoteLoc,
968+
unsigned LiteralCapacity,
961969
unsigned InterpolationCount,
962970
TapExpr *AppendingExpr)
963971
: LiteralExpr(ExprKind::InterpolatedStringLiteral, /*Implicit=*/false),
964-
Loc(Loc), AppendingExpr(AppendingExpr), SemanticExpr() {
972+
Loc(Loc),
973+
TrailingQuoteLoc(TrailingQuoteLoc),
974+
AppendingExpr(AppendingExpr), SemanticExpr() {
965975
Bits.InterpolatedStringLiteralExpr.InterpolationCount = InterpolationCount;
966976
Bits.InterpolatedStringLiteralExpr.LiteralCapacity = LiteralCapacity;
967977
}
@@ -998,6 +1008,11 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
9981008
// token, so the range should be (Start == End).
9991009
return Loc;
10001010
}
1011+
SourceLoc getTrailingQuoteLoc() const {
1012+
// Except when computing a SourceRange for an ASTScope. Then the range
1013+
// must be (Start - TrainingQuoteLoc).
1014+
return TrailingQuoteLoc;
1015+
}
10011016

10021017
/// Call the \c callback with information about each segment in turn.
10031018
void forEachSegment(ASTContext &Ctx,

branches/master-rebranch/include/swift/Driver/Driver.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ class OutputInfo {
8787
Immediate,
8888
};
8989

90+
enum class MSVCRuntime {
91+
MultiThreaded,
92+
MultiThreadedDebug,
93+
MultiThreadedDLL,
94+
MultiThreadedDebugDLL,
95+
};
96+
9097
/// The mode in which the driver should invoke the frontend.
9198
Mode CompilerMode = Mode::StandardCompile;
9299

100+
Optional<MSVCRuntime> RuntimeVariant = llvm::None;
101+
93102
/// The output type which should be used for compile actions.
94103
file_types::ID CompilerOutputType = file_types::ID::TY_INVALID;
95104

branches/master-rebranch/include/swift/FrontendTool/FrontendTool.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ class FrontendObserver {
4242

4343
/// The frontend has configured the compiler instance.
4444
virtual void configuredCompiler(CompilerInstance &instance);
45+
46+
/// The frontend has performed semantic analysis.
47+
virtual void performedSemanticAnalysis(CompilerInstance &instance);
48+
49+
/// The frontend has performed basic SIL generation.
50+
/// SIL diagnostic passes have not yet been applied.
51+
virtual void performedSILGeneration(SILModule &module);
52+
53+
/// The frontend has executed the SIL optimization and diagnostics pipelines.
54+
virtual void performedSILProcessing(SILModule &module);
55+
56+
// TODO: maybe enhance this interface to hear about IRGen and LLVM
57+
// progress.
4558
};
4659

4760
namespace frontend {

branches/master-rebranch/include/swift/Option/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ def enable_app_extension : Flag<["-"], "application-extension">,
455455
Flags<[FrontendOption, NoInteractiveOption]>,
456456
HelpText<"Restrict code to those available for App Extensions">;
457457

458+
def libc : Separate<["-"], "libc">, HelpText<"libc runtime library to use">;
459+
458460
// Linker options
459461

460462
def linker_option_Group : OptionGroup<"<linker-specific options>">;

branches/master-rebranch/include/swift/SIL/SILBasicBlock.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,20 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
232232
const ValueDecl *D = nullptr);
233233

234234
/// Replace the \p{i}th BB arg with a new BBArg with SILType \p Ty and
235-
/// ValueDecl
236-
/// \p D.
237-
SILPhiArgument *replacePhiArgument(unsigned i, SILType Ty,
238-
ValueOwnershipKind Kind,
239-
const ValueDecl *D = nullptr);
235+
/// ValueDecl \p D.
236+
///
237+
/// NOTE: This assumes that the current argument in position \p i has had its
238+
/// uses eliminated. To replace/replace all uses with, use
239+
/// replacePhiArgumentAndRAUW.
240+
SILPhiArgument *replacePhiArgument(unsigned i, SILType type,
241+
ValueOwnershipKind kind,
242+
const ValueDecl *decl = nullptr);
243+
244+
/// Replace phi argument \p i and RAUW all uses.
245+
SILPhiArgument *
246+
replacePhiArgumentAndReplaceAllUses(unsigned i, SILType type,
247+
ValueOwnershipKind kind,
248+
const ValueDecl *decl = nullptr);
240249

241250
/// Allocate a new argument of type \p Ty and append it to the argument
242251
/// list. Optionally you can pass in a value decl parameter.

branches/master-rebranch/include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,11 +1938,7 @@ class SILBuilder {
19381938
SILType destTy, SILBasicBlock *successBB,
19391939
SILBasicBlock *failureBB,
19401940
ProfileCounter Target1Count = ProfileCounter(),
1941-
ProfileCounter Target2Count = ProfileCounter()) {
1942-
return insertTerminator(CheckedCastBranchInst::create(
1943-
getSILDebugLocation(Loc), isExact, op, destTy, successBB, failureBB,
1944-
getFunction(), C.OpenedArchetypes, Target1Count, Target2Count));
1945-
}
1941+
ProfileCounter Target2Count = ProfileCounter());
19461942

19471943
CheckedCastValueBranchInst *
19481944
createCheckedCastValueBranch(SILLocation Loc, SILValue op, SILType destTy,

branches/master-rebranch/include/swift/SIL/SILInstruction.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,8 @@ class ApplyInstBase<Impl, Base, false> : public Base {
18411841
/// issues. It is at the bottom of the file.
18421842
SILFunction *getCalleeFunction() const;
18431843

1844+
bool isCalleeDynamicallyReplaceable() const;
1845+
18441846
/// Gets the referenced function if the callee is a function_ref instruction.
18451847
SILFunction *getReferencedFunction() const {
18461848
if (auto *FRI = dyn_cast<FunctionRefBaseInst>(getCallee()))
@@ -7773,6 +7775,27 @@ SILValue ApplyInstBase<Impl, Base, false>::getCalleeOrigin() const {
77737775
}
77747776
}
77757777

7778+
template <class Impl, class Base>
7779+
bool ApplyInstBase<Impl, Base, false>::isCalleeDynamicallyReplaceable() const {
7780+
SILValue Callee = getCalleeOrigin();
7781+
7782+
while (true) {
7783+
if (auto *FRI = dyn_cast<FunctionRefInst>(Callee))
7784+
return false;
7785+
7786+
if (auto *FRI = dyn_cast<DynamicFunctionRefInst>(Callee))
7787+
return true;
7788+
if (auto *FRI = dyn_cast<PreviousDynamicFunctionRefInst>(Callee))
7789+
return true;
7790+
7791+
if (auto *PAI = dyn_cast<PartialApplyInst>(Callee)) {
7792+
Callee = PAI->getCalleeOrigin();
7793+
continue;
7794+
}
7795+
return false;
7796+
}
7797+
}
7798+
77767799
template <class Impl, class Base>
77777800
SILFunction *ApplyInstBase<Impl, Base, false>::getCalleeFunction() const {
77787801
SILValue Callee = getCalleeOrigin();

branches/master-rebranch/include/swift/Serialization/ModuleFormat.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 491; // mangled class names as vtable keys
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 493; // dependency types for structs
5656

5757
using DeclIDField = BCFixed<31>;
5858

@@ -948,7 +948,8 @@ namespace decls_block {
948948
GenericEnvironmentIDField, // generic environment
949949
AccessLevelField, // access level
950950
BCVBR<4>, // number of conformances
951-
BCArray<TypeIDField> // inherited types
951+
BCVBR<4>, // number of inherited types
952+
BCArray<TypeIDField> // inherited types, followed by dependency types
952953
// Trailed by the generic parameters (if any), the members record, and
953954
// finally conformance info (if any).
954955
>;
@@ -981,7 +982,8 @@ namespace decls_block {
981982
TypeIDField, // superclass
982983
AccessLevelField, // access level
983984
BCVBR<4>, // number of conformances
984-
BCArray<TypeIDField> // inherited types
985+
BCVBR<4>, // number of inherited types
986+
BCArray<TypeIDField> // inherited types, followed by dependency types
985987
// Trailed by the generic parameters (if any), the members record, and
986988
// finally conformance info (if any).
987989
>;

0 commit comments

Comments
 (0)