Skip to content

Commit 5653a03

Browse files
authored
---
yaml --- r: 348975 b: refs/heads/master c: c9f1900 h: refs/heads/master i: 348973: 89e51af 348971: e18a6b6 348967: 61d458c 348959: 4b99b7c
1 parent fec6538 commit 5653a03

File tree

74 files changed

+1322
-895
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

+1322
-895
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 483bd5dbc364cbe7cdfd6e3b1d92f1b3cd774be3
2+
refs/heads/master: c9f1900d3b6ca17bbe58bc7f26ebc19498ed0360
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swift.gyb linguist-language=Swift
2+
*.cpp.gyb linguist-language=C++

trunk/cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ function(_compile_swift_files
333333
"-emit-module-interface-path" "${interface_file}")
334334
endif()
335335

336+
if (NOT SWIFTFILE_IS_STDLIB_CORE)
337+
list(APPEND swift_module_flags
338+
"-Xfrontend" "-experimental-skip-non-inlinable-function-bodies")
339+
endif()
340+
336341
# If we have extra regexp flags, check if we match any of the regexps. If so
337342
# add the relevant flags to our swift_flags.
338343
if (SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS OR SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS)

trunk/include/swift/AST/Attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ class DeclAttributes {
16721672
public:
16731673
template <typename ATTR, bool AllowInvalid>
16741674
using AttributeKindRange =
1675-
OptionalTransformRange<llvm::iterator_range<const_iterator>,
1675+
OptionalTransformRange<iterator_range<const_iterator>,
16761676
ToAttributeKind<ATTR, AllowInvalid>,
16771677
const_iterator>;
16781678

trunk/include/swift/AST/DeclContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ class DeclIterator {
667667

668668
/// The range of declarations stored within an iterable declaration
669669
/// context.
670-
typedef IteratorRange<DeclIterator> DeclRange;
670+
using DeclRange = iterator_range<DeclIterator>;
671671

672672
/// The kind of an \c IterableDeclContext.
673673
enum class IterableDeclContextKind : uint8_t {

trunk/include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ ERROR(expected_expr_throw,PointsToFirstBadToken,
970970
// Yield Statment
971971
ERROR(expected_expr_yield,PointsToFirstBadToken,
972972
"expected expression in 'yield' statement", ())
973+
ERROR(unexpected_arg_label_yield,none,
974+
"unexpected argument label in 'yield' statement", ())
973975

974976
// Defer Statement
975977
ERROR(expected_lbrace_after_defer,PointsToFirstBadToken,

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,6 +3493,8 @@ ERROR(single_tuple_parameter_mismatch_special,none,
34933493
ERROR(single_tuple_parameter_mismatch_normal,none,
34943494
"%0 %1 expects a single parameter of type %2%3",
34953495
(DescriptiveDeclKind, DeclBaseName, Type, StringRef))
3496+
NOTE(note_maybe_forgot_to_form_tuple,none,
3497+
"did you mean to pass a tuple?", ())
34963498
ERROR(unknown_single_tuple_parameter_mismatch,none,
34973499
"single parameter of type %0 is expected in call", (Type))
34983500
ERROR(cannot_convert_single_tuple_into_multiple_arguments,none,

trunk/include/swift/AST/TypeRepr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ struct TupleTypeReprElement {
653653
TypeRepr *Type;
654654
SourceLoc TrailingCommaLoc;
655655

656-
TupleTypeReprElement() {}
656+
TupleTypeReprElement(): Type(nullptr) {}
657657
TupleTypeReprElement(TypeRepr *Type): Type(Type) {}
658658
};
659659

trunk/include/swift/AST/Types.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,13 +3965,11 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
39653965
};
39663966
using IndirectFormalResultIter =
39673967
llvm::filter_iterator<const SILResultInfo *, IndirectFormalResultFilter>;
3968-
using IndirectFormalResultRange = IteratorRange<IndirectFormalResultIter>;
3968+
using IndirectFormalResultRange = iterator_range<IndirectFormalResultIter>;
39693969

39703970
/// A range of SILResultInfo for all formally indirect results.
39713971
IndirectFormalResultRange getIndirectFormalResults() const {
3972-
auto filter =
3973-
llvm::make_filter_range(getResults(), IndirectFormalResultFilter());
3974-
return makeIteratorRange(filter.begin(), filter.end());
3972+
return llvm::make_filter_range(getResults(), IndirectFormalResultFilter());
39753973
}
39763974

39773975
struct DirectFormalResultFilter {
@@ -3981,13 +3979,11 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
39813979
};
39823980
using DirectFormalResultIter =
39833981
llvm::filter_iterator<const SILResultInfo *, DirectFormalResultFilter>;
3984-
using DirectFormalResultRange = IteratorRange<DirectFormalResultIter>;
3982+
using DirectFormalResultRange = iterator_range<DirectFormalResultIter>;
39853983

39863984
/// A range of SILResultInfo for all formally direct results.
39873985
DirectFormalResultRange getDirectFormalResults() const {
3988-
auto filter =
3989-
llvm::make_filter_range(getResults(), DirectFormalResultFilter());
3990-
return makeIteratorRange(filter.begin(), filter.end());
3986+
return llvm::make_filter_range(getResults(), DirectFormalResultFilter());
39913987
}
39923988

39933989
/// Get a single non-address SILType that represents all formal direct

trunk/include/swift/Basic/BlotSetVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ class BlotSetVector {
6767

6868
ArrayRef<Optional<ValueT>> getArray() const { return vector; }
6969

70-
llvm::iterator_range<const_iterator> getRange() const {
70+
iterator_range<const_iterator> getRange() const {
7171
return {begin(), end()};
7272
}
7373

7474
using const_reverse_iterator = typename VectorT::const_reverse_iterator;
7575
const_reverse_iterator rbegin() const { return vector.rbegin(); }
7676
const_reverse_iterator rend() const { return vector.rend(); }
77-
llvm::iterator_range<const_reverse_iterator> getReverseRange() const {
77+
iterator_range<const_reverse_iterator> getReverseRange() const {
7878
return {rbegin(), rend()};
7979
}
8080

trunk/include/swift/Basic/LLVM.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace llvm {
4343
template<typename T> class TinyPtrVector;
4444
template<typename T> class Optional;
4545
template <typename ...PTs> class PointerUnion;
46+
template <typename IteratorT> class iterator_range;
4647
class SmallBitVector;
4748

4849
// Other common classes.
@@ -63,6 +64,7 @@ namespace swift {
6364

6465
// Containers.
6566
using llvm::ArrayRef;
67+
using llvm::iterator_range;
6668
using llvm::MutableArrayRef;
6769
using llvm::None;
6870
using llvm::Optional;

trunk/include/swift/Basic/Range.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
namespace swift {
4646
using llvm::make_range;
47-
using llvm::iterator_range;
4847

4948
template<typename T>
5049
inline auto reversed(T &&container)

trunk/include/swift/Basic/STLExtras.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,37 +251,13 @@ inline Iterator prev_or_begin(Iterator it, Iterator begin) {
251251

252252
/// @}
253253

254-
/// A range of iterators.
255-
/// TODO: Add `llvm::iterator_range::empty()`, then remove this helper, along
256-
/// with the superfluous TransformIterator.
257-
template<typename Iterator>
258-
class IteratorRange {
259-
Iterator First, Last;
260-
261-
public:
262-
using iterator = Iterator;
263-
264-
IteratorRange(Iterator first, Iterator last) : First(first), Last(last) { }
265-
iterator begin() const { return First; }
266-
iterator end() const { return Last; }
267-
bool empty() const { return First == Last; }
268-
269-
typename std::iterator_traits<iterator>::value_type front() const {
270-
assert(!empty() && "Front of empty range");
271-
return *begin();
272-
}
273-
};
274-
275-
/// Create a new iterator range.
276-
template<typename Iterator>
277-
inline IteratorRange<Iterator>
278-
makeIteratorRange(Iterator first, Iterator last) {
279-
return IteratorRange<Iterator>(first, last);
280-
}
281254

282255
/// An iterator that transforms the result of an underlying bidirectional
283256
/// iterator with a given operation.
284257
///
258+
/// Slightly different semantics from llvm::map_iterator, but we should
259+
/// probably figure out how to merge them eventually.
260+
///
285261
/// \tparam Iterator the underlying iterator.
286262
///
287263
/// \tparam Operation A function object that transforms the underlying

trunk/include/swift/Parse/ASTGen.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class ASTGen {
3737

3838
// FIXME: remove when Syntax can represent all types and ASTGen can handle
3939
// them
40+
/// Exprs that cannot be represented by Syntax or generated by ASTGen.
41+
llvm::DenseMap<SourceLoc, Expr *> Exprs;
42+
4043
/// Decl attributes that cannot be represented by Syntax or generated by
4144
/// ASTGen.
4245
llvm::DenseMap<SourceLoc, DeclAttributes> ParsedDeclAttrs;
@@ -81,6 +84,10 @@ class ASTGen {
8184

8285
Expr *generate(const syntax::ExprSyntax &Expr, const SourceLoc Loc);
8386
Expr *generate(const syntax::IdentifierExprSyntax &Expr, const SourceLoc Loc);
87+
Expr *generate(const syntax::SuperRefExprSyntax &Expr, const SourceLoc Loc);
88+
Expr *generate(const syntax::ArrayExprSyntax &Expr, const SourceLoc Loc);
89+
Expr *generate(const syntax::DictionaryExprSyntax &Expr, const SourceLoc Loc);
90+
Expr *generate(const syntax::TupleExprSyntax &E, const SourceLoc Loc);
8491
Expr *generate(const syntax::EditorPlaceholderExprSyntax &Expr,
8592
const SourceLoc Loc);
8693
Expr *generate(const syntax::SpecializeExprSyntax &Expr, const SourceLoc Loc);
@@ -106,7 +113,14 @@ class ASTGen {
106113
const Optional<syntax::DeclNameArgumentsSyntax> &args,
107114
const SourceLoc Loc);
108115

116+
void generateExprTupleElementList(const syntax::TupleExprElementListSyntax &elements,
117+
const SourceLoc Loc, bool isForCallArguments,
118+
SmallVectorImpl<Expr *> &exprs,
119+
SmallVectorImpl<Identifier> &exprLabels,
120+
SmallVectorImpl<SourceLoc> &exprLabelLocs);
121+
109122
private:
123+
void validateCollectionElement(Expr *elementExpr);
110124

111125
Expr *generateMagicIdentifierLiteralExpression(
112126
const syntax::TokenSyntax &PoundToken, const SourceLoc Loc);
@@ -210,6 +224,13 @@ class ASTGen {
210224
static SourceLoc advanceLocBegin(const SourceLoc &Loc,
211225
const syntax::Syntax &Node);
212226

227+
/// Advance \p Loc to the last non-missing token of the \p Node or, if it
228+
/// doesn't contain any, the last non-missing token preceding it in the tree.
229+
/// \p Loc must be the leading trivia of the first token in the tree in which
230+
/// \p Node resides
231+
static SourceLoc advanceLocEnd(const SourceLoc &Loc,
232+
const syntax::Syntax &Node);
233+
213234
ValueDecl *lookupInScope(DeclName Name);
214235

215236
void addToScope(ValueDecl *D, bool diagnoseRedefinitions = true);
@@ -219,9 +240,13 @@ class ASTGen {
219240
TypeRepr *lookupType(syntax::TypeSyntax Type);
220241

221242
public:
243+
void addExpr(Expr *Expr, const SourceLoc Loc);
244+
bool hasExpr(const SourceLoc Loc) const;
245+
Expr *takeExpr(const SourceLoc Loc);
246+
222247
void addDeclAttributes(DeclAttributes attrs, const SourceLoc Loc);
223248
bool hasDeclAttributes(SourceLoc Loc) const;
224-
DeclAttributes getDeclAttributes(const SourceLoc Loc) const;
249+
DeclAttributes takeDeclAttributes(const SourceLoc Loc);
225250
};
226251
} // namespace swift
227252

trunk/include/swift/Parse/ParsedRawSyntaxNode.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ParsedRawSyntaxNode {
5252
};
5353
struct DeferredLayoutNode {
5454
MutableArrayRef<ParsedRawSyntaxNode> Children;
55+
CharSourceRange Range;
5556
};
5657
struct DeferredTokenNode {
5758
const ParsedTriviaPiece *TriviaPieces;
@@ -72,9 +73,9 @@ class ParsedRawSyntaxNode {
7273
/// Primary used for capturing a deferred missing token.
7374
bool IsMissing = false;
7475

75-
ParsedRawSyntaxNode(syntax::SyntaxKind k,
76+
ParsedRawSyntaxNode(syntax::SyntaxKind k, CharSourceRange r,
7677
MutableArrayRef<ParsedRawSyntaxNode> deferredNodes)
77-
: DeferredLayout({deferredNodes}),
78+
: DeferredLayout({deferredNodes, r}),
7879
SynKind(uint16_t(k)), TokKind(uint16_t(tok::unknown)),
7980
DK(DataKind::DeferredLayout) {
8081
assert(getKind() == k && "Syntax kind with too large value!");
@@ -211,14 +212,12 @@ class ParsedRawSyntaxNode {
211212
return copy;
212213
}
213214

214-
CharSourceRange getDeferredRange(bool includeTrivia) const {
215+
CharSourceRange getDeferredRange() const {
215216
switch (DK) {
216217
case DataKind::DeferredLayout:
217-
return getDeferredLayoutRange(includeTrivia);
218+
return getDeferredLayoutRange();
218219
case DataKind::DeferredToken:
219-
return includeTrivia
220-
? getDeferredTokenRangeWithTrivia()
221-
: getDeferredTokenRange();
220+
return getDeferredTokenRangeWithTrivia();
222221
default:
223222
llvm_unreachable("node not deferred");
224223
}
@@ -243,20 +242,9 @@ class ParsedRawSyntaxNode {
243242

244243
// Deferred Layout Data ====================================================//
245244

246-
CharSourceRange getDeferredLayoutRange(bool includeTrivia) const {
245+
CharSourceRange getDeferredLayoutRange() const {
247246
assert(DK == DataKind::DeferredLayout);
248-
auto HasValidRange = [includeTrivia](const ParsedRawSyntaxNode &Child) {
249-
return !Child.isNull() && !Child.isMissing() &&
250-
Child.getDeferredRange(includeTrivia).isValid();
251-
};
252-
auto first = llvm::find_if(getDeferredChildren(), HasValidRange);
253-
if (first == getDeferredChildren().end())
254-
return CharSourceRange();
255-
auto last = llvm::find_if(llvm::reverse(getDeferredChildren()),
256-
HasValidRange);
257-
auto firstRange = first->getDeferredRange(includeTrivia);
258-
firstRange.widen(last->getDeferredRange(includeTrivia));
259-
return firstRange;
247+
return DeferredLayout.Range;
260248
}
261249
ArrayRef<ParsedRawSyntaxNode> getDeferredChildren() const {
262250
assert(DK == DataKind::DeferredLayout);

trunk/include/swift/Parse/ParsedSyntaxNodes.h.gyb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ namespace swift {
3232
% if not node.is_syntax_collection():
3333
class Parsed${node.name};
3434
% end
35+
% if node.is_buildable():
36+
class Parsed${node.name}Builder;
37+
% end
3538
% end
3639

3740
% for node in SYNTAX_NODES + PARSEONLY_NODES:
@@ -79,6 +82,10 @@ public:
7982
static bool classof(const ParsedSyntax *S) {
8083
return kindof(S->getKind());
8184
}
85+
86+
% if node.is_buildable():
87+
using Builder = Parsed${node.name}Builder;
88+
% end
8289
};
8390

8491
% end

0 commit comments

Comments
 (0)