Skip to content

Commit 52a06ad

Browse files
Merge pull request #888 from swiftwasm/maxd/master-merge
Resolve conflicts with master
2 parents da9e60e + 3fc1573 commit 52a06ad

File tree

17 files changed

+322
-516
lines changed

17 files changed

+322
-516
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 196 additions & 338 deletions
Large diffs are not rendered by default.

include/swift/AST/Decl.h

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7156,18 +7156,16 @@ class OperatorDecl : public Decl {
71567156

71577157
Identifier name;
71587158

7159-
ArrayRef<Identifier> Identifiers;
7160-
ArrayRef<SourceLoc> IdentifierLocs;
7159+
ArrayRef<Located<Identifier>> Identifiers;
71617160
ArrayRef<NominalTypeDecl *> DesignatedNominalTypes;
71627161
SourceLoc getLocFromSource() const { return NameLoc; }
71637162
friend class Decl;
71647163
public:
71657164
OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
71667165
Identifier Name, SourceLoc NameLoc,
7167-
ArrayRef<Identifier> Identifiers,
7168-
ArrayRef<SourceLoc> IdentifierLocs)
7166+
ArrayRef<Located<Identifier>> Identifiers)
71697167
: Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
7170-
Identifiers(Identifiers), IdentifierLocs(IdentifierLocs) {}
7168+
Identifiers(Identifiers) {}
71717169

71727170
OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
71737171
Identifier Name, SourceLoc NameLoc,
@@ -7202,14 +7200,10 @@ class OperatorDecl : public Decl {
72027200
///
72037201
/// \todo These two purposes really ought to be in separate properties and the
72047202
/// designated type list should be of TypeReprs instead of Identifiers.
7205-
ArrayRef<Identifier> getIdentifiers() const {
7203+
ArrayRef<Located<Identifier>> getIdentifiers() const {
72067204
return Identifiers;
72077205
}
72087206

7209-
ArrayRef<SourceLoc> getIdentifierLocs() const {
7210-
return IdentifierLocs;
7211-
}
7212-
72137207
ArrayRef<NominalTypeDecl *> getDesignatedNominalTypes() const {
72147208
return DesignatedNominalTypes;
72157209
}
@@ -7238,18 +7232,17 @@ class InfixOperatorDecl : public OperatorDecl {
72387232
public:
72397233
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
72407234
SourceLoc nameLoc, SourceLoc colonLoc,
7241-
ArrayRef<Identifier> identifiers,
7242-
ArrayRef<SourceLoc> identifierLocs)
7235+
ArrayRef<Located<Identifier>> identifiers)
72437236
: OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
7244-
identifiers, identifierLocs),
7237+
identifiers),
72457238
ColonLoc(colonLoc) {}
72467239

72477240
SourceLoc getEndLoc() const {
7248-
auto identifierLocs = getIdentifierLocs();
7249-
if (identifierLocs.empty())
7241+
auto identifiers = getIdentifiers();
7242+
if (identifiers.empty())
72507243
return getNameLoc();
72517244

7252-
return identifierLocs.back();
7245+
return identifiers.back().Loc;
72537246
}
72547247

72557248
SourceRange getSourceRange() const {
@@ -7280,10 +7273,9 @@ class PrefixOperatorDecl : public OperatorDecl {
72807273
public:
72817274
PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
72827275
SourceLoc NameLoc,
7283-
ArrayRef<Identifier> Identifiers,
7284-
ArrayRef<SourceLoc> IdentifierLocs)
7276+
ArrayRef<Located<Identifier>> Identifiers)
72857277
: OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,
7286-
Identifiers, IdentifierLocs) {}
7278+
Identifiers) {}
72877279

72887280
PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
72897281
SourceLoc NameLoc,
@@ -7315,10 +7307,9 @@ class PostfixOperatorDecl : public OperatorDecl {
73157307
public:
73167308
PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
73177309
SourceLoc NameLoc,
7318-
ArrayRef<Identifier> Identifiers,
7319-
ArrayRef<SourceLoc> IdentifierLocs)
7310+
ArrayRef<Located<Identifier>> Identifiers)
73207311
: OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,
7321-
Identifiers, IdentifierLocs) {}
7312+
Identifiers) {}
73227313

73237314
PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
73247315
SourceLoc NameLoc,

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ namespace {
12291229
auto identifiers = OD->getIdentifiers();
12301230
for (auto index : indices(identifiers)) {
12311231
OS.indent(Indent + 2);
1232-
OS << "identifier #" << index << " " << identifiers[index];
1232+
OS << "identifier #" << index << " " << identifiers[index].Item;
12331233
if (index != identifiers.size() - 1)
12341234
OS << "\n";
12351235
}

lib/Basic/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ add_swift_host_library(swiftBasic STATIC
7878
# Platform-agnostic fallback TaskQueue implementation
7979
Default/TaskQueue.inc
8080

81-
GYB_SOURCES
82-
UnicodeExtendedGraphemeClusters.cpp.gyb
83-
8481
LLVM_LINK_COMPONENTS support)
82+
_swift_gyb_target_sources(swiftBasic PRIVATE
83+
UnicodeExtendedGraphemeClusters.cpp.gyb)
84+
8585
target_include_directories(swiftBasic PRIVATE
8686
${UUID_INCLUDE})
8787

lib/Parse/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ add_swift_host_library(swiftParse STATIC
2222
PersistentParserState.cpp
2323
Scope.cpp
2424
SyntaxParsingCache.cpp
25-
SyntaxParsingContext.cpp
26-
27-
GYB_SOURCES
25+
SyntaxParsingContext.cpp)
26+
_swift_gyb_target_sources(swiftParse PRIVATE
2827
ParsedSyntaxBuilders.cpp.gyb
2928
ParsedSyntaxNodes.cpp.gyb
3029
ParsedSyntaxRecorder.cpp.gyb)

lib/Parse/ParseDecl.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7530,8 +7530,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
75307530
// parse them both as identifiers here and sort it out in type
75317531
// checking.
75327532
SourceLoc colonLoc;
7533-
SmallVector<Identifier, 4> identifiers;
7534-
SmallVector<SourceLoc, 4> identifierLocs;
7533+
SmallVector<Located<Identifier>, 4> identifiers;
75357534
if (Tok.is(tok::colon)) {
75367535
SyntaxParsingContext GroupCtxt(SyntaxContext,
75377536
SyntaxKind::OperatorPrecedenceAndTypes);
@@ -7552,16 +7551,16 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
75527551
SyntaxKind::IdentifierList);
75537552

75547553
Identifier name;
7555-
identifierLocs.push_back(consumeIdentifier(&name));
7556-
identifiers.push_back(name);
7554+
auto loc = consumeIdentifier(&name);
7555+
identifiers.emplace_back(name, loc);
75577556

75587557
while (Tok.is(tok::comma)) {
75597558
auto comma = consumeToken();
75607559

75617560
if (Tok.is(tok::identifier)) {
75627561
Identifier name;
7563-
identifierLocs.push_back(consumeIdentifier(&name));
7564-
identifiers.push_back(name);
7562+
auto loc = consumeIdentifier(&name);
7563+
identifiers.emplace_back(name, loc);
75657564
} else {
75667565
if (Tok.isNot(tok::eof)) {
75677566
auto otherTokLoc = consumeToken();
@@ -7576,12 +7575,13 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
75767575
SyntaxParsingContext GroupCtxt(SyntaxContext,
75777576
SyntaxKind::IdentifierList);
75787577

7579-
identifiers.push_back(Context.getIdentifier(Tok.getText()));
7580-
identifierLocs.push_back(consumeToken(tok::identifier));
7578+
Identifier name;
7579+
auto nameLoc = consumeIdentifier(&name);
7580+
identifiers.emplace_back(name, nameLoc);
75817581

75827582
if (isPrefix || isPostfix) {
75837583
diagnose(colonLoc, diag::precedencegroup_not_infix)
7584-
.fixItRemove({colonLoc, identifierLocs.back()});
7584+
.fixItRemove({colonLoc, nameLoc});
75857585
}
75867586
// Nothing to complete here, simply consume the token.
75877587
if (Tok.is(tok::code_complete))
@@ -7598,7 +7598,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
75987598
auto Diag = diagnose(lBraceLoc, diag::deprecated_operator_body);
75997599
if (Tok.is(tok::r_brace)) {
76007600
SourceLoc lastGoodLoc =
7601-
!identifierLocs.empty() ? identifierLocs.back() : SourceLoc();
7601+
!identifiers.empty() ? identifiers.back().Loc : SourceLoc();
76027602
if (lastGoodLoc.isInvalid())
76037603
lastGoodLoc = NameLoc;
76047604
SourceLoc lastGoodLocEnd = Lexer::getLocForEndOfToken(SourceMgr,
@@ -7616,18 +7616,15 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
76167616
if (Attributes.hasAttribute<PrefixAttr>())
76177617
res = new (Context)
76187618
PrefixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc,
7619-
Context.AllocateCopy(identifiers),
7620-
Context.AllocateCopy(identifierLocs));
7619+
Context.AllocateCopy(identifiers));
76217620
else if (Attributes.hasAttribute<PostfixAttr>())
76227621
res = new (Context)
76237622
PostfixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc,
7624-
Context.AllocateCopy(identifiers),
7625-
Context.AllocateCopy(identifierLocs));
7623+
Context.AllocateCopy(identifiers));
76267624
else
76277625
res = new (Context)
76287626
InfixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc, colonLoc,
7629-
Context.AllocateCopy(identifiers),
7630-
Context.AllocateCopy(identifierLocs));
7627+
Context.AllocateCopy(identifiers));
76317628

76327629
diagnoseOperatorFixityAttributes(*this, Attributes, res);
76337630

lib/Sema/TypeCheckAccess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,9 +2006,9 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
20062006
// FIXME: Handle operator designated types (which also applies to prefix
20072007
// and postfix operators).
20082008
if (auto *precedenceGroup = IOD->getPrecedenceGroup()) {
2009-
if (!IOD->getIdentifierLocs().empty()) {
2009+
if (!IOD->getIdentifiers().empty()) {
20102010
checkPrecedenceGroup(precedenceGroup, IOD, IOD->getLoc(),
2011-
IOD->getIdentifierLocs().front());
2011+
IOD->getIdentifiers().front().Loc);
20122012
}
20132013
}
20142014
}

0 commit comments

Comments
 (0)