Skip to content

Commit a7d9917

Browse files
committed
CHC: add analysis digests
1 parent 0227fa6 commit a7d9917

24 files changed

+1453
-229
lines changed

CodeHawk/CHC/cchpre/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ MLIS := \
6060
cCHCallsite \
6161
cCHReturnsite \
6262
cCHSPO \
63+
cCHCandidateOutputParameter \
64+
cCHOutputParameterAnalysis \
65+
cCHAnalysisDigest \
6366
cCHProofScaffolding \
6467
cCHPreFileIO \
6568
cCHPrimaryProofObligations \
@@ -96,6 +99,9 @@ SOURCES := \
9699
cCHCallsite \
97100
cCHReturnsite \
98101
cCHSPO \
102+
cCHCandidateOutputParameter \
103+
cCHOutputParameterAnalysis \
104+
cCHAnalysisDigest \
99105
cCHProofScaffolding \
100106
cCHPreFileIO \
101107
cCHPrimaryProofObligations \
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
(* =============================================================================
2+
CodeHawk C Analyzer
3+
Author: Henny Sipma
4+
------------------------------------------------------------------------------
5+
The MIT License (MIT)
6+
7+
Copyright (c) 2025 Aarno Labs LLC
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
============================================================================= *)
27+
28+
(* chutil *)
29+
open CHTraceResult
30+
open CHXmlDocument
31+
32+
(* cchpre *)
33+
open CCHPreTypes
34+
35+
36+
let eloc (line: int): string = __FILE__ ^ ":" ^ (string_of_int line)
37+
let elocm (line: int): string = (eloc line) ^ ": "
38+
39+
40+
let analysis_digest_name (kind: analysis_digest_kind_t): string =
41+
match kind with
42+
| UndefinedBehaviorAnalysis -> "undefined-behavior"
43+
| OutputParameterAnalysis _ -> "output parameters"
44+
45+
46+
class analysis_digest_t
47+
(_fname: string)
48+
(_pod: podictionary_int)
49+
(kind: analysis_digest_kind_t): analysis_digest_int =
50+
object (self)
51+
52+
method is_active (po_s: proof_obligation_int list) =
53+
match kind with
54+
| UndefinedBehaviorAnalysis -> true
55+
| OutputParameterAnalysis digest -> digest#is_active po_s
56+
57+
method kind = kind
58+
59+
method write_xml (node: xml_element_int) =
60+
let _ = node#setAttribute "name" (analysis_digest_name self#kind) in
61+
match self#kind with
62+
| OutputParameterAnalysis digest -> digest#write_xml node
63+
| _ -> ()
64+
65+
method read_xml (node: xml_element_int): unit traceresult =
66+
match self#kind with
67+
| UndefinedBehaviorAnalysis -> Ok ()
68+
| OutputParameterAnalysis digest -> digest#read_xml node
69+
70+
end
71+
72+
73+
let mk_undefined_behavior_analysis_digest
74+
(fname: string) (pod: podictionary_int): analysis_digest_int =
75+
new analysis_digest_t fname pod UndefinedBehaviorAnalysis
76+
77+
78+
let mk_output_parameter_analysis_digest
79+
(fname: string) (pod: podictionary_int): analysis_digest_int =
80+
let opdigest = CCHOutputParameterAnalysis.mk_analysis_digest fname pod in
81+
new analysis_digest_t fname pod (OutputParameterAnalysis opdigest)
82+
83+
84+
let read_xml_analysis_digest
85+
(node: xml_element_int)
86+
(fname: string)
87+
(pod: podictionary_int): analysis_digest_int traceresult =
88+
let name = node#getAttribute "name" in
89+
match name with
90+
| "undefined-behavior" ->
91+
Ok (mk_undefined_behavior_analysis_digest fname pod)
92+
| "output parameters" ->
93+
let digest = mk_output_parameter_analysis_digest fname pod in
94+
let _ = digest#read_xml node in
95+
Ok digest
96+
| _ ->
97+
Error [(elocm __LINE__) ^ "Name of analysis not recognized: " ^ name]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(* =============================================================================
2+
CodeHawk C Analyzer
3+
Author: Henny Sipma
4+
------------------------------------------------------------------------------
5+
The MIT License (MIT)
6+
7+
Copyright (c) 2025 Aarno Labs LLC
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
============================================================================= *)
27+
28+
29+
(* chutil *)
30+
open CHTraceResult
31+
open CHXmlDocument
32+
33+
(* cchpre *)
34+
open CCHPreTypes
35+
36+
37+
val analysis_digest_name: analysis_digest_kind_t -> string
38+
39+
40+
val mk_undefined_behavior_analysis_digest:
41+
string -> podictionary_int -> analysis_digest_int
42+
43+
val mk_output_parameter_analysis_digest:
44+
string -> podictionary_int -> analysis_digest_int
45+
46+
47+
val read_xml_analysis_digest:
48+
xml_element_int
49+
-> string
50+
-> podictionary_int
51+
-> analysis_digest_int traceresult

0 commit comments

Comments
 (0)