Skip to content

Commit 88f8da1

Browse files
committed
ASTI: address missing reaching defs
1 parent f6f89e4 commit 88f8da1

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

chb/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chbversion: str = "0.3.0-20251011"
1+
chbversion: str = "0.3.0-20251012"

chb/astinterface/ASTICodeTransformer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ def transform_block_stmt(self, stmt: AST.ASTBlock) -> AST.ASTStmt:
7272
for s in stmt.stmts:
7373
newstmt = s.transform(self)
7474
# prune empty blocks that may have been created by the pruning
75-
# of redundant if statements
76-
if newstmt.is_ast_block and len((cast(AST.ASTBlock, newstmt)).stmts) == 0:
75+
# of redundant if statements.
76+
# StmtLabels may be intermixed with statements, hence the check
77+
# for is_stmt_label.
78+
if (
79+
not newstmt.is_stmt_label
80+
and newstmt.is_ast_block
81+
and len((cast(AST.ASTBlock, newstmt)).stmts) == 0):
7782
continue
7883
newstmts.append(newstmt)
7984

chb/astinterface/ASTIProvenance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ def resolve_reaching_defs(self) -> None:
426426
for rd in rds:
427427
rd = cast("ReachingDefFact", rd)
428428
v = str(rd.variable)
429+
if v == "PC":
430+
continue
429431
addrs = [str(d) for d in rd.deflocations]
430432
for addr in addrs:
431433
if addr == "init":

chb/astinterface/ASTInterfaceBasicBlock.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ def trampoline_takedown_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
542542
raise UF.CHBError("Internal error")
543543
return self.trampoline_block_ast("fallthrough", astree)
544544

545+
def trampoline_continue_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
546+
if not self.is_trampoline:
547+
raise UF.CHBError("Internal error")
548+
return self.trampoline_block_ast("continuepath", astree)
549+
545550
def trampoline_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
546551
stmts: List[AST.ASTStmt] = []
547552

@@ -562,4 +567,6 @@ def trampoline_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
562567
str(len(self.trampoline_payload_roles)))
563568
if "fallthrough" in self.trampoline:
564569
stmts.append(self.trampoline_takedown_ast(astree))
570+
if "continuepath" in self.trampoline:
571+
stmts.append(self.trampoline_continue_ast(astree))
565572
return astree.mk_block(stmts)

0 commit comments

Comments
 (0)