Insert a load of the temporary object for arguments passed by value

This commit is contained in:
Dave Bartolomeo
2020-10-16 12:56:46 -04:00
parent 6a9ecf7ba2
commit 9afddf0dad

View File

@@ -256,7 +256,17 @@ private predicate ignoreLoad(Expr expr) {
private predicate needsLoadForParentExpr(Expr expr) {
exists(CrementOperation crement | expr = crement.getOperand().getFullyConverted())
or
exists(AssignOperation ao | expr = ao.getLValue().getFullyConverted())
exists(AssignOperation ao | expr = ao.getLValue().getFullyConverted()) or
// For arguments that are passed by value but require a constructor call, the extractor emits a
// `TemporaryObjectExpr` as the argument, and marks it as a glvalue. This is roughly how a code-
// generating compiler would implement this, passing the address of the temporary so that the
// callee is using the exact same memory location allocated by the caller. We don't fully model
// this yet, though, so we'll synthesize a load so that we appear to be passing the temporary
// object via a bitwise copy.
exists(Call call |
expr = call.getAnArgument().getFullyConverted().(TemporaryObjectExpr) and
expr.isGLValueCategory()
)
}
/**