|
55 | 55 | VMemoryVariable, VAuxiliaryVariable, VRegisterVariable) |
56 | 56 | from chb.invariants.VConstantValueVariable import ( |
57 | 57 | VInitialRegisterValue, VInitialMemoryValue, VFunctionReturnValue, |
58 | | - SymbolicValue, MemoryAddress) |
| 58 | + VTypeCastValue, SymbolicValue, MemoryAddress) |
59 | 59 | from chb.invariants.VMemoryBase import ( |
60 | 60 | VMemoryBase, |
61 | 61 | VMemoryBaseBaseVar, |
@@ -889,6 +889,14 @@ def xvariable_to_ast_def_lval_expression( |
889 | 889 | vinfo = astree.globalsymboltable.get_symbol(name) |
890 | 890 | return astree.mk_vinfo_lval_expression(vinfo, anonymous=anonymous) |
891 | 891 |
|
| 892 | + if xvar.is_typecast_value: |
| 893 | + tcvar = cast("VTypeCastValue", xvar.denotation) |
| 894 | + chklogger.logger.error( |
| 895 | + "AST def conversion of typecast value %s to lval at address %s " |
| 896 | + + "not yet supported", |
| 897 | + str(tcvar), iaddr) |
| 898 | + return astree.mk_temp_lval_expression() |
| 899 | + |
892 | 900 | chklogger.logger.error( |
893 | 901 | "AST def conversion of variable %s to lval-expression at address " |
894 | 902 | + "%s not yet supported", |
@@ -1553,12 +1561,17 @@ def global_variable_to_ast_lval( |
1553 | 1561 | if fieldoffset.offset.is_no_offset: |
1554 | 1562 | subfieldastoffset: AST.ASTOffset = nooffset |
1555 | 1563 | elif fieldoffset.offset.is_field_offset: |
1556 | | - subfieldoffset = cast( |
| 1564 | + subfieldfldoffset = cast( |
1557 | 1565 | "VMemoryOffsetFieldOffset", fieldoffset.offset) |
1558 | | - subfieldname = subfieldoffset.fieldname |
1559 | | - subfieldkey = subfieldoffset.ckey |
| 1566 | + subfieldname = subfieldfldoffset.fieldname |
| 1567 | + subfieldkey = subfieldfldoffset.ckey |
1560 | 1568 | subfieldastoffset = astree.mk_field_offset( |
1561 | 1569 | subfieldname, subfieldkey) |
| 1570 | + elif fieldoffset.offset.is_array_index_offset: |
| 1571 | + subfieldarrayoffset = cast( |
| 1572 | + "VMemoryOffsetArrayIndexOffset", fieldoffset.offset) |
| 1573 | + subfieldastoffset = array_offset_to_ast_offset( |
| 1574 | + subfieldarrayoffset, xdata, iaddr, astree, anonymous=anonymous) |
1562 | 1575 | else: |
1563 | 1576 | chklogger.logger.error( |
1564 | 1577 | "Index sub offset of global offset %s not yet handled at %s", |
@@ -1741,10 +1754,26 @@ def vargument_deref_value_to_ast_lval( |
1741 | 1754 | astree: ASTInterface, |
1742 | 1755 | anonymous: bool = False) -> AST.ASTLval: |
1743 | 1756 |
|
| 1757 | + if offset.is_no_offset: |
| 1758 | + asmvar = cast("VAuxiliaryVariable", basevar.denotation) |
| 1759 | + vinitvar = cast("VInitialRegisterValue", asmvar.auxvar) |
| 1760 | + xinitarg = vinitregister_value_to_ast_lval_expression( |
| 1761 | + vinitvar, xdata, iaddr, astree, anonymous=anonymous) |
| 1762 | + argtype = xinitarg.ctype(astree.ctyper) |
| 1763 | + if argtype is None: |
| 1764 | + chklogger.logger.error( |
| 1765 | + "Untyped dereferenced argument value %s not yet supported at " |
| 1766 | + + "address %s", |
| 1767 | + str(xinitarg), iaddr) |
| 1768 | + return astree.mk_temp_lval() |
| 1769 | + else: |
| 1770 | + return astree.mk_memref_lval(xinitarg, anonymous=anonymous) |
| 1771 | + |
1744 | 1772 | if not offset.is_constant_value_offset: |
1745 | 1773 | chklogger.logger.error( |
1746 | | - "Non-constant offset: %s not yet supported at address %s", |
1747 | | - str(offset), iaddr) |
| 1774 | + "Non-constant offset: %s with variable %s not yet supported at " |
| 1775 | + + "address %s", |
| 1776 | + str(offset), str(basevar), iaddr) |
1748 | 1777 | return astree.mk_temp_lval() |
1749 | 1778 |
|
1750 | 1779 | coff = offset.offsetvalue() |
@@ -1844,6 +1873,39 @@ def vargument_deref_value_to_ast_lval( |
1844 | 1873 | str(basevar), str(offset), iaddr) |
1845 | 1874 | return astree.mk_temp_lval() |
1846 | 1875 |
|
| 1876 | + if basevar.is_typecast_value: |
| 1877 | + asmvar = cast("VAuxiliaryVariable", basevar.denotation) |
| 1878 | + vtcv = cast("VTypeCastValue", asmvar.auxvar) |
| 1879 | + bctype = vtcv.tgttype |
| 1880 | + vtype = bctype.convert(astree.typconverter) |
| 1881 | + if vtype is not None and vtype.is_pointer: |
| 1882 | + tgttype = cast(AST.ASTTypPtr, vtype).tgttyp |
| 1883 | + castaddr = vtcv.iaddr |
| 1884 | + if len(astree.ssa_intros[castaddr]) == 1: |
| 1885 | + vinfo = list(astree.ssa_intros[castaddr].values())[0] |
| 1886 | + vexpr = astree.mk_vinfo_lval_expression( |
| 1887 | + vinfo, anonymous=anonymous) |
| 1888 | + if tgttype.is_compound: |
| 1889 | + |
| 1890 | + return field_pointer_to_ast_memref_lval( |
| 1891 | + vexpr, |
| 1892 | + tgttype, |
| 1893 | + coff, |
| 1894 | + iaddr, |
| 1895 | + astree, |
| 1896 | + anonymous=anonymous) |
| 1897 | + |
| 1898 | + chklogger.logger.error( |
| 1899 | + "AST conversion of typecast value %s with type %s not yet handled " |
| 1900 | + + " at address %s", |
| 1901 | + str(basevar), str(tgttype), iaddr) |
| 1902 | + return astree.mk_temp_lval() |
| 1903 | + |
| 1904 | + chklogger.logger.error( |
| 1905 | + "AST conversion of typecast value %s with type %s not yet handled at %s", |
| 1906 | + str(basevar), str(vtype), iaddr) |
| 1907 | + return astree.mk_temp_lval() |
| 1908 | + |
1847 | 1909 | chklogger.logger.error( |
1848 | 1910 | "AST conversion of argument deref lvalue: %s with offset %s not yet " |
1849 | 1911 | + "handled at %s (variable denotation type: %s)", |
|
0 commit comments