Skip to content

Commit 3228411

Browse files
committed
XXPRUTIL: add error handling
1 parent a76df20 commit 3228411

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
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-20250326"
1+
chbversion: str = "0.3.0-20250327"

chb/app/InstrXData.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ def has_branch_conditions(self) -> bool:
483483
def has_condition_setter(self) -> bool:
484484
return len(self.tags) == 4 and self.tags[1] == "TF"
485485

486+
def has_missing_branch_conditions(self) -> bool:
487+
return len(self.tags) > 1 and self.tags[1] == "TF:no-x"
488+
486489
def get_condition_setter(self) -> str:
487490
if len(self.tags) > 2:
488491
return self.tags[2]

chb/invariants/XXprUtil.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,22 @@ def default() -> AST.ASTExpr:
12991299
compkey = cast(AST.ASTTypComp, hl_addr_tgttype).compkey
13001300
compinfo = astree.compinfo(compkey)
13011301

1302+
if not compinfo.has_fields():
1303+
if not anonymous:
1304+
chklogger.logger.error(
1305+
"Struct definition is missing for %s at address %s "
1306+
+ "(no fields found)",
1307+
compinfo.compname, iaddr)
1308+
return astree.mk_temp_lval_expression()
1309+
1310+
if not compinfo.has_field_offsets():
1311+
if not anonymous:
1312+
chklogger.logger.error(
1313+
"Struct definition for %s does not have field offsets "
1314+
+ "at address %s",
1315+
compinfo.compname, iaddr)
1316+
return astree.mk_temp_lval_expression()
1317+
13021318
(field, _) = compinfo.field_at_offset(0)
13031319
fieldoffset = astree.mk_field_offset(field.fieldname, compkey)
13041320
return astree.mk_memref_expr(
@@ -1341,6 +1357,22 @@ def default() -> AST.ASTExpr:
13411357
compkey = cast(AST.ASTTypComp, exp1tgttype).compkey
13421358
compinfo = astree.compinfo(compkey)
13431359

1360+
if not compinfo.has_fields():
1361+
if not anonymous:
1362+
chklogger.logger.error(
1363+
"Struct definition is missing for %s at address %s "
1364+
+ "(no fields found)",
1365+
compinfo.compname, iaddr)
1366+
return astree.mk_temp_lval_expression()
1367+
1368+
if not compinfo.has_field_offsets():
1369+
if not anonymous:
1370+
chklogger.logger.error(
1371+
"Struct definition for %s does not have field offsets "
1372+
+ "at address %s",
1373+
compinfo.compname, iaddr)
1374+
return astree.mk_temp_lval_expression()
1375+
13441376
scalaroffset = cast(AST.ASTIntegerConstant, exp2).cvalue
13451377
(field, rem) = compinfo.field_at_offset(scalaroffset)
13461378
if rem > 0:

0 commit comments

Comments
 (0)