Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Interacting changes to conversion ranking, temporary initialization, destructor reuse, and node selection alter expression-to-node identity across C++ dataflow analyses beyond the limited-consequence review scope.
No open issues 🎉
What changed in this PR
Fixes C++ dataflow expression mapping for temporary objects, avoiding duplicate asExpr mappings caused by implicit destructor calls.
Changes:
- Refines conversion flow to handle temporary initialization and reused values.
- Adds regression cases for temporaries with and without destructors.
| File | Description |
|---|---|
| cpp/ql/test/library-tests/dataflow/asExpr/test.cpp | Adds temporary-object expression mapping tests. |
| cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll | Links initialization stores to temporary-object expressions. |
| cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/ExprNodes.qll | Refines conversion steps used for expression mapping. |
Review effort: Balanced (adaptive)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a temporary of a class with a destructor (such as
return_obj_by_value().f()), the extractor generates aTemporaryObjectExprfor the qualifier off()and aReuseExprto reuse it in the implicit destructor call:We want the "most converted instruction" to be the instruction for which
asExprhas a result. To do this,getConvertedResultExpressionhas a columnnto indicate the index in a chain of conversions. Becauser15is aCopyValue,getConvertedResultExpressiontreats it as a conversion ofr1. Sor15getsReuseExpratn = 0andreturn_obj_by_value()atn = 1, whiler1keepsreturn_obj_by_value()atn = 0. As a resultasExprmapsreturn_obj_by_value()to 2 nodes: the qualifiers off()and~Obj().This PR introduces
exprConversionFlow, which excludesReuseExprwhen the reused value is accessed elsewhere and treats the store initializing aTemporaryObjectExpr(m6->r1) as a conversion step.Commit-by-commit review recommended.