Skip to content

Resolve conflicts with master #888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
534 changes: 196 additions & 338 deletions cmake/modules/AddSwift.cmake

Large diffs are not rendered by default.

35 changes: 13 additions & 22 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7156,18 +7156,16 @@ class OperatorDecl : public Decl {

Identifier name;

ArrayRef<Identifier> Identifiers;
ArrayRef<SourceLoc> IdentifierLocs;
ArrayRef<Located<Identifier>> Identifiers;
ArrayRef<NominalTypeDecl *> DesignatedNominalTypes;
SourceLoc getLocFromSource() const { return NameLoc; }
friend class Decl;
public:
OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
Identifier Name, SourceLoc NameLoc,
ArrayRef<Identifier> Identifiers,
ArrayRef<SourceLoc> IdentifierLocs)
ArrayRef<Located<Identifier>> Identifiers)
: Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
Identifiers(Identifiers), IdentifierLocs(IdentifierLocs) {}
Identifiers(Identifiers) {}

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

ArrayRef<SourceLoc> getIdentifierLocs() const {
return IdentifierLocs;
}

ArrayRef<NominalTypeDecl *> getDesignatedNominalTypes() const {
return DesignatedNominalTypes;
}
Expand Down Expand Up @@ -7238,18 +7232,17 @@ class InfixOperatorDecl : public OperatorDecl {
public:
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
SourceLoc nameLoc, SourceLoc colonLoc,
ArrayRef<Identifier> identifiers,
ArrayRef<SourceLoc> identifierLocs)
ArrayRef<Located<Identifier>> identifiers)
: OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
identifiers, identifierLocs),
identifiers),
ColonLoc(colonLoc) {}

SourceLoc getEndLoc() const {
auto identifierLocs = getIdentifierLocs();
if (identifierLocs.empty())
auto identifiers = getIdentifiers();
if (identifiers.empty())
return getNameLoc();

return identifierLocs.back();
return identifiers.back().Loc;
}

SourceRange getSourceRange() const {
Expand Down Expand Up @@ -7280,10 +7273,9 @@ class PrefixOperatorDecl : public OperatorDecl {
public:
PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
SourceLoc NameLoc,
ArrayRef<Identifier> Identifiers,
ArrayRef<SourceLoc> IdentifierLocs)
ArrayRef<Located<Identifier>> Identifiers)
: OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,
Identifiers, IdentifierLocs) {}
Identifiers) {}

PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
SourceLoc NameLoc,
Expand Down Expand Up @@ -7315,10 +7307,9 @@ class PostfixOperatorDecl : public OperatorDecl {
public:
PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
SourceLoc NameLoc,
ArrayRef<Identifier> Identifiers,
ArrayRef<SourceLoc> IdentifierLocs)
ArrayRef<Located<Identifier>> Identifiers)
: OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,
Identifiers, IdentifierLocs) {}
Identifiers) {}

PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
SourceLoc NameLoc,
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ namespace {
auto identifiers = OD->getIdentifiers();
for (auto index : indices(identifiers)) {
OS.indent(Indent + 2);
OS << "identifier #" << index << " " << identifiers[index];
OS << "identifier #" << index << " " << identifiers[index].Item;
if (index != identifiers.size() - 1)
OS << "\n";
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ add_swift_host_library(swiftBasic STATIC
# Platform-agnostic fallback TaskQueue implementation
Default/TaskQueue.inc

GYB_SOURCES
UnicodeExtendedGraphemeClusters.cpp.gyb

LLVM_LINK_COMPONENTS support)
_swift_gyb_target_sources(swiftBasic PRIVATE
UnicodeExtendedGraphemeClusters.cpp.gyb)

target_include_directories(swiftBasic PRIVATE
${UUID_INCLUDE})

Expand Down
5 changes: 2 additions & 3 deletions lib/Parse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ add_swift_host_library(swiftParse STATIC
PersistentParserState.cpp
Scope.cpp
SyntaxParsingCache.cpp
SyntaxParsingContext.cpp

GYB_SOURCES
SyntaxParsingContext.cpp)
_swift_gyb_target_sources(swiftParse PRIVATE
ParsedSyntaxBuilders.cpp.gyb
ParsedSyntaxNodes.cpp.gyb
ParsedSyntaxRecorder.cpp.gyb)
Expand Down
29 changes: 13 additions & 16 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7530,8 +7530,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
// parse them both as identifiers here and sort it out in type
// checking.
SourceLoc colonLoc;
SmallVector<Identifier, 4> identifiers;
SmallVector<SourceLoc, 4> identifierLocs;
SmallVector<Located<Identifier>, 4> identifiers;
if (Tok.is(tok::colon)) {
SyntaxParsingContext GroupCtxt(SyntaxContext,
SyntaxKind::OperatorPrecedenceAndTypes);
Expand All @@ -7552,16 +7551,16 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
SyntaxKind::IdentifierList);

Identifier name;
identifierLocs.push_back(consumeIdentifier(&name));
identifiers.push_back(name);
auto loc = consumeIdentifier(&name);
identifiers.emplace_back(name, loc);

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

if (Tok.is(tok::identifier)) {
Identifier name;
identifierLocs.push_back(consumeIdentifier(&name));
identifiers.push_back(name);
auto loc = consumeIdentifier(&name);
identifiers.emplace_back(name, loc);
} else {
if (Tok.isNot(tok::eof)) {
auto otherTokLoc = consumeToken();
Expand All @@ -7576,12 +7575,13 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
SyntaxParsingContext GroupCtxt(SyntaxContext,
SyntaxKind::IdentifierList);

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

if (isPrefix || isPostfix) {
diagnose(colonLoc, diag::precedencegroup_not_infix)
.fixItRemove({colonLoc, identifierLocs.back()});
.fixItRemove({colonLoc, nameLoc});
}
// Nothing to complete here, simply consume the token.
if (Tok.is(tok::code_complete))
Expand All @@ -7598,7 +7598,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
auto Diag = diagnose(lBraceLoc, diag::deprecated_operator_body);
if (Tok.is(tok::r_brace)) {
SourceLoc lastGoodLoc =
!identifierLocs.empty() ? identifierLocs.back() : SourceLoc();
!identifiers.empty() ? identifiers.back().Loc : SourceLoc();
if (lastGoodLoc.isInvalid())
lastGoodLoc = NameLoc;
SourceLoc lastGoodLocEnd = Lexer::getLocForEndOfToken(SourceMgr,
Expand All @@ -7616,18 +7616,15 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
if (Attributes.hasAttribute<PrefixAttr>())
res = new (Context)
PrefixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc,
Context.AllocateCopy(identifiers),
Context.AllocateCopy(identifierLocs));
Context.AllocateCopy(identifiers));
else if (Attributes.hasAttribute<PostfixAttr>())
res = new (Context)
PostfixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc,
Context.AllocateCopy(identifiers),
Context.AllocateCopy(identifierLocs));
Context.AllocateCopy(identifiers));
else
res = new (Context)
InfixOperatorDecl(CurDeclContext, OperatorLoc, Name, NameLoc, colonLoc,
Context.AllocateCopy(identifiers),
Context.AllocateCopy(identifierLocs));
Context.AllocateCopy(identifiers));

diagnoseOperatorFixityAttributes(*this, Attributes, res);

Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/TypeCheckAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2006,9 +2006,9 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
// FIXME: Handle operator designated types (which also applies to prefix
// and postfix operators).
if (auto *precedenceGroup = IOD->getPrecedenceGroup()) {
if (!IOD->getIdentifierLocs().empty()) {
if (!IOD->getIdentifiers().empty()) {
checkPrecedenceGroup(precedenceGroup, IOD, IOD->getLoc(),
IOD->getIdentifierLocs().front());
IOD->getIdentifiers().front().Loc);
}
}
}
Expand Down
Loading