Skip to content

Commit be2e93a

Browse files
committed
Merge branch 'master' into dev/DataProtocol-inputs
2 parents b1d4d40 + 9fb7fc0 commit be2e93a

File tree

148 files changed

+5281
-1483
lines changed

Some content is hidden

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

148 files changed

+5281
-1483
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
3+
from __future__ import print_function
4+
5+
import argparse
6+
import os
7+
import subprocess
8+
9+
10+
def main():
11+
parser = argparse.ArgumentParser()
12+
parser.add_argument('--verbose', '-v', action='store_true')
13+
parser.add_argument('--package-path', type=str, required=True)
14+
parser.add_argument('--build-path', type=str, required=True)
15+
parser.add_argument('--toolchain', type=str, required=True)
16+
17+
# Build the debug/release versions.
18+
args = parser.parse_args()
19+
swiftbuild_path = os.path.join(args.toolchain, 'usr', 'bin', 'swift-build')
20+
swiftbuild_args = [
21+
swiftbuild_path,
22+
'--package-path', args.package_path,
23+
'--build-path', args.build_path,
24+
'--configuration', 'debug',
25+
]
26+
if args.verbose:
27+
swiftbuild_args.append('--verbose')
28+
subprocess.call(swiftbuild_args)
29+
30+
swiftbuild_args = [
31+
swiftbuild_path,
32+
'--package-path', args.package_path,
33+
'--build-path', args.build_path,
34+
'--configuration', 'release',
35+
'-Xswiftc', '-Xllvm',
36+
'-Xswiftc', '-align-module-to-page-size',
37+
]
38+
if args.verbose:
39+
swiftbuild_args.append('--verbose')
40+
subprocess.call(swiftbuild_args)
41+
42+
43+
if __name__ == "__main__":
44+
main()

cmake/modules/AddSwift.cmake

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,30 @@ function(_add_variant_c_compile_flags)
318318
endforeach()
319319
endif()
320320

321+
set(ICU_UC_INCLUDE_DIR ${SWIFT_${CFLAGS_SDK}_${CFLAGS_ARCH}_ICU_UC_INCLUDE})
322+
if(NOT "${ICU_UC_INCLUDE_DIR}" STREQUAL "" AND
323+
NOT "${ICU_UC_INCLUDE_DIR}" STREQUAL "/usr/include" AND
324+
NOT "${ICU_UC_INCLUDE_DIR}" STREQUAL "/usr/${SWIFT_SDK_${CFLAGS_SDK}_ARCH_${CFLAGS_ARCH}_TRIPLE}/include" AND
325+
NOT "${ICU_UC_INCLUDE_DIR}" STREQUAL "/usr/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_TRIPLE}/include")
326+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
327+
list(APPEND result -I;${ICU_UC_INCLUDE_DIR})
328+
else()
329+
list(APPEND result -isystem;${ICU_UC_INCLUDE_DIR})
330+
endif()
331+
endif()
332+
333+
set(ICU_I18N_INCLUDE_DIR ${SWIFT_${CFLAGS_SDK}_${CFLAGS_ARCH}_ICU_I18N_INCLUDE})
334+
if(NOT "${ICU_I18N_INCLUDE_DIR}" STREQUAL "" AND
335+
NOT "${ICU_I18N_INCLUDE_DIR}" STREQUAL "/usr/include" AND
336+
NOT "${ICU_I18N_INCLUDE_DIR}" STREQUAL "/usr/${SWIFT_SDK_${CFLAGS_SDK}_ARCH_${CFLAGS_ARCH}_TRIPLE}/include" AND
337+
NOT "${ICU_I18N_INCLUDE_DIR}" STREQUAL "/usr/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_TRIPLE}/include")
338+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
339+
list(APPEND result -I;${ICU_I18N_INCLUDE_DIR})
340+
else()
341+
list(APPEND result -isystem;${ICU_I18N_INCLUDE_DIR})
342+
endif()
343+
endif()
344+
321345
set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
322346
endfunction()
323347

@@ -960,21 +984,6 @@ function(_add_swift_library_single target name)
960984
endif()
961985
_set_target_prefix_and_suffix("${target}" "${libkind}" "${SWIFTLIB_SINGLE_SDK}")
962986

963-
if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
964-
if(NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_UC_INCLUDE}" STREQUAL "" AND
965-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_UC_INCLUDE}" STREQUAL "/usr/include" AND
966-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_UC_INCLUDE}" STREQUAL "/usr/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_ARCH_${SWIFTLIB_SINGLE_ARCHITECTURE}_TRIPLE}/include" AND
967-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_UC_INCLUDE}" STREQUAL "/usr/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_TRIPLE}/include")
968-
target_include_directories("${target}" SYSTEM PRIVATE "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_UC_INCLUDE}")
969-
endif()
970-
if(NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_I18N_INCLUDE}" STREQUAL "" AND
971-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_I18N_INCLUDE}" STREQUAL "/usr/include" AND
972-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_I18N_INCLUDE}" STREQUAL "/usr/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_ARCH_${SWIFTLIB_SINGLE_ARCHITECTURE}_TRIPLE}/include" AND
973-
NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_I18N_INCLUDE}" STREQUAL "/usr/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_TRIPLE}/include")
974-
target_include_directories("${target}" SYSTEM PRIVATE "${SWIFT_${SWIFTLIB_SINGLE_SDK}_${SWIFTLIB_SINGLE_ARCHITECTURE}_ICU_I18N_INCLUDE}")
975-
endif()
976-
endif()
977-
978987
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS")
979988
swift_windows_include_for_arch(${SWIFTLIB_SINGLE_ARCHITECTURE} SWIFTLIB_INCLUDE)
980989
target_include_directories("${target}" SYSTEM PRIVATE ${SWIFTLIB_INCLUDE})
@@ -1018,6 +1027,11 @@ function(_add_swift_library_single target name)
10181027
set_target_properties("${target}" PROPERTIES
10191028
LIBRARY_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}
10201029
ARCHIVE_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
1030+
if(SWIFTLIB_SINGLE_SDK STREQUAL WINDOWS AND SWIFTLIB_SINGLE_IS_STDLIB_CORE
1031+
AND libkind STREQUAL SHARED)
1032+
add_custom_command(TARGET ${target} POST_BUILD
1033+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${target}> ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
1034+
endif()
10211035

10221036
foreach(config ${CMAKE_CONFIGURATION_TYPES})
10231037
string(TOUPPER ${config} config_upper)

docs/WindowsBuild.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Visual Studio 2017 or newer is needed to build swift on Windows.
44

55
## 1. Install dependencies
6-
1. Latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
6+
- Install the latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
77
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web
88
Development|Universal Windows App Development|Windows SDK" in your
99
installation.
@@ -205,15 +205,10 @@ cmake --build S:\b\lldb
205205

206206
## 10. Running tests on Windows
207207

208-
Running the testsuite on Windows has additional external dependencies. You must have a subset of the GNUWin32 programs installed and available in your path. The following packages are currently required:
209-
210-
1. coreutils
211-
2. diffutils
212-
3. grep
213-
4. sed
208+
Running the testsuite on Windows has additional external dependencies.
214209

215210
```cmd
216-
path S:\thirdparty\icu4c-63_1-Win64-MSVC2017\bin64;S:\b\swift\bin;S:\b\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles(x86)%\GnuWin32\bin
211+
path S:\thirdparty\icu4c-63_1-Win64-MSVC2017\bin64;S:\b\swift\bin;S:\b\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
217212
ninja -C S:\b\swift check-swift
218213
```
219214

include/swift/AST/Decl.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "swift/Basic/ArrayRefView.h"
3737
#include "swift/Basic/Compiler.h"
3838
#include "swift/Basic/InlineBitfield.h"
39+
#include "swift/Basic/NullablePtr.h"
3940
#include "swift/Basic/OptionalEnum.h"
4041
#include "swift/Basic/Range.h"
4142
#include "llvm/ADT/DenseMap.h"
@@ -4747,8 +4748,32 @@ class VarDecl : public AbstractStorageDecl {
47474748
/// return this. Otherwise, this VarDecl must belong to a CaseStmt's
47484749
/// CaseLabelItem. In that case, return the first case label item of the first
47494750
/// case stmt in a sequence of case stmts that fallthrough into each other.
4751+
///
4752+
/// NOTE: During type checking, we emit an error if we have a single case
4753+
/// label item with a pattern that has multiple var decls of the same
4754+
/// name. This means that during type checking and before type checking, we
4755+
/// may have a _malformed_ switch stmt var decl linked list since var decls in
4756+
/// the same case label item that have the same name will point at the same
4757+
/// canonical var decl, namely the first var decl with the name in the
4758+
/// canonical case label item's var decl list. This is ok, since we are going
4759+
/// to emit the error, but it requires us to be more careful/cautious before
4760+
/// type checking has been complete when relying on canonical var decls
4761+
/// matching up.
47504762
VarDecl *getCanonicalVarDecl() const;
47514763

4764+
/// If this is a case stmt var decl, return the var decl that corresponds to
4765+
/// this var decl in the first case label item of the case stmt. Returns
4766+
/// nullptr if this isn't a VarDecl that is part of a case stmt.
4767+
NullablePtr<VarDecl> getCorrespondingFirstCaseLabelItemVarDecl() const;
4768+
4769+
/// If this is a case stmt var decl, return the case body var decl that this
4770+
/// var decl maps to.
4771+
NullablePtr<VarDecl> getCorrespondingCaseBodyVariable() const;
4772+
4773+
/// Return true if this var decl is an implicit var decl belonging to a case
4774+
/// stmt's body.
4775+
bool isCaseBodyVariable() const;
4776+
47524777
/// True if the global stored property requires lazy initialization.
47534778
bool isLazilyInitializedGlobal() const;
47544779

include/swift/AST/DiagnosticConsumer.h

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class DiagnosticConsumer {
7979

8080
public:
8181
virtual ~DiagnosticConsumer();
82-
82+
8383
/// Invoked whenever the frontend emits a diagnostic.
8484
///
8585
/// \param SM The source manager associated with the source locations in
@@ -94,11 +94,20 @@ class DiagnosticConsumer {
9494
/// \param FormatArgs The diagnostic format string arguments.
9595
///
9696
/// \param Info Extra information associated with the diagnostic.
97-
virtual void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
98-
DiagnosticKind Kind,
99-
StringRef FormatString,
100-
ArrayRef<DiagnosticArgument> FormatArgs,
101-
const DiagnosticInfo &Info) = 0;
97+
///
98+
/// \param bufferIndirectlyCausingDiagnostic Only used when directing
99+
/// diagnostics to different outputs.
100+
/// In batch mode a diagnostic may be
101+
/// located in a non-primary file, but there will be no .dia file for a
102+
/// non-primary. If valid, this argument contains a location within a buffer
103+
/// that corresponds to a primary input. The .dia file for that primary can be
104+
/// used for the diagnostic, as if it had occurred at this location.
105+
virtual void
106+
handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
107+
StringRef FormatString,
108+
ArrayRef<DiagnosticArgument> FormatArgs,
109+
const DiagnosticInfo &Info,
110+
SourceLoc bufferIndirectlyCausingDiagnostic) = 0;
102111

103112
/// \returns true if an error occurred while finishing-up.
104113
virtual bool finishProcessing() { return false; }
@@ -116,11 +125,11 @@ class DiagnosticConsumer {
116125
/// DiagnosticConsumer that discards all diagnostics.
117126
class NullDiagnosticConsumer : public DiagnosticConsumer {
118127
public:
119-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
120-
DiagnosticKind Kind,
128+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
121129
StringRef FormatString,
122130
ArrayRef<DiagnosticArgument> FormatArgs,
123-
const DiagnosticInfo &Info) override;
131+
const DiagnosticInfo &Info,
132+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
124133
};
125134

126135
/// DiagnosticConsumer that forwards diagnostics to the consumers of
@@ -129,11 +138,11 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
129138
DiagnosticEngine &TargetEngine;
130139
public:
131140
ForwardingDiagnosticConsumer(DiagnosticEngine &Target);
132-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
133-
DiagnosticKind Kind,
141+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
134142
StringRef FormatString,
135143
ArrayRef<DiagnosticArgument> FormatArgs,
136-
const DiagnosticInfo &Info) override;
144+
const DiagnosticInfo &Info,
145+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
137146
};
138147

139148
/// DiagnosticConsumer that funnels diagnostics in certain files to
@@ -175,8 +184,12 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
175184
std::string inputFileName;
176185

177186
/// The consumer (if any) for diagnostics associated with the inputFileName.
178-
/// A null pointer for the DiagnosticConsumer means that diagnostics for
179-
/// this file should not be emitted.
187+
/// A null pointer for the DiagnosticConsumer means that this file is a
188+
/// non-primary one in batch mode and we have no .dia file for it.
189+
/// If there is a responsible primary when the diagnostic is handled
190+
/// it will be shunted to that primary's .dia file.
191+
/// Otherwise it will be suppressed, assuming that the diagnostic will
192+
/// surface in another frontend job that compiles that file as a primary.
180193
std::unique_ptr<DiagnosticConsumer> consumer;
181194

182195
// Has this subconsumer ever handled a diagnostic that is an error?
@@ -191,16 +204,16 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
191204
std::unique_ptr<DiagnosticConsumer> consumer)
192205
: inputFileName(inputFileName), consumer(std::move(consumer)) {}
193206

194-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
195-
DiagnosticKind Kind,
207+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
196208
StringRef FormatString,
197209
ArrayRef<DiagnosticArgument> FormatArgs,
198-
const DiagnosticInfo &Info) {
210+
const DiagnosticInfo &Info,
211+
const SourceLoc bufferIndirectlyCausingDiagnostic) {
199212
if (!getConsumer())
200213
return;
201214
hasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
202215
getConsumer()->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs,
203-
Info);
216+
Info, bufferIndirectlyCausingDiagnostic);
204217
}
205218

206219
void informDriverOfIncompleteBatchModeCompilation() {
@@ -287,11 +300,11 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
287300
SmallVectorImpl<Subconsumer> &consumers);
288301

289302
public:
290-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
291-
DiagnosticKind Kind,
303+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
292304
StringRef FormatString,
293305
ArrayRef<DiagnosticArgument> FormatArgs,
294-
const DiagnosticInfo &Info) override;
306+
const DiagnosticInfo &Info,
307+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
295308

296309
bool finishProcessing() override;
297310

@@ -309,6 +322,14 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
309322
/// a particular consumer if diagnostic goes there.
310323
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
311324
subconsumerForLocation(SourceManager &SM, SourceLoc loc);
325+
326+
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
327+
findSubconsumer(SourceManager &SM, SourceLoc loc, DiagnosticKind Kind,
328+
SourceLoc bufferIndirectlyCausingDiagnostic);
329+
330+
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
331+
findSubconsumerForNonNote(SourceManager &SM, SourceLoc loc,
332+
SourceLoc bufferIndirectlyCausingDiagnostic);
312333
};
313334

314335
} // end namespace swift

include/swift/AST/DiagnosticEngine.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace swift {
2828
class DiagnosticEngine;
2929
class SourceManager;
3030
class ValueDecl;
31-
31+
class SourceFile;
32+
3233
enum class PatternKind : uint8_t;
3334
enum class SelfAccessKind : uint8_t;
3435
enum class ReferenceOwnership : uint8_t;
@@ -561,6 +562,12 @@ namespace swift {
561562
/// emitted once all transactions have closed.
562563
unsigned TransactionCount = 0;
563564

565+
/// For batch mode, use this to know where to output a diagnostic from a
566+
/// non-primary file. It's any location in the buffer of the current primary
567+
/// input being compiled.
568+
/// May be invalid.
569+
SourceLoc bufferIndirectlyCausingDiagnostic;
570+
564571
friend class InFlightDiagnostic;
565572
friend class DiagnosticTransaction;
566573

@@ -799,6 +806,27 @@ namespace swift {
799806

800807
public:
801808
static const char *diagnosticStringFor(const DiagID id);
809+
810+
/// If there is no clear .dia file for a diagnostic, put it in the one
811+
/// corresponding to the SourceLoc given here.
812+
/// In particular, in batch mode when a diagnostic is located in
813+
/// a non-primary file, use this affordance to place it in the .dia
814+
/// file for the primary that is currently being worked on.
815+
void setBufferIndirectlyCausingDiagnosticToInput(SourceLoc);
816+
void resetBufferIndirectlyCausingDiagnostic();
817+
SourceLoc getDefaultDiagnosticLoc() const {
818+
return bufferIndirectlyCausingDiagnostic;
819+
}
820+
};
821+
822+
class BufferIndirectlyCausingDiagnosticRAII {
823+
private:
824+
DiagnosticEngine &Diags;
825+
public:
826+
BufferIndirectlyCausingDiagnosticRAII(const SourceFile &SF);
827+
~BufferIndirectlyCausingDiagnosticRAII() {
828+
Diags.resetBufferIndirectlyCausingDiagnostic();
829+
}
802830
};
803831

804832
/// Represents a diagnostic transaction. While a transaction is

include/swift/AST/DiagnosticsSema.def

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,8 @@ ERROR(missing_dynamic_callable_kwargs_method,none,
10531053

10541054
ERROR(invalid_dynamic_member_lookup_type,none,
10551055
"@dynamicMemberLookup attribute requires %0 to have a "
1056-
"'subscript(dynamicMember:)' method with an "
1057-
"'ExpressibleByStringLiteral' parameter", (Type))
1056+
"'subscript(dynamicMember:)' method that accepts either "
1057+
"'ExpressibleByStringLiteral' or a keypath", (Type))
10581058

10591059
ERROR(string_index_not_integer,none,
10601060
"String must not be indexed with %0, it has variable size elements",
@@ -3874,9 +3874,6 @@ ERROR(borrowed_on_objc_protocol_requirement,none,
38743874

38753875
ERROR(dynamic_not_in_class,none,
38763876
"only members of classes may be dynamic", ())
3877-
ERROR(dynamic_with_final,none,
3878-
"a declaration cannot be both 'final' and 'dynamic'",
3879-
())
38803877
ERROR(dynamic_with_nonobjc,none,
38813878
"a declaration cannot be both '@nonobjc' and 'dynamic'",
38823879
())
@@ -4102,6 +4099,11 @@ WARNING(resilience_decl_unavailable_warn,
41024099
"should not be referenced from " FRAGILE_FUNC_KIND "3",
41034100
(DescriptiveDeclKind, DeclName, AccessLevel, unsigned, bool))
41044101

4102+
ERROR(inlinable_decl_ref_implementation_only,
4103+
none, "%0 %1 cannot be used in an inlinable "
4104+
"function because its module was imported implementation-only",
4105+
(DescriptiveDeclKind, DeclName))
4106+
41054107
#undef FRAGILE_FUNC_KIND
41064108

41074109
NOTE(resilience_decl_declared_here_public,

0 commit comments

Comments
 (0)