Skip to content

Commit d1f6eb4

Browse files
---
yaml --- r: 344318 b: refs/heads/master-rebranch c: b520076 h: refs/heads/master
1 parent 993da03 commit d1f6eb4

Some content is hidden

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

60 files changed

+825
-539
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 061c036a233b45743a7ebe4645c66340cb48726c
1458+
refs/heads/master-rebranch: b520076aff48d7c15e7391b15d1df7864e11d6be
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
118118
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AttributeNodes.py"
119119
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AvailabilityNodes.py"
120120
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CommonNodes.py"
121+
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CompletionOnlyNodes.py"
121122
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/DeclNodes.py"
122123
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/ExprNodes.py"
123124
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/GenericNodes.py"

branches/master-rebranch/include/swift/AST/TypeCheckRequests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ class InferredGenericSignatureRequest :
10941094
public SimpleRequest<InferredGenericSignatureRequest,
10951095
GenericSignature *(ModuleDecl *,
10961096
GenericSignature *,
1097-
SmallVector<GenericParamList *, 2>,
1097+
GenericParamList *,
10981098
SmallVector<Requirement, 2>,
10991099
SmallVector<TypeLoc, 2>,
11001100
bool),
@@ -1110,7 +1110,7 @@ class InferredGenericSignatureRequest :
11101110
evaluate(Evaluator &evaluator,
11111111
ModuleDecl *module,
11121112
GenericSignature *baseSignature,
1113-
SmallVector<GenericParamList *, 2> addedParameters,
1113+
GenericParamList *gpl,
11141114
SmallVector<Requirement, 2> addedRequirements,
11151115
SmallVector<TypeLoc, 2> inferenceSources,
11161116
bool allowConcreteGenericParams) const;

branches/master-rebranch/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ SWIFT_REQUEST(NameLookup, GenericSignatureRequest,
5454
SeparatelyCached, NoLocationInfo)
5555
SWIFT_REQUEST(TypeChecker, InferredGenericSignatureRequest,
5656
GenericSignature *(ModuleDecl *, GenericSignature *,
57-
SmallVector<GenericParamList *, 2>,
57+
GenericParamList *,
5858
SmallVector<Requirement, 2>,
5959
SmallVector<TypeLoc, 2>, bool),
6060
Cached, NoLocationInfo)

branches/master-rebranch/include/swift/Parse/ASTGen.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "swift/AST/ASTContext.h"
1717
#include "swift/AST/Decl.h"
1818
#include "swift/AST/Expr.h"
19+
#include "swift/AST/TypeRepr.h"
1920
#include "swift/Parse/PersistentParserState.h"
2021
#include "swift/Syntax/SyntaxNodes.h"
2122
#include "llvm/ADT/DenseMap.h"
@@ -43,6 +44,30 @@ class ASTGen {
4344

4445
SourceLoc generate(const syntax::TokenSyntax &Tok, const SourceLoc Loc);
4546

47+
SourceLoc generateIdentifierDeclName(const syntax::TokenSyntax &Tok,
48+
const SourceLoc, Identifier &Identifier);
49+
50+
public:
51+
//===--------------------------------------------------------------------===//
52+
// Decls.
53+
54+
Decl *generate(const syntax::DeclSyntax &Decl, const SourceLoc Loc);
55+
TypeDecl *generate(const syntax::AssociatedtypeDeclSyntax &Decl,
56+
const SourceLoc Loc);
57+
58+
TrailingWhereClause *generate(const syntax::GenericWhereClauseSyntax &syntax,
59+
const SourceLoc Loc);
60+
MutableArrayRef<TypeLoc>
61+
generate(const syntax::TypeInheritanceClauseSyntax &syntax,
62+
const SourceLoc Loc, bool allowClassRequirement);
63+
64+
private:
65+
DeclAttributes
66+
generateDeclAttributes(const syntax::DeclSyntax &D,
67+
const Optional<syntax::AttributeListSyntax> &attrs,
68+
const Optional<syntax::ModifierListSyntax> &modifiers,
69+
SourceLoc Loc, bool includeComments);
70+
4671
public:
4772
//===--------------------------------------------------------------------===//
4873
// Expressions.
@@ -97,6 +122,10 @@ class ASTGen {
97122
const SourceLoc Loc);
98123
TypeRepr *generate(const syntax::ImplicitlyUnwrappedOptionalTypeSyntax &Type,
99124
const SourceLoc Loc);
125+
TypeRepr *generate(const syntax::ClassRestrictionTypeSyntax &Type,
126+
const SourceLoc Loc);
127+
TypeRepr *generate(const syntax::CodeCompletionTypeSyntax &Type,
128+
const SourceLoc Loc);
100129
TypeRepr *generate(const syntax::UnknownTypeSyntax &Type,
101130
const SourceLoc Loc);
102131

branches/master-rebranch/include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CodeCompletionCallbacks {
4040
/// completion. This declaration contained the code completion token.
4141
Decl *ParsedDecl = nullptr;
4242

43+
TypeLoc ParsedTypeLoc;
44+
4345
/// True if code completion is done inside a raw value expression of an enum
4446
/// case.
4547
bool InEnumElementRawValue = false;
@@ -76,6 +78,10 @@ class CodeCompletionCallbacks {
7678
ParsedDecl = D;
7779
}
7880

81+
void setParsedTypeLoc(TypeLoc TyLoc) {
82+
ParsedTypeLoc = TyLoc;
83+
}
84+
7985
void setLeadingSequenceExprs(ArrayRef<Expr *> exprs) {
8086
leadingSequenceExprs.assign(exprs.begin(), exprs.end());
8187
}
@@ -159,10 +165,10 @@ class CodeCompletionCallbacks {
159165
virtual void completeTypeSimpleBeginning() {};
160166

161167
/// Complete a given type-identifier after we have consumed the dot.
162-
virtual void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) {};
168+
virtual void completeTypeIdentifierWithDot() {};
163169

164170
/// Complete a given type-identifier when there is no trailing dot.
165-
virtual void completeTypeIdentifierWithoutDot(IdentTypeRepr *ITR) {};
171+
virtual void completeTypeIdentifierWithoutDot() {};
166172

167173
/// Complete the beginning of a case statement at the top of switch stmt.
168174
virtual void completeCaseStmtKeyword() {};

branches/master-rebranch/include/swift/Parse/LibSyntaxGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LibSyntaxGenerator {
3838
assert(Node.isDeferredToken());
3939

4040
auto Kind = Node.getTokenKind();
41-
auto Range = Node.getDeferredTokenRangeWithTrivia();
41+
auto Range = Node.getDeferredTokenRange();
4242
auto LeadingTriviaPieces = Node.getDeferredLeadingTriviaPieces();
4343
auto TrailingTriviaPieces = Node.getDeferredTrailingTriviaPieces();
4444

branches/master-rebranch/include/swift/Parse/ParsedSyntaxBuilders.h.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace swift {
3030
class ParsedRawSyntaxRecorder;
3131
class SyntaxParsingContext;
3232

33-
% for node in SYNTAX_NODES + SILONLY_NODES:
33+
% for node in SYNTAX_NODES + PARSEONLY_NODES:
3434
% if node.is_buildable():
3535
% child_count = len(node.children)
3636
class Parsed${node.name}Builder {

branches/master-rebranch/include/swift/Parse/ParsedSyntaxNodes.h.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ namespace swift {
2828
% # Emit the non-collection classes first, then emit the collection classes
2929
% # that reference these classes.
3030

31-
% for node in SYNTAX_NODES + SILONLY_NODES:
31+
% for node in SYNTAX_NODES + PARSEONLY_NODES:
3232
% if not node.is_syntax_collection():
3333
class Parsed${node.name};
3434
% end
3535
% end
3636

37-
% for node in SYNTAX_NODES + SILONLY_NODES:
37+
% for node in SYNTAX_NODES + PARSEONLY_NODES:
3838
% if node.is_syntax_collection():
3939
using Parsed${node.name} =
4040
ParsedSyntaxCollection<syntax::SyntaxKind::${node.syntax_kind}>;
4141
% end
4242
% end
4343

44-
% for node in SYNTAX_NODES + SILONLY_NODES:
44+
% for node in SYNTAX_NODES + PARSEONLY_NODES:
4545
% if not node.is_syntax_collection():
4646
% qualifier = "" if node.is_base() else "final"
4747
% for line in dedented_lines(node.description):

branches/master-rebranch/include/swift/Parse/ParsedSyntaxRecorder.h.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SyntaxParsingContext;
3131

3232
struct ParsedSyntaxRecorder {
3333

34-
% for node in SYNTAX_NODES + SILONLY_NODES:
34+
% for node in SYNTAX_NODES + PARSEONLY_NODES:
3535
% if node.children:
3636
% child_params = []
3737
% for child in node.children:

branches/master-rebranch/include/swift/Parse/Parser.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,12 +1004,23 @@ class Parser {
10041004
bool delayParsingDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
10051005
IterableDeclContext *IDC);
10061006

1007+
ParsedSyntaxResult<ParsedTypeInheritanceClauseSyntax>
1008+
parseTypeInheritanceClauseSyntax(bool allowClassRequirement,
1009+
bool allowAnyObject);
1010+
1011+
ParsedSyntaxResult<ParsedDeclSyntax>
1012+
parseDeclAssociatedTypeSyntax(ParseDeclOptions flags,
1013+
Optional<ParsedAttributeListSyntax> attrs,
1014+
Optional<ParsedModifierListSyntax> modifiers);
1015+
10071016
ParserResult<TypeDecl> parseDeclTypeAlias(ParseDeclOptions Flags,
1008-
DeclAttributes &Attributes);
1017+
DeclAttributes &Attributes,
1018+
SourceLoc leadingLoc);
10091019

10101020
ParserResult<TypeDecl> parseDeclAssociatedType(ParseDeclOptions Flags,
1011-
DeclAttributes &Attributes);
1012-
1021+
DeclAttributes &Attributes,
1022+
SourceLoc leadingLoc);
1023+
10131024
/// Parse a #if ... #endif directive.
10141025
/// Delegate callback function to parse elements in the blocks.
10151026
ParserResult<IfConfigDecl> parseIfConfig(
@@ -1091,7 +1102,7 @@ class Parser {
10911102

10921103
ParserResult<ImportDecl> parseDeclImport(ParseDeclOptions Flags,
10931104
DeclAttributes &Attributes);
1094-
ParserStatus parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
1105+
ParserStatus parseInheritance(MutableArrayRef<TypeLoc> &Inherited,
10951106
bool allowClassRequirement,
10961107
bool allowAnyObject);
10971108
ParserStatus parseDeclItem(bool &PreviousHadSemi,

branches/master-rebranch/include/swift/Parse/SyntaxParsingContext.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,9 @@ class alignas(1 << SyntaxAlignInBits) SyntaxParsingContext {
279279
}
280280

281281
/// Returns the topmost Syntax node.
282-
template <typename SyntaxNode> SyntaxNode topNode() {
283-
ParsedRawSyntaxNode &TopNode = getStorage().back();
284-
if (TopNode.isRecorded()) {
285-
OpaqueSyntaxNode OpaqueNode = TopNode.getOpaqueNode();
286-
return getSyntaxCreator().getLibSyntaxNodeFor<SyntaxNode>(OpaqueNode);
287-
}
288-
return getSyntaxCreator().createNode<SyntaxNode>(TopNode.copyDeferred());
289-
}
282+
template <typename SyntaxNode> SyntaxNode topNode();
290283

291-
template <typename SyntaxNode>
292-
llvm::Optional<SyntaxNode> popIf() {
284+
template <typename SyntaxNode> llvm::Optional<SyntaxNode> popIf() {
293285
auto &Storage = getStorage();
294286
if (Storage.size() <= Offset)
295287
return llvm::None;
@@ -376,5 +368,24 @@ class alignas(1 << SyntaxAlignInBits) SyntaxParsingContext {
376368
"Only meant for use in the debugger");
377369
};
378370

371+
template <typename SyntaxNode>
372+
inline SyntaxNode SyntaxParsingContext::topNode() {
373+
ParsedRawSyntaxNode &TopNode = getStorage().back();
374+
if (TopNode.isRecorded()) {
375+
OpaqueSyntaxNode OpaqueNode = TopNode.getOpaqueNode();
376+
return getSyntaxCreator().getLibSyntaxNodeFor<SyntaxNode>(OpaqueNode);
377+
}
378+
return getSyntaxCreator().createNode<SyntaxNode>(TopNode.copyDeferred());
379+
}
380+
381+
template <> inline TokenSyntax SyntaxParsingContext::topNode<TokenSyntax>() {
382+
ParsedRawSyntaxNode &TopNode = getStorage().back();
383+
if (TopNode.isRecorded()) {
384+
OpaqueSyntaxNode OpaqueNode = TopNode.getOpaqueNode();
385+
return getSyntaxCreator().getLibSyntaxNodeFor<TokenSyntax>(OpaqueNode);
386+
}
387+
return getSyntaxCreator().createToken(TopNode.copyDeferred());
388+
}
389+
379390
} // namespace swift
380391
#endif // SWIFT_SYNTAX_PARSING_CONTEXT_H

branches/master-rebranch/include/swift/SIL/ApplySite.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,13 @@ class ApplySite {
130130
llvm_unreachable("covered switch"); \
131131
} while (0)
132132

133+
/// Return the callee operand as a value.
134+
SILValue getCallee() const { return getCalleeOperand()->get(); }
135+
133136
/// Return the callee operand.
134-
SILValue getCallee() const { FOREACH_IMPL_RETURN(getCallee()); }
137+
const Operand *getCalleeOperand() const {
138+
FOREACH_IMPL_RETURN(getCalleeOperand());
139+
}
135140

136141
/// Return the callee value by looking through function conversions until we
137142
/// find a function_ref, partial_apply, or unrecognized callee value.

branches/master-rebranch/include/swift/SIL/BranchPropagatedUser.h

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,28 @@ class BranchPropagatedUser {
3131
InnerTy user;
3232

3333
public:
34-
BranchPropagatedUser(SILInstruction *inst) : user(inst) {
35-
assert(!isa<CondBranchInst>(inst));
36-
}
37-
38-
BranchPropagatedUser(CondBranchInst *cbi) : user(cbi) {}
39-
40-
BranchPropagatedUser(CondBranchInst *cbi, unsigned successorIndex)
41-
: user(cbi, successorIndex) {
42-
assert(successorIndex == CondBranchInst::TrueIdx ||
43-
successorIndex == CondBranchInst::FalseIdx);
34+
BranchPropagatedUser(Operand *op) : user() {
35+
auto *opUser = op->getUser();
36+
auto *cbi = dyn_cast<CondBranchInst>(opUser);
37+
if (!cbi) {
38+
user = InnerTy(opUser, 0);
39+
return;
40+
}
41+
unsigned operandIndex = op->getOperandNumber();
42+
if (cbi->isConditionOperandIndex(operandIndex)) {
43+
// TODO: Is this correct?
44+
user = InnerTy(cbi, CondBranchInst::TrueIdx);
45+
return;
46+
}
47+
bool isTrueOperand = cbi->isTrueOperandIndex(operandIndex);
48+
if (isTrueOperand) {
49+
user = InnerTy(cbi, CondBranchInst::TrueIdx);
50+
} else {
51+
user = InnerTy(cbi, CondBranchInst::FalseIdx);
52+
}
4453
}
54+
BranchPropagatedUser(const Operand *op)
55+
: BranchPropagatedUser(const_cast<Operand *>(op)) {}
4556

4657
BranchPropagatedUser(const BranchPropagatedUser &other) : user(other.user) {}
4758
BranchPropagatedUser &operator=(const BranchPropagatedUser &other) {
@@ -96,6 +107,19 @@ class BranchPropagatedUser {
96107
NumLowBitsAvailable =
97108
llvm::PointerLikeTypeTraits<InnerTy>::NumLowBitsAvailable
98109
};
110+
111+
private:
112+
BranchPropagatedUser(SILInstruction *inst) : user(inst) {
113+
assert(!isa<CondBranchInst>(inst));
114+
}
115+
116+
BranchPropagatedUser(CondBranchInst *cbi) : user(cbi) {}
117+
118+
BranchPropagatedUser(CondBranchInst *cbi, unsigned successorIndex)
119+
: user(cbi, successorIndex) {
120+
assert(successorIndex == CondBranchInst::TrueIdx ||
121+
successorIndex == CondBranchInst::FalseIdx);
122+
}
99123
};
100124

101125
} // namespace swift

branches/master-rebranch/include/swift/SIL/OwnershipUtils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,13 @@ struct BorrowScopeIntroducingValue {
310310
/// called with a scope that is not local.
311311
///
312312
/// The intention is that this method can be used instead of
313-
/// BorrowScopeIntroducingValue::getLocalScopeEndingInstructions() to avoid
313+
/// BorrowScopeIntroducingValue::getLocalScopeEndingUses() to avoid
314314
/// introducing an intermediate array when one needs to transform the
315315
/// instructions before storing them.
316316
///
317317
/// NOTE: To determine if a scope is a local scope, call
318318
/// BorrowScopeIntoducingValue::isLocalScope().
319-
void visitLocalScopeEndingInstructions(
320-
function_ref<void(SILInstruction *)> visitor) const;
319+
void visitLocalScopeEndingUses(function_ref<void(Operand *)> visitor) const;
321320

322321
bool isLocalScope() const { return kind.isLocalScope(); }
323322

branches/master-rebranch/include/swift/SIL/SILInstruction.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,8 @@ class ApplyInstBase<Impl, Base, false> : public Base {
18611861
/// The operand number of the first argument.
18621862
static unsigned getArgumentOperandNumber() { return NumStaticOperands; }
18631863

1864-
SILValue getCallee() const { return getAllOperands()[Callee].get(); }
1864+
const Operand *getCalleeOperand() const { return &getAllOperands()[Callee]; }
1865+
SILValue getCallee() const { return getCalleeOperand()->get(); }
18651866

18661867
/// Gets the origin of the callee by looking through function type conversions
18671868
/// until we find a function_ref, partial_apply, or unrecognized value.
@@ -7212,7 +7213,10 @@ class CondBranchInst final
72127213
ProfileCounter FalseBBCount, SILFunction &F);
72137214

72147215
public:
7215-
SILValue getCondition() const { return getAllOperands()[ConditionIdx].get(); }
7216+
const Operand *getConditionOperand() const {
7217+
return &getAllOperands()[ConditionIdx];
7218+
}
7219+
SILValue getCondition() const { return getConditionOperand()->get(); }
72167220
void setCondition(SILValue newCondition) {
72177221
getAllOperands()[ConditionIdx].set(newCondition);
72187222
}
@@ -7258,6 +7262,11 @@ class CondBranchInst final
72587262
return getAllOperands().slice(NumFixedOpers + getNumTrueArgs());
72597263
}
72607264

7265+
/// Returns true if \p op is mapped to the condition operand of the cond_br.
7266+
bool isConditionOperand(Operand *op) const {
7267+
return getConditionOperand() == op;
7268+
}
7269+
72617270
bool isConditionOperandIndex(unsigned OpIndex) const {
72627271
assert(OpIndex < getNumOperands() &&
72637272
"OpIndex must be an index for an actual operand");

branches/master-rebranch/include/swift/Syntax/Syntax.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Syntax {
8383
SyntaxKind getKind() const;
8484

8585
/// Get the shared raw syntax.
86-
RC<RawSyntax> getRaw() const;
86+
const RC<RawSyntax> &getRaw() const;
8787

8888
/// Get an ID for this node that is stable across incremental parses
8989
SyntaxNodeId getId() const { return getRaw()->getId(); }

0 commit comments

Comments
 (0)