[NFC] Thread DeclNameRef through most of the compiler

This huge commit contains as many of the mechanical changes as possible.
This commit is contained in:
Brent Royal-Gordon
2019-12-10 19:46:10 -08:00
parent da88512eda
commit addbe3e5ed
66 changed files with 505 additions and 464 deletions

View File

@@ -753,7 +753,7 @@ Parser::parseImplementsAttribute(SourceLoc AtLoc, SourceLoc Loc) {
SourceLoc lParenLoc = consumeToken();
DeclNameLoc MemberNameLoc;
DeclName MemberName;
DeclNameRef MemberName;
ParserResult<TypeRepr> ProtocolType;
{
SyntaxParsingContext ContentContext(
@@ -794,9 +794,12 @@ Parser::parseImplementsAttribute(SourceLoc AtLoc, SourceLoc Loc) {
return Status;
}
// FIXME(ModQual): Reject module qualification on MemberName.
return ParserResult<ImplementsAttr>(
ImplementsAttr::create(Context, AtLoc, SourceRange(Loc, rParenLoc),
ProtocolType.get(), MemberName, MemberNameLoc));
ProtocolType.get(), MemberName.getFullName(),
MemberNameLoc));
}
/// Parse a `@differentiable` attribute, returning true on error.
@@ -817,8 +820,8 @@ Parser::parseDifferentiableAttribute(SourceLoc atLoc, SourceLoc loc) {
SourceLoc lParenLoc = loc, rParenLoc = loc;
bool linear = false;
SmallVector<ParsedAutoDiffParameter, 8> params;
Optional<DeclNameWithLoc> jvpSpec;
Optional<DeclNameWithLoc> vjpSpec;
Optional<DeclNameRefWithLoc> jvpSpec;
Optional<DeclNameRefWithLoc> vjpSpec;
TrailingWhereClause *whereClause = nullptr;
// Parse '('.
@@ -946,7 +949,8 @@ bool Parser::parseDifferentiationParametersClause(
bool Parser::parseDifferentiableAttributeArguments(
bool &linear, SmallVectorImpl<ParsedAutoDiffParameter> &params,
Optional<DeclNameWithLoc> &jvpSpec, Optional<DeclNameWithLoc> &vjpSpec,
Optional<DeclNameRefWithLoc> &jvpSpec,
Optional<DeclNameRefWithLoc> &vjpSpec,
TrailingWhereClause *&whereClause) {
StringRef AttrName = "differentiable";
@@ -1006,7 +1010,7 @@ bool Parser::parseDifferentiableAttributeArguments(
// Function that parses a label and a function specifier, e.g. 'vjp: foo(_:)'.
// Return true on error.
auto parseFuncSpec = [&](StringRef label, DeclNameWithLoc &result,
auto parseFuncSpec = [&](StringRef label, DeclNameRefWithLoc &result,
bool &terminateParsingArgs) -> bool {
// Parse label.
if (parseSpecificIdentifier(label,
@@ -1035,7 +1039,7 @@ bool Parser::parseDifferentiableAttributeArguments(
if (isIdentifier(Tok, "jvp")) {
SyntaxParsingContext JvpContext(
SyntaxContext, SyntaxKind::DifferentiableAttributeFuncSpecifier);
jvpSpec = DeclNameWithLoc();
jvpSpec = DeclNameRefWithLoc();
if (parseFuncSpec("jvp", *jvpSpec, terminateParsingArgs))
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
if (terminateParsingArgs)
@@ -1048,7 +1052,7 @@ bool Parser::parseDifferentiableAttributeArguments(
if (isIdentifier(Tok, "vjp")) {
SyntaxParsingContext VjpContext(
SyntaxContext, SyntaxKind::DifferentiableAttributeFuncSpecifier);
vjpSpec = DeclNameWithLoc();
vjpSpec = DeclNameRefWithLoc();
if (parseFuncSpec("vjp", *vjpSpec, terminateParsingArgs))
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
if (terminateParsingArgs)
@@ -1087,7 +1091,7 @@ ParserResult<DerivativeAttr> Parser::parseDerivativeAttribute(SourceLoc atLoc,
SourceLoc loc) {
StringRef AttrName = "derivative";
SourceLoc lParenLoc = loc, rParenLoc = loc;
DeclNameWithLoc original;
DeclNameRefWithLoc original;
SmallVector<ParsedAutoDiffParameter, 8> params;
// Parse trailing comma, if it exists, and check for errors.
@@ -2033,7 +2037,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
}
SourceLoc LParenLoc = consumeToken(tok::l_paren);
DeclName replacedFunction;
DeclNameRef replacedFunction;
{
SyntaxParsingContext ContentContext(
SyntaxContext, SyntaxKind::NamedAttributeStringArgument);
@@ -3652,7 +3656,7 @@ Parser::parseDecl(ParseDeclOptions Flags,
if (CurDeclContext) {
if (auto nominal = dyn_cast<NominalTypeDecl>(CurDeclContext)) {
diagnose(nominal->getLoc(), diag::note_in_decl_extension, false,
nominal->getName());
nominal->createNameRef());
} else if (auto extension = dyn_cast<ExtensionDecl>(CurDeclContext)) {
if (auto repr = extension->getExtendedTypeRepr()) {
if (auto idRepr = dyn_cast<IdentTypeRepr>(repr)) {
@@ -4041,8 +4045,8 @@ ParserStatus Parser::parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
// Add 'AnyObject' to the inherited list.
Inherited.push_back(
new (Context) SimpleIdentTypeRepr(DeclNameLoc(classLoc),
Context.getIdentifier("AnyObject")));
new (Context) SimpleIdentTypeRepr(DeclNameLoc(classLoc), DeclNameRef_(
Context.getIdentifier("AnyObject"))));
continue;
}