@@ -84,6 +84,8 @@ struct LookupResultEntry {
84
84
ValueDecl *getBaseDecl () const ;
85
85
};
86
86
87
+ class LegacyUnqualifiedLookup ; // for verifyEqual below
88
+
87
89
// / This class implements and represents the result of performing
88
90
// / unqualified lookup (i.e. lookup for a plain identifier).
89
91
class UnqualifiedLookup {
@@ -108,9 +110,6 @@ class UnqualifiedLookup {
108
110
// /
109
111
// / If the current DeclContext is nested in a function body, the SourceLoc
110
112
// / is used to determine which declarations in that body are visible.
111
- UnqualifiedLookup (const char *dummy, DeclName Name, DeclContext *DC,
112
- LazyResolver *TypeResolver, SourceLoc Loc = SourceLoc(),
113
- Options options = Options());
114
113
UnqualifiedLookup (DeclName Name, DeclContext *DC, LazyResolver *TypeResolver,
115
114
SourceLoc Loc = SourceLoc(), Options options = Options());
116
115
@@ -121,6 +120,10 @@ class UnqualifiedLookup {
121
120
// / That is, \c makeArrayRef(Results).take_front(IndexOfFirstOuterResults)
122
121
// / will be Results from the innermost scope that had results, and the
123
122
// / remaining elements of Results will be from parent scopes of this one.
123
+ // /
124
+ // / Allows unqualified name lookup to return results from outer scopes.
125
+ // / This is necessary for disambiguating calls to functions like `min` and
126
+ // / `max`.
124
127
size_t IndexOfFirstOuterResult;
125
128
126
129
// / Return true if anything was found by the name lookup.
@@ -129,69 +132,7 @@ class UnqualifiedLookup {
129
132
// / Get the result as a single type, or a null type if that fails.
130
133
TypeDecl *getSingleTypeResult ();
131
134
132
- public: // for exp debugging
133
- SourceFile const *recordedSF = nullptr ;
134
- DeclName recordedName;
135
- bool recordedIsCascadingUse = false ;
136
- };
137
-
138
- inline UnqualifiedLookup::Options operator |(UnqualifiedLookup::Flags flag1,
139
- UnqualifiedLookup::Flags flag2) {
140
- return UnqualifiedLookup::Options (flag1) | flag2;
141
- }
142
-
143
- // / This class implements and represents the result of performing
144
- // / unqualified lookup (i.e. lookup for a plain identifier).
145
- class ExpUnqualifiedLookup {
146
- public:
147
- using Flags = UnqualifiedLookup::Flags;
148
-
149
- using Options = UnqualifiedLookup::Options;
150
-
151
- // / Lookup an unqualified identifier \p Name in the context.
152
- // /
153
- // / If the current DeclContext is nested in a function body, the SourceLoc
154
- // / is used to determine which declarations in that body are visible.
155
- ExpUnqualifiedLookup (DeclName Name, DeclContext *DC,
156
- LazyResolver *TypeResolver, SourceLoc Loc = SourceLoc(),
157
- Options options = Options());
158
-
159
- SmallVector<LookupResultEntry, 4 > Results;
160
- // / The index of the first result that isn't from the innermost scope
161
- // / with results.
162
- // /
163
- // / That is, \c makeArrayRef(Results).take_front(IndexOfFirstOuterResults)
164
- // / will be Results from the innermost scope that had results, and the
165
- // / remaining elements of Results will be from parent scopes of this one.
166
- // /
167
- // / Allows unqualified name lookup to return results from outer scopes.
168
- // / This is necessary for disambiguating calls to functions like `min` and
169
- // / `max`.
170
- size_t IndexOfFirstOuterResult;
171
-
172
- // / Return true if anything was found by the name lookup.
173
- bool isSuccess () const { return !Results.empty (); }
174
-
175
- // / Get the result as a single type, or a null type if that fails.
176
- TypeDecl *getSingleTypeResult ();
177
-
178
- bool operator ==(const UnqualifiedLookup &other) const {
179
- if (Results.size () != other.Results .size ())
180
- return false ;
181
- for (size_t i: indices (Results)) {
182
- const auto &e = Results[i];
183
- const auto &oe = other.Results [i];
184
- if (e.getValueDecl () != oe.getValueDecl ())
185
- return false ;
186
- if (e.getDeclContext () != oe.getDeclContext ())
187
- return false ;
188
- if (e.getBaseDecl () != oe.getBaseDecl ())
189
- return false ;
190
- }
191
- return IndexOfFirstOuterResult == other.IndexOfFirstOuterResult ;
192
- }
193
-
194
- bool verifyEqual (const UnqualifiedLookup &) const ;
135
+ bool verifyEqual (const LegacyUnqualifiedLookup &&) const ;
195
136
196
137
public: // for exp debugging
197
138
SourceFile const *recordedSF = nullptr ;
@@ -235,7 +176,51 @@ inline UnqualifiedLookup::Options operator|(UnqualifiedLookup::Flags flag1,
235
176
};
236
177
std::vector<PerScopeLookupState> breadcrumbs;
237
178
void dumpBreadcrumbs () const ;
238
- };
179
+ };
180
+
181
+ inline UnqualifiedLookup::Options operator |(UnqualifiedLookup::Flags flag1,
182
+ UnqualifiedLookup::Flags flag2) {
183
+ return UnqualifiedLookup::Options (flag1) | flag2;
184
+ }
185
+
186
+ // / This class implements and represents the result of performing
187
+ // / unqualified lookup (i.e. lookup for a plain identifier).
188
+ // / It is being kept around in order to check the refactoring against the new
189
+ // / UnqualifiedLookup above.
190
+ class LegacyUnqualifiedLookup {
191
+ public:
192
+ using Flags = UnqualifiedLookup::Flags;
193
+ using Options = UnqualifiedLookup::Options;
194
+
195
+ // / Lookup an unqualified identifier \p Name in the context.
196
+ // /
197
+ // / If the current DeclContext is nested in a function body, the SourceLoc
198
+ // / is used to determine which declarations in that body are visible.
199
+ LegacyUnqualifiedLookup (DeclName Name, DeclContext *DC,
200
+ LazyResolver *TypeResolver,
201
+ SourceLoc Loc = SourceLoc(),
202
+ Options options = Options());
203
+
204
+ SmallVector<LookupResultEntry, 4 > Results;
205
+ // / The index of the first result that isn't from the innermost scope
206
+ // / with results.
207
+ // /
208
+ // / That is, \c makeArrayRef(Results).take_front(IndexOfFirstOuterResults)
209
+ // / will be Results from the innermost scope that had results, and the
210
+ // / remaining elements of Results will be from parent scopes of this one.
211
+ size_t IndexOfFirstOuterResult;
212
+
213
+ // / Return true if anything was found by the name lookup.
214
+ bool isSuccess () const { return !Results.empty (); }
215
+
216
+ // / Get the result as a single type, or a null type if that fails.
217
+ TypeDecl *getSingleTypeResult ();
218
+
219
+ public: // for exp debugging
220
+ SourceFile const *recordedSF = nullptr ;
221
+ DeclName recordedName;
222
+ bool recordedIsCascadingUse = false ;
223
+ };
239
224
240
225
// / Describes the reason why a certain declaration is visible.
241
226
enum class DeclVisibilityKind {
0 commit comments