@@ -256,22 +256,24 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
256
256
257
257
// Compute the expression that determines whether the range is empty.
258
258
Expr *Empty
259
- = callNullaryMethodOf (new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
260
- RangeTy),
261
- TC.Context .getIdentifier (" empty" ),
262
- S->getInLoc (), diag::foreach_range_empty,
263
- diag::foreach_nonfunc_range_empty);
259
+ = callNullaryMethodOf (
260
+ new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
261
+ Range->getTypeOfReference ()),
262
+ TC.Context .getIdentifier (" empty" ),
263
+ S->getInLoc (), diag::foreach_range_empty,
264
+ diag::foreach_nonfunc_range_empty);
264
265
if (!Empty) return nullptr ;
265
266
if (TC.typeCheckCondition (Empty)) return nullptr ;
266
267
S->setRangeEmpty (Empty);
267
268
268
269
// Compute the expression that extracts a value from the range.
269
270
Expr *GetFirst
270
- = callNullaryMethodOf (new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
271
- RangeTy),
272
- TC.Context .getIdentifier (" getFirst" ),
273
- S->getInLoc (), diag::foreach_range_getfirst,
274
- diag::foreach_nonfunc_range_getfirst);
271
+ = callNullaryMethodOf (
272
+ new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
273
+ Range->getTypeOfReference ()),
274
+ TC.Context .getIdentifier (" getFirst" ),
275
+ S->getInLoc (), diag::foreach_range_getfirst,
276
+ diag::foreach_nonfunc_range_getfirst);
275
277
if (!GetFirst) return nullptr ;
276
278
277
279
// Make sure our element type is materializable.
@@ -293,11 +295,12 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
293
295
294
296
// Compute the expression that drops the first value from the range.
295
297
Expr *DropFirst
296
- = callNullaryMethodOf (new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
297
- RangeTy),
298
- TC.Context .getIdentifier (" dropFirst" ),
299
- S->getInLoc (), diag::foreach_range_dropfirst,
300
- diag::foreach_nonfunc_range_dropfirst);
298
+ = callNullaryMethodOf (
299
+ new (TC.Context ) DeclRefExpr (Range, S->getInLoc (),
300
+ Range->getTypeOfReference ()),
301
+ TC.Context .getIdentifier (" dropFirst" ),
302
+ S->getInLoc (), diag::foreach_range_dropfirst,
303
+ diag::foreach_nonfunc_range_dropfirst);
301
304
if (!DropFirst) return nullptr ;
302
305
S->setRangeDropFirst (DropFirst);
303
306
0 commit comments