update Assignment-2 template#79
Open
yuleisui wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Assignment 2 C++ symbolic execution components by (1) improving constant-object expression creation to resolve constant-ness against the base object, and (2) modifying the Assignment 2 C++ template logic for statement translation.
Changes:
- Update
Z3SSEMgr::createExprForObjVarto perform constant-type checks against the resolved base object (getBaseObject) rather than the originalobjVar. - Remove existing constraint-generation logic for
BinaryOPStmt,SelectStmt, andPhiStmtinSSE::handleNonBranch, replacing it with TODO stubs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Assignment-2/CPP/Z3SSEMgr.cpp | Adjusts constant handling to dyn_cast/isa against the resolved base object to better handle GEPs into constant aggregates. |
| Assignment-2/CPP/Assignment_2.cpp | Replaces previously implemented translations for BinaryOp/Select/Phi with TODO placeholders, removing solver constraints for these statements. |
Comments suppressed due to low confidence (2)
Assignment-2/CPP/Assignment_2.cpp:129
- SelectStmt handling was removed and replaced with a TODO, so SSA select expressions will no longer constrain the result value. This can lead to incorrect path feasibility and incorrect values flowing into subsequent constraints. Restore the select translation or provide an equivalent implementation.
else if (const SelectStmt *select = SVFUtil::dyn_cast<SelectStmt>(stmt)) {
// TODO: implement SelectStmt handler here
}
Assignment-2/CPP/Assignment_2.cpp:132
- PhiStmt handling was removed and replaced with a TODO, so SSA phi nodes will no longer be translated into constraints. This breaks value propagation across CFG joins and can invalidate subsequent constraints built on the phi result. Restore the previous phi translation logic or provide an equivalent implementation.
else if (const PhiStmt *phi = SVFUtil::dyn_cast<PhiStmt>(stmt)) {
// TODO: implement PhiStmt handler here
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
119
to
122
| else if (const BinaryOPStmt *binary = SVFUtil::dyn_cast<BinaryOPStmt>(stmt)) | ||
| { | ||
| expr op0 = getZ3Expr(binary->getOpVarID(0)); | ||
| expr op1 = getZ3Expr(binary->getOpVarID(1)); | ||
| expr res = getZ3Expr(binary->getResID()); | ||
| switch (binary->getOpcode()) | ||
| { | ||
| case BinaryOperator::Add: | ||
| addToSolver(res == op0 + op1); | ||
| break; | ||
| case BinaryOperator::Sub: | ||
| addToSolver(res == op0 - op1); | ||
| break; | ||
| case BinaryOperator::Mul: | ||
| addToSolver(res == op0 * op1); | ||
| break; | ||
| case BinaryOperator::SDiv: | ||
| addToSolver(res == op0 / op1); | ||
| break; | ||
| case BinaryOperator::SRem: | ||
| addToSolver(res == op0 % op1); | ||
| break; | ||
| case BinaryOperator::Xor: | ||
| addToSolver(res == bv2int(int2bv(32, op0) ^ int2bv(32, op1), 1)); | ||
| break; | ||
| case BinaryOperator::And: | ||
| addToSolver(res == bv2int(int2bv(32, op0) & int2bv(32, op1), 1)); | ||
| break; | ||
| case BinaryOperator::Or: | ||
| addToSolver(res == bv2int(int2bv(32, op0) | int2bv(32, op1), 1)); | ||
| break; | ||
| case BinaryOperator::AShr: | ||
| addToSolver(res == bv2int(ashr(int2bv(32, op0), int2bv(32, op1)), 1)); | ||
| break; | ||
| case BinaryOperator::Shl: | ||
| addToSolver(res == bv2int(shl(int2bv(32, op0), int2bv(32, op1)), 1)); | ||
| break; | ||
| default: | ||
| assert(false && "implement this part"); | ||
| } | ||
| // TODO: implement BinaryOPStmt handler here | ||
| } |
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.
No description provided.