Skip to content

Commit ce718ee

Browse files
authored
Merge branch 'master' into normal-conformance-requirement-signature
2 parents 348c6b8 + 2561edd commit ce718ee

File tree

74 files changed

+1285
-776
lines changed

Some content is hidden

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

74 files changed

+1285
-776
lines changed

docs/OwnershipManifesto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ cases to be spelled explicitly:
975975
It's important to allow temporary values to be shared for
976976
function arguments because many function parameters will be
977977
marked as `shared` simply because the functions don't
978-
actually from owning that parameter, not because it's in
978+
actually benefit from owning that parameter, not because it's in
979979
any way semantically important that they be passed a
980980
reference to an existing variable. For example, we expect
981981
to change things like comparison operators to take their

include/swift/AST/DiagnosticsDriver.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ WARNING(warn_cannot_stat_input,none,
113113
"unable to determine when '%0' was last modified: %1",
114114
(StringRef, StringRef))
115115

116+
WARNING(warn_unable_to_load_dependencies, none,
117+
"unable to load dependencies file \"%0\", disabling incremental mode",
118+
(StringRef))
119+
116120
ERROR(error_input_changed_during_build,none,
117121
"input file '%0' was modified during the build",
118122
(StringRef))

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ ERROR(value_type_comparison_with_nil_illegal,none,
164164
ERROR(cannot_match_expr_pattern_with_value,none,
165165
"expression pattern of type %0 cannot match values of type %1",
166166
(Type, Type))
167+
ERROR(cannot_match_unresolved_expr_pattern_with_value,none,
168+
"pattern cannot match values of type %0",
169+
(Type))
167170

168171
ERROR(cannot_reference_compare_types,none,
169172
"cannot check reference equality of functions; operands here have types "

include/swift/AST/Pattern.h

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ class EnumElementPattern : public Pattern {
492492
SourceLoc DotLoc;
493493
SourceLoc NameLoc;
494494
Identifier Name;
495-
EnumElementDecl *ElementDecl;
495+
PointerUnion<EnumElementDecl *, Expr*> ElementDeclOrUnresolvedOriginalExpr;
496496
Pattern /*nullable*/ *SubPattern;
497497

498498
public:
@@ -501,10 +501,25 @@ class EnumElementPattern : public Pattern {
501501
Pattern *SubPattern, Optional<bool> Implicit = None)
502502
: Pattern(PatternKind::EnumElement),
503503
ParentType(ParentType), DotLoc(DotLoc), NameLoc(NameLoc), Name(Name),
504-
ElementDecl(Element), SubPattern(SubPattern) {
504+
ElementDeclOrUnresolvedOriginalExpr(Element),
505+
SubPattern(SubPattern) {
505506
if (Implicit.hasValue() && *Implicit)
506507
setImplicit();
507508
}
509+
510+
/// Create an unresolved EnumElementPattern for a `.foo` pattern relying on
511+
/// contextual type.
512+
EnumElementPattern(SourceLoc DotLoc,
513+
SourceLoc NameLoc,
514+
Identifier Name,
515+
Pattern *SubPattern,
516+
Expr *UnresolvedOriginalExpr)
517+
: Pattern(PatternKind::EnumElement),
518+
ParentType(), DotLoc(DotLoc), NameLoc(NameLoc), Name(Name),
519+
ElementDeclOrUnresolvedOriginalExpr(UnresolvedOriginalExpr),
520+
SubPattern(SubPattern) {
521+
522+
}
508523

509524
bool hasSubPattern() const { return SubPattern; }
510525

@@ -524,8 +539,19 @@ class EnumElementPattern : public Pattern {
524539

525540
Identifier getName() const { return Name; }
526541

527-
EnumElementDecl *getElementDecl() const { return ElementDecl; }
528-
void setElementDecl(EnumElementDecl *d) { ElementDecl = d; }
542+
EnumElementDecl *getElementDecl() const {
543+
return ElementDeclOrUnresolvedOriginalExpr.dyn_cast<EnumElementDecl*>();
544+
}
545+
void setElementDecl(EnumElementDecl *d) {
546+
ElementDeclOrUnresolvedOriginalExpr = d;
547+
}
548+
549+
Expr *getUnresolvedOriginalExpr() const {
550+
return ElementDeclOrUnresolvedOriginalExpr.get<Expr*>();
551+
}
552+
bool hasUnresolvedOriginalExpr() const {
553+
return ElementDeclOrUnresolvedOriginalExpr.is<Expr*>();
554+
}
529555

530556
SourceLoc getNameLoc() const { return NameLoc; }
531557
SourceLoc getLoc() const { return NameLoc; }

include/swift/Basic/Defer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
namespace swift {
2424
template <typename F>
2525
class DoAtScopeExit {
26-
F &Fn;
26+
F Fn;
2727
void operator=(DoAtScopeExit&) = delete;
2828
public:
29-
DoAtScopeExit(F &Fn) : Fn(Fn){}
29+
DoAtScopeExit(F &&Fn) : Fn(std::move(Fn)) {}
3030
~DoAtScopeExit() {
3131
Fn();
3232
}
@@ -36,7 +36,7 @@ namespace swift {
3636
struct DeferTask {};
3737
template<typename F>
3838
DoAtScopeExit<typename std::decay<F>::type> operator+(DeferTask, F&& fn) {
39-
return DoAtScopeExit<typename std::decay<F>::type>(fn);
39+
return DoAtScopeExit<typename std::decay<F>::type>(std::move(fn));
4040
}
4141
}
4242
} // end namespace swift

include/swift/Basic/Demangle.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ class Context {
289289
/// or ObjC-as-swift thunks.
290290
bool isThunkSymbol(llvm::StringRef MangledName);
291291

292+
/// Returns true if the \p mangledName refers to a function which conforms to
293+
/// the Swift calling convention.
294+
///
295+
/// The return value is unspecified if the \p MangledName does not refer to a
296+
/// function symbol.
297+
bool hasSwiftCallingConvention(llvm::StringRef MangledName);
298+
292299
/// Deallocates all nodes.
293300
///
294301
/// The memory which is used for nodes is not freed but recycled for the next

include/swift/Basic/LangOptions.h

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
#include <vector>
3030

3131
namespace swift {
32+
33+
/// Kind of implicit platform conditions.
34+
enum class PlatformConditionKind {
35+
/// The active os target (OSX, iOS, Linux, etc.)
36+
OS,
37+
/// The active arch target (x86_64, i386, arm, arm64, etc.)
38+
Arch,
39+
/// The active endianness target (big or little)
40+
Endianness,
41+
/// Runtime support (_ObjC or _Native)
42+
Runtime,
43+
};
44+
enum { NumPlatformConditionKind = 4 };
45+
3246
/// \brief A collection of options that affect the language dialect and
3347
/// provide compiler debugging facilities.
3448
class LangOptions {
@@ -202,14 +216,9 @@ namespace swift {
202216
}
203217

204218
/// Sets an implicit platform condition.
205-
///
206-
/// There are currently three supported platform conditions:
207-
/// - os: The active os target (OSX or iOS)
208-
/// - arch: The active arch target (x86_64, i386, arm, arm64)
209-
/// - _runtime: Runtime support (_ObjC or _Native)
210-
void addPlatformConditionValue(StringRef Name, StringRef Value) {
211-
assert(!Name.empty() && !Value.empty());
212-
PlatformConditionValues.emplace_back(Name, Value);
219+
void addPlatformConditionValue(PlatformConditionKind Kind, StringRef Value) {
220+
assert(!Value.empty());
221+
PlatformConditionValues.emplace_back(Kind, Value);
213222
}
214223

215224
/// Removes all values added with addPlatformConditionValue.
@@ -218,7 +227,7 @@ namespace swift {
218227
}
219228

220229
/// Returns the value for the given platform condition or an empty string.
221-
StringRef getPlatformConditionValue(StringRef Name) const;
230+
StringRef getPlatformConditionValue(PlatformConditionKind Kind) const;
222231

223232
/// Explicit conditional compilation flags, initialized via the '-D'
224233
/// compiler flag.
@@ -230,7 +239,7 @@ namespace swift {
230239
/// Determines if a given conditional compilation flag has been set.
231240
bool isCustomConditionalCompilationFlagSet(StringRef Name) const;
232241

233-
ArrayRef<std::pair<std::string, std::string>>
242+
ArrayRef<std::pair<PlatformConditionKind, std::string>>
234243
getPlatformConditionValues() const {
235244
return PlatformConditionValues;
236245
}
@@ -244,35 +253,18 @@ namespace swift {
244253
return EffectiveLanguageVersion.isVersion3();
245254
}
246255

247-
/// Returns true if the 'os' platform condition argument represents
256+
/// Returns true if the given platform condition argument represents
248257
/// a supported target operating system.
249258
///
250-
/// Note that this also canonicalizes the OS name if the check returns
251-
/// true.
252-
///
253-
/// \param suggestions Populated with suggested replacements
254-
/// if a match is not found.
255-
static bool checkPlatformConditionOS(
256-
StringRef &OSName, std::vector<StringRef> &suggestions);
257-
258-
/// Returns true if the 'arch' platform condition argument represents
259-
/// a supported target architecture.
260-
///
261-
/// \param suggestions Populated with suggested replacements
262-
/// if a match is not found.
263-
static bool isPlatformConditionArchSupported(
264-
StringRef ArchName, std::vector<StringRef> &suggestions);
265-
266-
/// Returns true if the 'endian' platform condition argument represents
267-
/// a supported target endianness.
268-
///
269259
/// \param suggestions Populated with suggested replacements
270260
/// if a match is not found.
271-
static bool isPlatformConditionEndiannessSupported(
272-
StringRef endianness, std::vector<StringRef> &suggestions);
261+
static bool checkPlatformConditionSupported(
262+
PlatformConditionKind Kind, StringRef Value,
263+
std::vector<StringRef> &suggestions);
273264

274265
private:
275-
llvm::SmallVector<std::pair<std::string, std::string>, 3>
266+
llvm::SmallVector<std::pair<PlatformConditionKind, std::string>,
267+
NumPlatformConditionKind>
276268
PlatformConditionValues;
277269
llvm::SmallVector<std::string, 2> CustomConditionalCompilationFlags;
278270
};

include/swift/Driver/Compilation.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace swift {
4141
namespace driver {
4242
class Driver;
4343
class ToolChain;
44+
class PerformJobsState;
4445

4546
/// An enum providing different levels of output which should be produced
4647
/// by a Compilation.
@@ -56,6 +57,7 @@ enum class OutputLevel {
5657
};
5758

5859
class Compilation {
60+
friend class PerformJobsState;
5961
private:
6062
/// The DiagnosticEngine to which this Compilation should emit diagnostics.
6163
DiagnosticEngine &Diags;
@@ -136,6 +138,10 @@ class Compilation {
136138
/// rebuilt.
137139
bool ShowIncrementalBuildDecisions = false;
138140

141+
/// When true, traces the lifecycle of each driver job. Provides finer
142+
/// detail than ShowIncrementalBuildDecisions.
143+
bool ShowJobLifecycle = false;
144+
139145
static const Job *unwrap(const std::unique_ptr<const Job> &p) {
140146
return p.get();
141147
}
@@ -194,6 +200,10 @@ class Compilation {
194200
ShowIncrementalBuildDecisions = value;
195201
}
196202

203+
void setShowJobLifecycle(bool value = true) {
204+
ShowJobLifecycle = value;
205+
}
206+
197207
void setCompilationRecordPath(StringRef path) {
198208
assert(CompilationRecordPath.empty() && "already set");
199209
CompilationRecordPath = path;

include/swift/Driver/Job.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ class Job {
168168
/// terminating output with the given \p terminator.
169169
void printCommandLine(raw_ostream &Stream, StringRef Terminator = "\n") const;
170170

171+
/// Print a short summary of this Job to the given \p Stream.
172+
void printSummary(raw_ostream &Stream) const;
173+
171174
/// Print the command line for this Job to the given \p stream,
172175
/// and include any extra environment variables that will be set.
173176
///

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def driver_use_frontend_path : Separate<["-"], "driver-use-frontend-path">,
9191
def driver_show_incremental : Flag<["-"], "driver-show-incremental">,
9292
InternalDebugOpt,
9393
HelpText<"With -v, dump information about why files are being rebuilt">;
94+
def driver_show_job_lifecycle : Flag<["-"], "driver-show-job-lifecycle">,
95+
InternalDebugOpt,
96+
HelpText<"Show every step in the lifecycle of driver jobs">;
9497
def driver_use_filelists : Flag<["-"], "driver-use-filelists">,
9598
InternalDebugOpt, HelpText<"Pass input files as filelists whenever possible">;
9699

include/swift/SIL/SILBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,11 @@ class SILBuilder {
12801280
getSILDebugLocation(Loc), Operand, atomicity));
12811281
}
12821282

1283+
EndLifetimeInst *createEndLifetime(SILLocation Loc, SILValue Operand) {
1284+
return insert(new (F.getModule())
1285+
EndLifetimeInst(getSILDebugLocation(Loc), Operand));
1286+
}
1287+
12831288
FixLifetimeInst *createFixLifetime(SILLocation Loc, SILValue Operand) {
12841289
return insert(new (F.getModule())
12851290
FixLifetimeInst(getSILDebugLocation(Loc), Operand));

include/swift/SIL/SILCloner.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,9 +1700,16 @@ SILCloner<ImplClass>::visitFixLifetimeInst(FixLifetimeInst *Inst) {
17001700
getOpValue(Inst->getOperand())));
17011701
}
17021702

1703-
template<typename ImplClass>
1704-
void
1705-
SILCloner<ImplClass>::visitMarkDependenceInst(MarkDependenceInst *Inst) {
1703+
template <typename ImplClass>
1704+
void SILCloner<ImplClass>::visitEndLifetimeInst(EndLifetimeInst *Inst) {
1705+
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1706+
doPostProcess(Inst,
1707+
getBuilder().createEndLifetime(getOpLocation(Inst->getLoc()),
1708+
getOpValue(Inst->getOperand())));
1709+
}
1710+
1711+
template <typename ImplClass>
1712+
void SILCloner<ImplClass>::visitMarkDependenceInst(MarkDependenceInst *Inst) {
17061713
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
17071714
doPostProcess(Inst,
17081715
getBuilder().createMarkDependence(getOpLocation(Inst->getLoc()),

include/swift/SIL/SILInstruction.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,6 +4337,28 @@ class FixLifetimeInst :
43374337
: UnaryInstructionBase(DebugLoc, Operand) {}
43384338
};
43394339

4340+
/// EndLifetimeInst - An artificial end lifetime use of a value for the purpose
4341+
/// of working around verification problems.
4342+
///
4343+
/// Specifically, the signature of destroying deinit takes self at +0 and
4344+
/// returns self at +1. This is an issue since a deallocating deinit takes in
4345+
/// self at +1. Previously, we could rely on the deallocating bit being set in
4346+
/// the object header to allow SILGen to statically balance the +1 from the
4347+
/// deallocating deinit. This is because deallocating values used to be
4348+
/// immortal. The runtime now asserts if we release a deallocating value,
4349+
/// meaning such an approach does not work. This instruction acts as a "fake"
4350+
/// lifetime ending use allowing for static verification of deallocating
4351+
/// destroyers, without an actual release being emitted (avoiding the runtime
4352+
/// assert).
4353+
class EndLifetimeInst
4354+
: public UnaryInstructionBase<ValueKind::EndLifetimeInst, SILInstruction,
4355+
/*HAS_RESULT*/ false> {
4356+
friend SILBuilder;
4357+
4358+
EndLifetimeInst(SILDebugLocation DebugLoc, SILValue Operand)
4359+
: UnaryInstructionBase(DebugLoc, Operand) {}
4360+
};
4361+
43404362
/// MarkDependenceInst - Marks that one value depends on another for
43414363
/// validity in a non-obvious way.
43424364
class MarkDependenceInst : public SILInstruction {

include/swift/SIL/SILNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ ABSTRACT_VALUE(SILInstruction, ValueBase)
164164
INST(UnmanagedAutoreleaseValueInst, RefCountingInst, unmanaged_autorelease_value, MayHaveSideEffects, DoesNotRelease)
165165
INST(CopyUnownedValueInst, SILInstruction, copy_unowned_value, MayHaveSideEffects, DoesNotRelease)
166166
INST(DestroyValueInst, SILInstruction, destroy_value, MayHaveSideEffects, MayRelease)
167+
INST(EndLifetimeInst, SILInstruction, end_lifetime, MayHaveSideEffects, MayRelease)
167168

168169
// IsUnique does not actually write to memory but should be modeled
169170
// as such. Its operand is a pointer to an object reference. The

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
5454
/// in source control, you should also update the comment to briefly
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
57-
const uint16_t VERSION_MINOR = 322; // Last change: requirement conformances
57+
const uint16_t VERSION_MINOR = 323; // Last change: requirement conformances
5858

5959
using DeclID = PointerEmbeddedInt<unsigned, 31>;
6060
using DeclIDField = BCFixed<31>;

include/swift/SwiftDemangle/SwiftDemangle.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ size_t swift_demangle_getSimplifiedDemangledName(const char *MangledName,
5353
char *OutputBuffer,
5454
size_t Length);
5555

56+
/// \brief Demangles a Swift function name and returns true if the function
57+
/// conforms to the Swift calling convention.
58+
///
59+
/// \returns true if the function conforms to the Swift calling convention.
60+
/// The return value is unspecified if the \p MangledName does not refer to a
61+
/// function symbol.
62+
int swift_demangle_hasSwiftCallingConvention(const char *MangledName);
63+
5664
#ifdef __cplusplus
5765
} // extern "C"
5866
#endif

0 commit comments

Comments
 (0)