|
40 | 40 | from chc.app.CExp import CExp, CExpLval |
41 | 41 | from chc.app.CLHost import CLHostVar |
42 | 42 | from chc.app.CLval import CLval |
| 43 | + from chc.app.COffset import COffset |
43 | 44 | from chc.app.CTyp import CTyp |
| 45 | + from chc.app.CVarInfo import CVarInfo |
44 | 46 | from chc.proof.CFilePredicateDictionary import CFilePredicateDictionary |
45 | 47 |
|
46 | 48 |
|
|
71 | 73 | 'iu': 'int-underflow', |
72 | 74 | 'iub': 'index-upper-bound', |
73 | 75 | 'lb': 'lower-bound', |
| 76 | + 'li': 'locally-initialized', |
74 | 77 | 'nm': 'new-memory', |
75 | 78 | 'nn': 'not-null', |
76 | 79 | 'nneg': 'non-negative', |
77 | 80 | 'no': 'no-overlap', |
78 | 81 | 'nt': 'null-terminated', |
79 | 82 | 'null': 'null', |
| 83 | + 'opi': 'output_parameter-initialized', |
| 84 | + 'opu': 'output_parameter-unaltered', |
80 | 85 | 'pc': 'pointer-cast', |
81 | 86 | 'plb': 'ptr-lower-bound', |
82 | 87 | 'pre': 'precondition', |
@@ -180,6 +185,10 @@ def is_index_upper_bound(self) -> bool: |
180 | 185 | def is_initialized(self) -> bool: |
181 | 186 | return False |
182 | 187 |
|
| 188 | + @property |
| 189 | + def is_locally_initialized(self) -> bool: |
| 190 | + return False |
| 191 | + |
183 | 192 | @property |
184 | 193 | def is_initialized_range(self) -> bool: |
185 | 194 | return False |
@@ -224,6 +233,14 @@ def is_null(self) -> bool: |
224 | 233 | def is_null_terminated(self) -> bool: |
225 | 234 | return False |
226 | 235 |
|
| 236 | + @property |
| 237 | + def is_output_parameter_initialized(self) -> bool: |
| 238 | + return False |
| 239 | + |
| 240 | + @property |
| 241 | + def is_output_parameter_unaltered(self) -> bool: |
| 242 | + return False |
| 243 | + |
227 | 244 | @property |
228 | 245 | def is_pointer_cast(self) -> bool: |
229 | 246 | return False |
@@ -962,6 +979,48 @@ def __str__(self) -> str: |
962 | 979 | return "initialized(" + str(self.lval) + ")" |
963 | 980 |
|
964 | 981 |
|
| 982 | +@pdregistry.register_tag("li", CPOPredicate) |
| 983 | +class CPOLocallyInitialized(CPOPredicate): |
| 984 | + """locally initialized(lval): location initialized within the function. |
| 985 | +
|
| 986 | + - args[0]: index of lval in cdictionary |
| 987 | + """ |
| 988 | + |
| 989 | + def __init__( |
| 990 | + self, pd: "CFilePredicateDictionary", ixval: IT.IndexedTableValue |
| 991 | + ) -> None: |
| 992 | + CPOPredicate.__init__(self, pd, ixval) |
| 993 | + |
| 994 | + @property |
| 995 | + def varinfo(self) -> "CVarInfo": |
| 996 | + return self.cdeclarations.get_varinfo(self.args[0]) |
| 997 | + |
| 998 | + @property |
| 999 | + def lval(self) -> "CLval": |
| 1000 | + return self.cd.get_lval(self.args[1]) |
| 1001 | + |
| 1002 | + @property |
| 1003 | + def is_locally_initialized(self) -> bool: |
| 1004 | + return True |
| 1005 | + |
| 1006 | + def has_variable(self, vid: int) -> bool: |
| 1007 | + return self.lval.has_variable(vid) |
| 1008 | + |
| 1009 | + def has_variable_deref(self, vid: int) -> bool: |
| 1010 | + return self.lval.has_variable_deref(vid) |
| 1011 | + |
| 1012 | + def has_ref_type(self) -> bool: |
| 1013 | + return self.lval.has_ref_type() |
| 1014 | + |
| 1015 | + def __str__(self) -> str: |
| 1016 | + return ( |
| 1017 | + "locally-initialized(" |
| 1018 | + + str(self.varinfo.vname) |
| 1019 | + + ", " |
| 1020 | + + str(self.lval) |
| 1021 | + + ")") |
| 1022 | + |
| 1023 | + |
965 | 1024 | @pdregistry.register_tag("ir", CPOPredicate) |
966 | 1025 | class CPOInitializedRange(CPOPredicate): |
967 | 1026 | """initialized-range(exp, size): the memory range starting at the address |
@@ -2162,3 +2221,73 @@ def has_variable(self, vid: int) -> bool: |
2162 | 2221 |
|
2163 | 2222 | def __str__(self) -> str: |
2164 | 2223 | return "preserves-value(" + str(self.exp) + ")" |
| 2224 | + |
| 2225 | + |
| 2226 | +@pdregistry.register_tag("opi", CPOPredicate) |
| 2227 | +class CPOOutputParameterInitialized(CPOPredicate): |
| 2228 | + """ |
| 2229 | +
|
| 2230 | + - args[0]: index of varinfo in cdecls |
| 2231 | + """ |
| 2232 | + def __init__( |
| 2233 | + self, pd: "CFilePredicateDictionary", ixval: IT.IndexedTableValue |
| 2234 | + ) -> None: |
| 2235 | + CPOPredicate.__init__(self, pd, ixval) |
| 2236 | + |
| 2237 | + @property |
| 2238 | + def varinfo(self) -> "CVarInfo": |
| 2239 | + return self.cdeclarations.get_varinfo(self.args[0]) |
| 2240 | + |
| 2241 | + @property |
| 2242 | + def offset(self) -> "COffset": |
| 2243 | + return self.cd.get_offset(self.args[1]) |
| 2244 | + |
| 2245 | + @property |
| 2246 | + def is_output_parameter_initialized(self) -> bool: |
| 2247 | + return True |
| 2248 | + |
| 2249 | + def has_variable(self, vid: int) -> bool: |
| 2250 | + return self.varinfo.vid == vid |
| 2251 | + |
| 2252 | + def __str__(self) -> str: |
| 2253 | + return ( |
| 2254 | + "output_parameter-initialized(" |
| 2255 | + + str(self.varinfo.vname) |
| 2256 | + + ", " |
| 2257 | + + str(self.offset) |
| 2258 | + + ")") |
| 2259 | + |
| 2260 | + |
| 2261 | +@pdregistry.register_tag("opu", CPOPredicate) |
| 2262 | +class CPOOutputParameterUnaltered(CPOPredicate): |
| 2263 | + """ |
| 2264 | +
|
| 2265 | + - args[0]: index of varinfo in cdecls |
| 2266 | + """ |
| 2267 | + def __init__( |
| 2268 | + self, pd: "CFilePredicateDictionary", ixval: IT.IndexedTableValue |
| 2269 | + ) -> None: |
| 2270 | + CPOPredicate.__init__(self, pd, ixval) |
| 2271 | + |
| 2272 | + @property |
| 2273 | + def varinfo(self) -> "CVarInfo": |
| 2274 | + return self.cdeclarations.get_varinfo(self.args[0]) |
| 2275 | + |
| 2276 | + @property |
| 2277 | + def offset(self) -> "COffset": |
| 2278 | + return self.cd.get_offset(self.args[1]) |
| 2279 | + |
| 2280 | + @property |
| 2281 | + def is_output_parameter_unaltered(self) -> bool: |
| 2282 | + return True |
| 2283 | + |
| 2284 | + def has_variable(self, vid: int) -> bool: |
| 2285 | + return self.varinfo.vid == vid |
| 2286 | + |
| 2287 | + def __str__(self) -> str: |
| 2288 | + return ( |
| 2289 | + "output_parameter-unaltered(" |
| 2290 | + + str(self.varinfo.vname) |
| 2291 | + + ", " |
| 2292 | + + str(self.offset) |
| 2293 | + + ")") |
0 commit comments