Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9afddf0

Browse files
author
Dave Bartolomeo
committed
Insert a load of the temporary object for arguments passed by value
1 parent 6a9ecf7 commit 9afddf0

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,17 @@ private predicate ignoreLoad(Expr expr) {
256256
private predicate needsLoadForParentExpr(Expr expr) {
257257
exists(CrementOperation crement | expr = crement.getOperand().getFullyConverted())
258258
or
259-
exists(AssignOperation ao | expr = ao.getLValue().getFullyConverted())
259+
exists(AssignOperation ao | expr = ao.getLValue().getFullyConverted()) or
260+
// For arguments that are passed by value but require a constructor call, the extractor emits a
261+
// `TemporaryObjectExpr` as the argument, and marks it as a glvalue. This is roughly how a code-
262+
// generating compiler would implement this, passing the address of the temporary so that the
263+
// callee is using the exact same memory location allocated by the caller. We don't fully model
264+
// this yet, though, so we'll synthesize a load so that we appear to be passing the temporary
265+
// object via a bitwise copy.
266+
exists(Call call |
267+
expr = call.getAnArgument().getFullyConverted().(TemporaryObjectExpr) and
268+
expr.isGLValueCategory()
269+
)
260270
}
261271

262272
/**

0 commit comments

Comments
 (0)