@@ -1014,8 +1014,7 @@ void SourceFile::setSyntaxRoot(syntax::SourceFileSyntax &&Root) {
1014
1014
1015
1015
template <typename OP_DECL>
1016
1016
static Optional<OP_DECL *>
1017
- lookupOperatorDeclForName (ModuleDecl *M, SourceLoc Loc, Identifier Name,
1018
- OperatorMap<OP_DECL *> SourceFile::*OP_MAP);
1017
+ lookupOperatorDeclForName (ModuleDecl *M, SourceLoc Loc, Identifier Name);
1019
1018
1020
1019
template <typename OP_DECL>
1021
1020
using ImportedOperatorsMap = llvm::SmallDenseMap<OP_DECL*, bool , 16 >;
@@ -1066,8 +1065,7 @@ checkOperatorConflicts(const SourceFile &SF, SourceLoc loc,
1066
1065
template <typename OP_DECL>
1067
1066
static Optional<OP_DECL *>
1068
1067
lookupOperatorDeclForName (const FileUnit &File, SourceLoc Loc,
1069
- Identifier Name, bool includePrivate,
1070
- OperatorMap<OP_DECL *> SourceFile::*OP_MAP) {
1068
+ Identifier Name, bool includePrivate) {
1071
1069
switch (File.getKind ()) {
1072
1070
case FileUnitKind::Builtin:
1073
1071
// The Builtin module declares no operators.
@@ -1084,6 +1082,7 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc,
1084
1082
assert (SF.ASTStage >= SourceFile::NameBound);
1085
1083
1086
1084
// Look for an operator declaration in the current module.
1085
+ const auto OP_MAP = OperatorLookup<OP_DECL>::map_ptr;
1087
1086
auto found = (SF.*OP_MAP).find (Name);
1088
1087
if (found != (SF.*OP_MAP).end () && (includePrivate || found->second .getInt ()))
1089
1088
return found->second .getPointer ();
@@ -1105,7 +1104,7 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc,
1105
1104
continue ;
1106
1105
1107
1106
Optional<OP_DECL *> maybeOp =
1108
- lookupOperatorDeclForName (imported.module .second , Loc, Name, OP_MAP );
1107
+ lookupOperatorDeclForName<OP_DECL> (imported.module .second , Loc, Name);
1109
1108
if (!maybeOp)
1110
1109
return None;
1111
1110
@@ -1138,12 +1137,10 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc,
1138
1137
1139
1138
template <typename OP_DECL>
1140
1139
static Optional<OP_DECL *>
1141
- lookupOperatorDeclForName (ModuleDecl *M, SourceLoc Loc, Identifier Name,
1142
- OperatorMap<OP_DECL *> SourceFile::*OP_MAP)
1143
- {
1140
+ lookupOperatorDeclForName (ModuleDecl *M, SourceLoc Loc, Identifier Name) {
1144
1141
OP_DECL *result = nullptr ;
1145
1142
for (const FileUnit *File : M->getFiles ()) {
1146
- auto next = lookupOperatorDeclForName (*File, Loc, Name, false , OP_MAP );
1143
+ auto next = lookupOperatorDeclForName<OP_DECL> (*File, Loc, Name, false );
1147
1144
if (!next.hasValue ())
1148
1145
return next;
1149
1146
@@ -1159,9 +1156,9 @@ lookupOperatorDeclForName(ModuleDecl *M, SourceLoc Loc, Identifier Name,
1159
1156
template <typename OperatorType>
1160
1157
llvm::Expected<OperatorType *> LookupOperatorRequest<OperatorType>::evaluate(
1161
1158
Evaluator &evaluator, OperatorLookupDescriptor desc) const {
1162
- auto result = lookupOperatorDeclForName (*desc.SF , desc.diagLoc , desc. name ,
1163
- /* includePrivate */ true ,
1164
- OperatorLookup<OperatorType>::map_ptr );
1159
+ auto result = lookupOperatorDeclForName<OperatorType> (*desc.SF , desc.diagLoc ,
1160
+ desc. name ,
1161
+ /* includePrivate */ true );
1165
1162
if (!result.hasValue ())
1166
1163
return nullptr ;
1167
1164
if (auto *tracker = desc.SF ->getReferencedNameTracker ()) {
@@ -1172,9 +1169,9 @@ llvm::Expected<OperatorType *> LookupOperatorRequest<OperatorType>::evaluate(
1172
1169
}
1173
1170
}
1174
1171
if (!result.getValue ()) {
1175
- result = lookupOperatorDeclForName (desc.SF ->getParentModule (), desc. diagLoc ,
1176
- desc.name ,
1177
- OperatorLookup<OperatorType>::map_ptr );
1172
+ result = lookupOperatorDeclForName<OperatorType> (desc.SF ->getParentModule (),
1173
+ desc.diagLoc ,
1174
+ desc. name );
1178
1175
}
1179
1176
return result.hasValue () ? result.getValue () : nullptr ;
1180
1177
}
@@ -1183,7 +1180,7 @@ llvm::Expected<OperatorType *> LookupOperatorRequest<OperatorType>::evaluate(
1183
1180
#define LOOKUP_OPERATOR (Kind ) \
1184
1181
Kind##Decl *ModuleDecl::lookup##Kind(Identifier name, SourceLoc loc) { \
1185
1182
auto result = \
1186
- lookupOperatorDeclForName (this , loc, name, &SourceFile::Kind##s); \
1183
+ lookupOperatorDeclForName<Kind##Decl> (this , loc, name); \
1187
1184
return result ? *result : nullptr ; \
1188
1185
} \
1189
1186
template llvm::Expected<Kind##Decl *> \
0 commit comments