Skip to content

Commit 76556e4

Browse files
authored
Merge pull request #68 from abakst/abakst/errno
Support CodeHawk `errno` analysis
2 parents 3ef0cb4 + 9a7cf3a commit 76556e4

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

chc/api/XPredicate.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,3 +1231,17 @@ def is_valid_mem(self) -> bool:
12311231

12321232
def __str__(self) -> str:
12331233
return "valid-mem(" + str(self.term) + ")"
1234+
1235+
1236+
@ifdregistry.register_tag("ew", XPredicate)
1237+
class XWritesErrno(XPredicate):
1238+
"""errno must have been written locally.
1239+
"""
1240+
1241+
def __init__(
1242+
self, ifd: "InterfaceDictionary", ixval: IT.IndexedTableValue
1243+
) -> None:
1244+
XPredicate.__init__(self, ifd, ixval)
1245+
1246+
def __str__(self) -> str:
1247+
return "errno-must-written()"

chc/cmdline/chkc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def parse() -> argparse.Namespace:
759759
cfileanalyze.add_argument(
760760
"--analysis",
761761
default="undefined-behavior",
762-
choices=["undefined-behavior", "outputparameters"],
762+
choices=["undefined-behavior", "outputparameters", "errno"],
763763
help="choose analysis for creating primary proof obligations")
764764
cfileanalyze.add_argument(
765765
"--collect-diagnostics",
@@ -809,7 +809,7 @@ def parse() -> argparse.Namespace:
809809
cfilereport.add_argument(
810810
"--analysis",
811811
default="undefined-behavior",
812-
choices=["undefined-behavior", "outputparameters"],
812+
choices=["undefined-behavior", "outputparameters", "errno"],
813813
help="choose analysis for reporting results")
814814
cfilereport.add_argument(
815815
"--open",
@@ -857,7 +857,7 @@ def parse() -> argparse.Namespace:
857857
cfilerun.add_argument(
858858
"--analysis",
859859
default="undefined-behavior",
860-
choices=["undefined-behavior", "outputparameters"],
860+
choices=["undefined-behavior", "outputparameters", "errno"],
861861
help="choose analysis for creating primary proof obligations")
862862
cfilerun.add_argument(
863863
"--collect-diagnostics",
@@ -1588,7 +1588,7 @@ def parse() -> argparse.Namespace:
15881588
cprojectanalyze.add_argument(
15891589
"--analysis",
15901590
default="undefined-behavior",
1591-
choices=["undefined-behavior", "outputparameters"],
1591+
choices=["undefined-behavior", "outputparameters", "errno"],
15921592
help="choose analysis for creating primary proof obligations")
15931593
cprojectanalyze.add_argument(
15941594
"--collect-diagnostics",
@@ -1635,7 +1635,7 @@ def parse() -> argparse.Namespace:
16351635
cprojectreport.add_argument(
16361636
"--analysis",
16371637
default="undefined-behavior",
1638-
choices=["undefined-behavior", "outputparameters"],
1638+
choices=["undefined-behavior", "outputparameters", "errno"],
16391639
help="choose analysis for reporting results")
16401640
cprojectreport.add_argument(
16411641
"--verbose", "-v",
@@ -1667,7 +1667,7 @@ def parse() -> argparse.Namespace:
16671667
cprojectreportfile.add_argument(
16681668
"--analysis",
16691669
default="undefined-behavior",
1670-
choices=["undefined-behavior", "outputparameters"],
1670+
choices=["undefined-behavior", "outputparameters", "errno"],
16711671
help="choose analysis for reporting results")
16721672
cprojectreportfile.add_argument(
16731673
"--showcode",

chc/proof/CPOPredicate.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
'cus': 'unsigned-to-signed-cast',
6262
'cuu': 'unsigned-to-unsigned-cast',
6363
'dr': 'distinct-region',
64+
'ew': 'errno-must-written',
6465
'fc': 'format-cast',
6566
'ft': 'format-string',
6667
'ga': 'global-address',
@@ -2231,6 +2232,24 @@ def __str__(self) -> str:
22312232
return "preserves-all-memory()"
22322233

22332234

2235+
@pdregistry.register_tag("ew", CPOPredicate)
2236+
class CPOErrnoMustBeWritten(CPOPredicate):
2237+
"""errno-must-written(): true if errno must have been written locally.
2238+
"""
2239+
2240+
def __init__(
2241+
self, pd: "CFilePredicateDictionary", ixval: IT.IndexedTableValue
2242+
) -> None:
2243+
CPOPredicate.__init__(self, pd, ixval)
2244+
2245+
@property
2246+
def is_errno_must_written(self) -> bool:
2247+
return True
2248+
2249+
def __str__(self) -> str:
2250+
return "errno-must-written()"
2251+
2252+
22342253
@pdregistry.register_tag("pv", CPOPredicate)
22352254
class CPOPreservedValue(CPOPredicate):
22362255
"""preserves-value(exp): true of a function that preserves the value of exp.

chc/summaries/cchsummaries.jar

-1.35 KB
Binary file not shown.

0 commit comments

Comments
 (0)