[Function builders] Minor fixes for "load" expr generation

This commit is contained in:
Doug Gregor
2020-01-14 16:56:46 -08:00
parent fccee4f77b
commit f959ace180
2 changed files with 9 additions and 3 deletions

View File

@@ -240,7 +240,7 @@ protected:
if (!childVar)
return;
expressions.push_back(buildVarRef(childVar, braceStmt->getEndLoc()));
expressions.push_back(buildVarRef(childVar, childVar->getLoc()));
};
for (const auto &node : braceStmt->getElements()) {
@@ -713,6 +713,12 @@ private:
temporaryVar, DeclNameLoc(implicitLoc), /*implicit=*/true);
declRef->setType(LValueType::get(temporaryVar->getType()));
// Load the right-hand side if needed.
if (finalCapturedExpr->getType()->is<LValueType>()) {
auto &cs = solution.getConstraintSystem();
finalCapturedExpr = cs.addImplicitLoadExpr(finalCapturedExpr);
}
auto assign = new (ctx) AssignExpr(
declRef, implicitLoc, finalCapturedExpr, /*implicit=*/true);
assign->setType(TupleType::getEmpty(ctx));

View File

@@ -13,7 +13,7 @@ struct Summer {
// CHECK-LABEL: sil_coverage_map {{.*}} "$s24coverage_functon_builder5test0SiyF"
@Summer
func test0() -> Int {
// CHECK: [[@LINE-1]]:21 -> [[@LINE+2]]:5 : 0
// CHECK: [[@LINE-1]]:21 -> [[@LINE+3]]:2 : 0
18
12
}
@@ -21,7 +21,7 @@ func test0() -> Int {
// CHECK-LABEL: sil_coverage_map {{.*}} "$s24coverage_functon_builder5test1SiyF"
@Summer
func test1() -> Int {
// CHECK: [[@LINE-1]]:21 -> [[@LINE+6]]:4 : 0
// CHECK: [[@LINE-1]]:21 -> [[@LINE+7]]:2 : 0
18
12
if 7 < 23 {