Skip to content

Commit 15ea3fe

Browse files
committed
Merge branch 'master' into martinboehme-patch-1
2 parents e530ef8 + 5013a02 commit 15ea3fe

File tree

156 files changed

+2291
-444
lines changed

Some content is hidden

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

156 files changed

+2291
-444
lines changed

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ SWIFT_TYPEID_NAMED(PatternBindingEntry *, PatternBindingEntry)
5757
SWIFT_TYPEID_NAMED(PostfixOperatorDecl *, PostfixOperatorDecl)
5858
SWIFT_TYPEID_NAMED(PrecedenceGroupDecl *, PrecedenceGroupDecl)
5959
SWIFT_TYPEID_NAMED(PrefixOperatorDecl *, PrefixOperatorDecl)
60+
SWIFT_TYPEID_NAMED(ProtocolConformance *, ProtocolConformance)
6061
SWIFT_TYPEID_NAMED(ProtocolDecl *, ProtocolDecl)
6162
SWIFT_TYPEID_NAMED(SourceFile *, SourceFile)
6263
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct PropertyWrapperTypeInfo;
5252
enum class CtorInitializerKind;
5353
struct PropertyWrapperLValueness;
5454
struct PropertyWrapperMutability;
55+
class ProtocolConformance;
5556
class ProtocolDecl;
5657
class Requirement;
5758
enum class ResilienceExpansion : unsigned;

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5069,6 +5069,14 @@ NOTE(function_builder_remove_attr, none,
50695069
"remove the attribute to explicitly disable the function builder", ())
50705070
NOTE(function_builder_remove_returns, none,
50715071
"remove 'return' statements to apply the function builder", ())
5072+
ERROR(function_builder_infer_ambig, none,
5073+
"ambiguous function builder inferred for %0: %1 or %2",
5074+
(DeclName, Type, Type))
5075+
NOTE(function_builder_infer_add_return, none,
5076+
"add an explicit 'return' statement to not use a function builder", ())
5077+
NOTE(function_builder_infer_pick_specific, none,
5078+
"apply function builder %0 (inferred from protocol %1)",
5079+
(Type, DeclName))
50725080

50735081
//------------------------------------------------------------------------------
50745082
// MARK: Tuple Shuffle Diagnostics

include/swift/AST/SILGenRequests.h

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,39 @@ template<typename Request>
4040
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
4141
const Request &request);
4242

43-
struct SILGenDescriptor {
43+
/// Describes a file or module to be lowered to SIL.
44+
struct ASTLoweringDescriptor {
4445
llvm::PointerUnion<FileUnit *, ModuleDecl *> context;
4546
Lowering::TypeConverter &conv;
4647
const SILOptions &opts;
4748

48-
friend llvm::hash_code hash_value(const SILGenDescriptor &owner) {
49+
friend llvm::hash_code hash_value(const ASTLoweringDescriptor &owner) {
4950
return llvm::hash_combine(owner.context, (void *)&owner.conv,
5051
(void *)&owner.opts);
5152
}
5253

53-
friend bool operator==(const SILGenDescriptor &lhs,
54-
const SILGenDescriptor &rhs) {
54+
friend bool operator==(const ASTLoweringDescriptor &lhs,
55+
const ASTLoweringDescriptor &rhs) {
5556
return lhs.context == rhs.context &&
5657
&lhs.conv == &rhs.conv &&
5758
&lhs.opts == &rhs.opts;
5859
}
5960

60-
friend bool operator!=(const SILGenDescriptor &lhs,
61-
const SILGenDescriptor &rhs) {
61+
friend bool operator!=(const ASTLoweringDescriptor &lhs,
62+
const ASTLoweringDescriptor &rhs) {
6263
return !(lhs == rhs);
6364
}
6465

6566
public:
66-
static SILGenDescriptor forFile(FileUnit &sf, Lowering::TypeConverter &conv,
67-
const SILOptions &opts) {
68-
return SILGenDescriptor{&sf, conv, opts};
67+
static ASTLoweringDescriptor
68+
forFile(FileUnit &sf, Lowering::TypeConverter &conv, const SILOptions &opts) {
69+
return ASTLoweringDescriptor{&sf, conv, opts};
6970
}
7071

71-
static SILGenDescriptor forWholeModule(ModuleDecl *mod,
72-
Lowering::TypeConverter &conv,
73-
const SILOptions &opts) {
74-
return SILGenDescriptor{mod, conv, opts};
72+
static ASTLoweringDescriptor forWholeModule(ModuleDecl *mod,
73+
Lowering::TypeConverter &conv,
74+
const SILOptions &opts) {
75+
return ASTLoweringDescriptor{mod, conv, opts};
7576
}
7677

7778
/// For a single file input, returns a single element array containing that
@@ -83,13 +84,17 @@ struct SILGenDescriptor {
8384
SourceFile *getSourceFileToParse() const;
8485
};
8586

86-
void simple_display(llvm::raw_ostream &out, const SILGenDescriptor &d);
87+
void simple_display(llvm::raw_ostream &out, const ASTLoweringDescriptor &d);
8788

88-
SourceLoc extractNearestSourceLoc(const SILGenDescriptor &desc);
89+
SourceLoc extractNearestSourceLoc(const ASTLoweringDescriptor &desc);
8990

90-
class SILGenerationRequest
91+
/// Lowers a file or module to SIL. In most cases this involves transforming
92+
/// a file's AST into SIL, through SILGen. However it can also handle files
93+
/// containing SIL in textual or binary form, which will be parsed or
94+
/// deserialized as needed.
95+
class ASTLoweringRequest
9196
: public SimpleRequest<
92-
SILGenerationRequest, std::unique_ptr<SILModule>(SILGenDescriptor),
97+
ASTLoweringRequest, std::unique_ptr<SILModule>(ASTLoweringDescriptor),
9398
RequestFlags::Uncached | RequestFlags::DependencySource> {
9499
public:
95100
using SimpleRequest::SimpleRequest;
@@ -98,8 +103,8 @@ class SILGenerationRequest
98103
friend SimpleRequest;
99104

100105
// Evaluation.
101-
std::unique_ptr<SILModule>
102-
evaluate(Evaluator &evaluator, SILGenDescriptor desc) const;
106+
std::unique_ptr<SILModule> evaluate(Evaluator &evaluator,
107+
ASTLoweringDescriptor desc) const;
103108

104109
public:
105110
// Incremental dependencies.
@@ -110,7 +115,7 @@ class SILGenerationRequest
110115
/// Parses a .sil file into a SILModule.
111116
class ParseSILModuleRequest
112117
: public SimpleRequest<ParseSILModuleRequest,
113-
std::unique_ptr<SILModule>(SILGenDescriptor),
118+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
114119
RequestFlags::Uncached> {
115120
public:
116121
using SimpleRequest::SimpleRequest;
@@ -119,8 +124,8 @@ class ParseSILModuleRequest
119124
friend SimpleRequest;
120125

121126
// Evaluation.
122-
std::unique_ptr<SILModule>
123-
evaluate(Evaluator &evaluator, SILGenDescriptor desc) const;
127+
std::unique_ptr<SILModule> evaluate(Evaluator &evaluator,
128+
ASTLoweringDescriptor desc) const;
124129
};
125130

126131
/// The zone number for SILGen.

include/swift/AST/SILGenTypeIDZone.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
SWIFT_REQUEST(SILGen, SILGenerationRequest,
18-
std::unique_ptr<SILModule>(SILGenDescriptor),
17+
SWIFT_REQUEST(SILGen, ASTLoweringRequest,
18+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
1919
Uncached, NoLocationInfo)
2020
SWIFT_REQUEST(SILGen, ParseSILModuleRequest,
21-
std::unique_ptr<SILModule>(SILGenDescriptor),
21+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
2222
Uncached, NoLocationInfo)

include/swift/AST/SemanticAttrs.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SEMANTICS_ATTR(ARRAY_GET_ELEMENT_ADDRESS, "array.get_element_address")
5151
SEMANTICS_ATTR(ARRAY_INIT, "array.init")
5252
SEMANTICS_ATTR(ARRAY_INIT_EMPTY, "array.init.empty")
5353
SEMANTICS_ATTR(ARRAY_MAKE_MUTABLE, "array.make_mutable")
54+
SEMANTICS_ATTR(ARRAY_END_MUTATION, "array.end_mutation")
5455
SEMANTICS_ATTR(ARRAY_MUTATE_UNKNOWN, "array.mutate_unknown")
5556
SEMANTICS_ATTR(ARRAY_PROPS_IS_NATIVE_TYPE_CHECKED, "array.props.isNativeTypeChecked")
5657
SEMANTICS_ATTR(ARRAY_RESERVE_CAPACITY_FOR_APPEND, "array.reserve_capacity_for_append")
@@ -67,6 +68,8 @@ SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_PARTIAL_NEVER,
6768
"optimize.sil.specialize.generic.partial.never")
6869
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_SIZE_NEVER,
6970
"optimize.sil.specialize.generic.size.never")
71+
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_OWNED2GUARANTEE_NEVER,
72+
"optimize.sil.specialize.owned2guarantee.never")
7073

7174
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_INTERPOLATION, "oslog.message.init_interpolation")
7275
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_STRING_LITERAL, "oslog.message.init_stringliteral")

include/swift/AST/TypeCheckRequests.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ class ClosureHasExplicitResultRequest
22402240
bool isCached() const { return true; }
22412241
};
22422242

2243-
using ProtocolConformanceLookupResult = SmallVector<ProtocolConformance *, 2>;
2243+
using ProtocolConformanceLookupResult = std::vector<ProtocolConformance *>;
22442244
void simple_display(llvm::raw_ostream &out, ConformanceLookupKind kind);
22452245

22462246
/// Lookup and expand all conformances in the given context.
@@ -2262,7 +2262,7 @@ class LookupAllConformancesInContextRequest
22622262
: public SimpleRequest<LookupAllConformancesInContextRequest,
22632263
ProtocolConformanceLookupResult(
22642264
const IterableDeclContext *),
2265-
RequestFlags::Uncached |
2265+
RequestFlags::Cached |
22662266
RequestFlags::DependencySink |
22672267
RequestFlags::DependencySource> {
22682268
public:
@@ -2276,6 +2276,8 @@ class LookupAllConformancesInContextRequest
22762276
evaluate(Evaluator &evaluator, const IterableDeclContext *IDC) const;
22772277

22782278
public:
2279+
bool isCached() const { return true; }
2280+
22792281
// Incremental dependencies
22802282
evaluator::DependencySource
22812283
readDependencySource(const evaluator::DependencyRecorder &eval) const;

include/swift/Basic/DiagnosticOptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class DiagnosticOptions {
3232
VerifyAndApplyFixes
3333
} VerifyMode = NoVerify;
3434

35+
enum FormattingStyle { LLVM, Swift };
36+
3537
/// Indicates whether to allow diagnostics for \c <unknown> locations if
3638
/// \c VerifyMode is not \c NoVerify.
3739
bool VerifyIgnoreUnknown = false;
@@ -61,7 +63,7 @@ class DiagnosticOptions {
6163

6264
// If set to true, use the more descriptive experimental formatting style for
6365
// diagnostics.
64-
bool EnableExperimentalFormatting = false;
66+
FormattingStyle PrintedFormattingStyle = FormattingStyle::LLVM;
6567

6668
std::string DiagnosticDocumentationPath = "";
6769

include/swift/Basic/SimpleDisplay.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ namespace swift {
136136
out << "}";
137137
}
138138

139+
template<typename T>
140+
void simple_display(llvm::raw_ostream &out,
141+
const std::vector<T> &vec) {
142+
out << "{";
143+
bool first = true;
144+
for (const T &value : vec) {
145+
if (first) first = false;
146+
else out << ", ";
147+
148+
simple_display(out, value);
149+
}
150+
out << "}";
151+
}
152+
139153
template<typename T, typename U>
140154
void simple_display(llvm::raw_ostream &out,
141155
const llvm::PointerUnion<T, U> &ptrUnion) {

include/swift/Basic/SourceManager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class SourceManager {
206206
///
207207
/// This respects \c #sourceLocation directives.
208208
std::pair<unsigned, unsigned>
209-
getLineAndColumn(SourceLoc Loc, unsigned BufferID = 0) const {
209+
getPresumedLineAndColumnForLoc(SourceLoc Loc, unsigned BufferID = 0) const {
210210
assert(Loc.isValid());
211211
int LineOffset = getLineOffset(Loc);
212212
int l, c;
@@ -215,14 +215,15 @@ class SourceManager {
215215
return { LineOffset + l, c };
216216
}
217217

218-
/// Returns the real line number for a source location.
218+
/// Returns the real line and column for a source location.
219219
///
220220
/// If \p BufferID is provided, \p Loc must come from that source buffer.
221221
///
222222
/// This does not respect \c #sourceLocation directives.
223-
unsigned getLineNumber(SourceLoc Loc, unsigned BufferID = 0) const {
223+
std::pair<unsigned, unsigned>
224+
getLineAndColumnInBuffer(SourceLoc Loc, unsigned BufferID = 0) const {
224225
assert(Loc.isValid());
225-
return LLVMSourceMgr.FindLineNumber(Loc.Value, BufferID);
226+
return LLVMSourceMgr.getLineAndColumn(Loc.Value, BufferID);
226227
}
227228

228229
StringRef getEntireTextForBuffer(unsigned BufferID) const;

0 commit comments

Comments
 (0)