Skip to content

Commit 8ee220a

Browse files
committed
Merge branch 'master' into slazarus/allow-access-through-existential-metatype
2 parents 390c635 + 1e41b13 commit 8ee220a

File tree

125 files changed

+3356
-1926
lines changed

Some content is hidden

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

125 files changed

+3356
-1926
lines changed

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/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,

include/swift/AST/IRGenOptions.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,17 @@ class IRGenOptions {
104104
/// Which sanitizer is turned on.
105105
OptionSet<SanitizerKind> Sanitizers;
106106

107+
/// Path prefixes that should be rewritten in debug info.
108+
PathRemapper DebugPrefixMap;
109+
107110
/// What level of debug info to generate.
108111
IRGenDebugInfoLevel DebugInfoLevel : 2;
109112

110113
/// What type of debug info to generate.
111114
IRGenDebugInfoFormat DebugInfoFormat : 2;
112115

113-
/// Path prefixes that should be rewritten in debug info.
114-
PathRemapper DebugPrefixMap;
116+
/// Whether to leave DWARF breadcrumbs pointing to imported Clang modules.
117+
unsigned DisableClangModuleSkeletonCUs : 1;
115118

116119
/// Whether we're generating IR for the JIT.
117120
unsigned UseJIT : 1;
@@ -227,7 +230,9 @@ class IRGenOptions {
227230
Verify(true), OptMode(OptimizationMode::NotSet),
228231
Sanitizers(OptionSet<SanitizerKind>()),
229232
DebugInfoLevel(IRGenDebugInfoLevel::None),
230-
DebugInfoFormat(IRGenDebugInfoFormat::None), UseJIT(false),
233+
DebugInfoFormat(IRGenDebugInfoFormat::None),
234+
DisableClangModuleSkeletonCUs(false),
235+
UseJIT(false),
231236
IntegratedREPL(false), DisableLLVMOptzns(false),
232237
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
233238
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),

include/swift/AST/Module.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,10 @@ class SourceFile final : public FileUnit {
959959
/// May be -1, to indicate no association with a buffer.
960960
int BufferID;
961961

962+
/// Does this source file have any implementation-only imports?
963+
/// If not, we can fast-path module checks.
964+
bool HasImplementationOnlyImports = false;
965+
962966
/// The list of protocol conformances that were "used" within this
963967
/// source file.
964968
llvm::SetVector<NormalProtocolConformance *> UsedConformances;
@@ -1047,6 +1051,12 @@ class SourceFile final : public FileUnit {
10471051
hasTestableOrPrivateImport(AccessLevel accessLevel, const ValueDecl *ofDecl,
10481052
ImportQueryKind kind = TestableAndPrivate) const;
10491053

1054+
bool hasImplementationOnlyImports() const {
1055+
return HasImplementationOnlyImports;
1056+
}
1057+
1058+
bool isImportedImplementationOnly(const ModuleDecl *module) const;
1059+
10501060
void clearLookupCache();
10511061

10521062
void cacheVisibleDecls(SmallVectorImpl<ValueDecl *> &&globals) const;

include/swift/AST/Stmt.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,15 +1055,26 @@ class CaseStmt final
10551055
return UnknownAttrLoc.isValid();
10561056
}
10571057

1058-
Optional<ArrayRef<VarDecl *>> getCaseBodyVariables() const {
1059-
if (!CaseBodyVariables)
1060-
return None;
1058+
/// Return an ArrayRef containing the case body variables of this CaseStmt.
1059+
///
1060+
/// Asserts if case body variables was not explicitly initialized. In contexts
1061+
/// where one wants a non-asserting version, \see
1062+
/// getCaseBodyVariablesOrEmptyArray.
1063+
ArrayRef<VarDecl *> getCaseBodyVariables() const {
10611064
ArrayRef<VarDecl *> a = *CaseBodyVariables;
10621065
return a;
10631066
}
10641067

1065-
Optional<MutableArrayRef<VarDecl *>> getCaseBodyVariables() {
1066-
return CaseBodyVariables;
1068+
bool hasCaseBodyVariables() const { return CaseBodyVariables.hasValue(); }
1069+
1070+
/// Return an MutableArrayRef containing the case body variables of this
1071+
/// CaseStmt.
1072+
///
1073+
/// Asserts if case body variables was not explicitly initialized. In contexts
1074+
/// where one wants a non-asserting version, \see
1075+
/// getCaseBodyVariablesOrEmptyArray.
1076+
MutableArrayRef<VarDecl *> getCaseBodyVariables() {
1077+
return *CaseBodyVariables;
10671078
}
10681079

10691080
ArrayRef<VarDecl *> getCaseBodyVariablesOrEmptyArray() const {

include/swift/Frontend/PrintingDiagnosticConsumer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
3535
PrintingDiagnosticConsumer(llvm::raw_ostream &stream = llvm::errs()) :
3636
Stream(stream) { }
3737

38-
virtual void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
39-
DiagnosticKind Kind,
40-
StringRef FormatString,
41-
ArrayRef<DiagnosticArgument> FormatArgs,
42-
const DiagnosticInfo &Info) override;
38+
virtual void
39+
handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
40+
StringRef FormatString,
41+
ArrayRef<DiagnosticArgument> FormatArgs,
42+
const DiagnosticInfo &Info,
43+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
4344

4445
void forceColors() {
4546
ForceColors = true;

include/swift/Migrator/FixitApplyDiagnosticConsumer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class FixitApplyDiagnosticConsumer final
6262
/// output stream.
6363
void printResult(llvm::raw_ostream &OS) const;
6464

65-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
66-
DiagnosticKind Kind,
65+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
6766
StringRef FormatString,
6867
ArrayRef<DiagnosticArgument> FormatArgs,
69-
const DiagnosticInfo &Info) override;
68+
const DiagnosticInfo &Info,
69+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
7070

7171
unsigned getNumFixitsApplied() const {
7272
return NumFixitsApplied;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ def disable_playground_transform : Flag<["-"], "disable-playground-transform">,
432432
def pc_macro : Flag<["-"], "pc-macro">,
433433
HelpText<"Apply the 'program counter simulation' macro">;
434434

435+
def no_clang_module_breadcrumbs : Flag<["-"], "no-clang-module-breadcrumbs">,
436+
HelpText<"Don't emit DWARF skeleton CUs for imported Clang modules. "
437+
"Use this when building a redistributable static archive.">;
438+
435439
def use_jit : Flag<["-"], "use-jit">,
436440
HelpText<"Register Objective-C classes as if the JIT were in use">;
437441

0 commit comments

Comments
 (0)