Skip to content

Commit addbe3e

Browse files
committed
[NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
1 parent da88512 commit addbe3e

Some content is hidden

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

66 files changed

+505
-464
lines changed

include/swift/AST/Attr.h

+32-30
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TypeAttributes {
6868

6969
struct Convention {
7070
StringRef Name = {};
71-
DeclName WitnessMethodProtocol = {};
71+
DeclNameRef WitnessMethodProtocol = {};
7272
StringRef ClangType = {};
7373
// Carry the source location for diagnostics.
7474
SourceLoc ClangTypeLoc = {};
@@ -78,7 +78,7 @@ class TypeAttributes {
7878
/// Don't use this function if you are creating a C convention as you
7979
/// probably need a ClangType field as well.
8080
static Convention makeSwiftConvention(StringRef name) {
81-
return {name, DeclName(), "", {}};
81+
return {name, DeclNameRef(), "", {}};
8282
}
8383
};
8484

@@ -1057,23 +1057,24 @@ class DynamicReplacementAttr final
10571057
friend TrailingObjects;
10581058
friend class DynamicallyReplacedDeclRequest;
10591059

1060-
DeclName ReplacedFunctionName;
1060+
DeclNameRef ReplacedFunctionName;
10611061
LazyMemberLoader *Resolver = nullptr;
10621062
uint64_t ResolverContextData;
10631063

10641064
/// Create an @_dynamicReplacement(for:) attribute written in the source.
10651065
DynamicReplacementAttr(SourceLoc atLoc, SourceRange baseRange,
1066-
DeclName replacedFunctionName, SourceRange parenRange);
1066+
DeclNameRef replacedFunctionName,
1067+
SourceRange parenRange);
10671068

1068-
DynamicReplacementAttr(DeclName name, AbstractFunctionDecl *f)
1069+
DynamicReplacementAttr(DeclNameRef name, AbstractFunctionDecl *f)
10691070
: DeclAttribute(DAK_DynamicReplacement, SourceLoc(), SourceRange(),
10701071
/*Implicit=*/false),
10711072
ReplacedFunctionName(name),
10721073
Resolver(nullptr), ResolverContextData(0) {
10731074
Bits.DynamicReplacementAttr.HasTrailingLocationInfo = false;
10741075
}
10751076

1076-
DynamicReplacementAttr(DeclName name,
1077+
DynamicReplacementAttr(DeclNameRef name,
10771078
LazyMemberLoader *Resolver = nullptr,
10781079
uint64_t Data = 0)
10791080
: DeclAttribute(DAK_DynamicReplacement, SourceLoc(), SourceRange(),
@@ -1100,18 +1101,18 @@ class DynamicReplacementAttr final
11001101
public:
11011102
static DynamicReplacementAttr *
11021103
create(ASTContext &Context, SourceLoc AtLoc, SourceLoc DynReplLoc,
1103-
SourceLoc LParenLoc, DeclName replacedFunction, SourceLoc RParenLoc);
1104+
SourceLoc LParenLoc, DeclNameRef replacedFunction, SourceLoc RParenLoc);
11041105

11051106
static DynamicReplacementAttr *create(ASTContext &ctx,
1106-
DeclName replacedFunction,
1107+
DeclNameRef replacedFunction,
11071108
AbstractFunctionDecl *replacedFuncDecl);
11081109

11091110
static DynamicReplacementAttr *create(ASTContext &ctx,
1110-
DeclName replacedFunction,
1111+
DeclNameRef replacedFunction,
11111112
LazyMemberLoader *Resolver,
11121113
uint64_t Data);
11131114

1114-
DeclName getReplacedFunctionName() const {
1115+
DeclNameRef getReplacedFunctionName() const {
11151116
return ReplacedFunctionName;
11161117
}
11171118

@@ -1630,8 +1631,8 @@ class OriginallyDefinedInAttr: public DeclAttribute {
16301631
};
16311632

16321633
/// A declaration name with location.
1633-
struct DeclNameWithLoc {
1634-
DeclName Name;
1634+
struct DeclNameRefWithLoc {
1635+
DeclNameRef Name;
16351636
DeclNameLoc Loc;
16361637
};
16371638

@@ -1652,9 +1653,9 @@ class DifferentiableAttr final
16521653
/// The number of parsed parameters specified in 'wrt:'.
16531654
unsigned NumParsedParameters = 0;
16541655
/// The JVP function.
1655-
Optional<DeclNameWithLoc> JVP;
1656+
Optional<DeclNameRefWithLoc> JVP;
16561657
/// The VJP function.
1657-
Optional<DeclNameWithLoc> VJP;
1658+
Optional<DeclNameRefWithLoc> VJP;
16581659
/// The JVP function (optional), resolved by the type checker if JVP name is
16591660
/// specified.
16601661
FuncDecl *JVPFunction = nullptr;
@@ -1674,43 +1675,43 @@ class DifferentiableAttr final
16741675
explicit DifferentiableAttr(bool implicit, SourceLoc atLoc,
16751676
SourceRange baseRange, bool linear,
16761677
ArrayRef<ParsedAutoDiffParameter> parameters,
1677-
Optional<DeclNameWithLoc> jvp,
1678-
Optional<DeclNameWithLoc> vjp,
1678+
Optional<DeclNameRefWithLoc> jvp,
1679+
Optional<DeclNameRefWithLoc> vjp,
16791680
TrailingWhereClause *clause);
16801681

16811682
explicit DifferentiableAttr(Decl *original, bool implicit, SourceLoc atLoc,
16821683
SourceRange baseRange, bool linear,
16831684
IndexSubset *parameterIndices,
1684-
Optional<DeclNameWithLoc> jvp,
1685-
Optional<DeclNameWithLoc> vjp,
1685+
Optional<DeclNameRefWithLoc> jvp,
1686+
Optional<DeclNameRefWithLoc> vjp,
16861687
GenericSignature derivativeGenericSignature);
16871688

16881689
public:
16891690
static DifferentiableAttr *create(ASTContext &context, bool implicit,
16901691
SourceLoc atLoc, SourceRange baseRange,
16911692
bool linear,
16921693
ArrayRef<ParsedAutoDiffParameter> params,
1693-
Optional<DeclNameWithLoc> jvp,
1694-
Optional<DeclNameWithLoc> vjp,
1694+
Optional<DeclNameRefWithLoc> jvp,
1695+
Optional<DeclNameRefWithLoc> vjp,
16951696
TrailingWhereClause *clause);
16961697

16971698
static DifferentiableAttr *create(AbstractFunctionDecl *original,
16981699
bool implicit, SourceLoc atLoc,
16991700
SourceRange baseRange, bool linear,
17001701
IndexSubset *parameterIndices,
1701-
Optional<DeclNameWithLoc> jvp,
1702-
Optional<DeclNameWithLoc> vjp,
1702+
Optional<DeclNameRefWithLoc> jvp,
1703+
Optional<DeclNameRefWithLoc> vjp,
17031704
GenericSignature derivativeGenSig);
17041705

17051706
/// Get the optional 'jvp:' function name and location.
17061707
/// Use this instead of `getJVPFunction` to check whether the attribute has a
17071708
/// registered JVP.
1708-
Optional<DeclNameWithLoc> getJVP() const { return JVP; }
1709+
Optional<DeclNameRefWithLoc> getJVP() const { return JVP; }
17091710

17101711
/// Get the optional 'vjp:' function name and location.
17111712
/// Use this instead of `getVJPFunction` to check whether the attribute has a
17121713
/// registered VJP.
1713-
Optional<DeclNameWithLoc> getVJP() const { return VJP; }
1714+
Optional<DeclNameRefWithLoc> getVJP() const { return VJP; }
17141715

17151716
IndexSubset *getParameterIndices() const {
17161717
return ParameterIndices;
@@ -1775,7 +1776,7 @@ class DerivativeAttr final
17751776
friend TrailingObjects;
17761777

17771778
/// The original function name.
1778-
DeclNameWithLoc OriginalFunctionName;
1779+
DeclNameRefWithLoc OriginalFunctionName;
17791780
/// The original function declaration, resolved by the type checker.
17801781
AbstractFunctionDecl *OriginalFunction = nullptr;
17811782
/// The number of parsed parameters specified in 'wrt:'.
@@ -1786,23 +1787,24 @@ class DerivativeAttr final
17861787
Optional<AutoDiffDerivativeFunctionKind> Kind = None;
17871788

17881789
explicit DerivativeAttr(bool implicit, SourceLoc atLoc, SourceRange baseRange,
1789-
DeclNameWithLoc original,
1790+
DeclNameRefWithLoc original,
17901791
ArrayRef<ParsedAutoDiffParameter> params);
17911792

17921793
explicit DerivativeAttr(bool implicit, SourceLoc atLoc, SourceRange baseRange,
1793-
DeclNameWithLoc original, IndexSubset *indices);
1794+
DeclNameRefWithLoc original, IndexSubset *indices);
17941795

17951796
public:
17961797
static DerivativeAttr *create(ASTContext &context, bool implicit,
17971798
SourceLoc atLoc, SourceRange baseRange,
1798-
DeclNameWithLoc original,
1799+
DeclNameRefWithLoc original,
17991800
ArrayRef<ParsedAutoDiffParameter> params);
18001801

18011802
static DerivativeAttr *create(ASTContext &context, bool implicit,
18021803
SourceLoc atLoc, SourceRange baseRange,
1803-
DeclNameWithLoc original, IndexSubset *indices);
1804+
DeclNameRefWithLoc original,
1805+
IndexSubset *indices);
18041806

1805-
DeclNameWithLoc getOriginalFunctionName() const {
1807+
DeclNameRefWithLoc getOriginalFunctionName() const {
18061808
return OriginalFunctionName;
18071809
}
18081810
AbstractFunctionDecl *getOriginalFunction() const {

include/swift/AST/DiagnosticsCommon.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ NOTE(kind_declname_declared_here,none,
163163
WARNING(warn_property_wrapper_module_scope,none,
164164
"ignoring associated type %0 in favor of module-scoped property "
165165
"wrapper %0; please qualify the reference with %1",
166-
(DeclName, Identifier))
166+
(DeclNameRef, Identifier))
167167

168168
#ifndef DIAG_NO_UNDEF
169169
# if defined(DIAG)

include/swift/AST/DiagnosticsParse.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ERROR(lex_conflict_marker_in_file,none,
207207
//------------------------------------------------------------------------------
208208

209209
NOTE(note_in_decl_extension,none,
210-
"in %select{declaration|extension}0 of %1", (bool, DeclName))
210+
"in %select{declaration|extension}0 of %1", (bool, DeclNameRef))
211211
ERROR(line_directive_style_deprecated,none,
212212
"#line directive was renamed to #sourceLocation",
213213
())

0 commit comments

Comments
 (0)