Skip to content

Commit 6497717

Browse files
committed
CHC: fix warnings and reformat
1 parent 953aa3e commit 6497717

File tree

7 files changed

+77
-108
lines changed

7 files changed

+77
-108
lines changed

CodeHawk/CHC/cchlib/cCHDeclarations.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ open CHXmlDocument
4141

4242
(* cchcil *)
4343
open CCHBasicTypes
44-
open CCHDictionary
4544
open CCHLibTypes
4645
open CCHSumTypeSerializer
4746
open CCHUtilities

CodeHawk/CHC/cchlib/cCHFunDeclarations.ml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
(* =============================================================================
2-
CodeHawk C Analyzer
2+
CodeHawk C Analyzer
33
Author: Henny Sipma
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
6-
6+
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2023 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
1313
in the Software without restriction, including without limitation the rights
1414
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1515
copies of the Software, and to permit persons to whom the Software is
1616
furnished to do so, subject to the following conditions:
17-
17+
1818
The above copyright notice and this permission notice shall be included in all
1919
copies or substantial portions of the Software.
20-
20+
2121
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2222
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2323
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -37,13 +37,12 @@ open CHXmlDocument
3737
(* cchlib *)
3838
open CCHBasicTypes
3939
open CCHFileEnvironment
40-
open CCHLibTypes
4140
open CCHSumTypeSerializer
4241
open CCHUtilities
4342

4443
module H = Hashtbl
4544

46-
45+
4746
let cd = CCHDictionary.cdictionary
4847
let cdecls = CCHDeclarations.cdeclarations
4948

@@ -136,7 +135,7 @@ object (self)
136135
STR "Formal ";
137136
INT n;
138137
STR " not found in function declarations"]))
139-
138+
140139
method get_locals =
141140
List.filter
142141
(fun vinfo -> vinfo.vparam = 0)
@@ -166,7 +165,7 @@ object (self)
166165
STR "Global variable with name: ";
167166
STR name;
168167
STR " not found"]))
169-
168+
170169
method get_varinfo_by_vid (vid:int) =
171170
if H.mem vidtable vid then
172171
self#xrep (varinfo_table#retrieve (H.find vidtable vid))
@@ -183,7 +182,7 @@ object (self)
183182
begin
184183
H.replace vidtable vinfo.vid index;
185184
index
186-
end
185+
end
187186

188187
method index_varinfo (vinfo:varinfo) =
189188
varinfo_table#add (self#getrep vinfo)
@@ -204,9 +203,8 @@ object (self)
204203
(List.map
205204
(fun (key,index) -> (index,self#xrep key)) varinfo_table#items)
206205
end
207-
206+
208207
end
209208

210209

211210
let mk_cfundeclarations () = new cfundeclarations_t
212-

CodeHawk/CHC/cchlib/cCHLibTypes.mli

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
============================================================================= *)
2929

3030
(* chlib *)
31-
open CHLanguage
3231
open CHNumerical
3332
open CHPretty
3433

@@ -48,45 +47,45 @@ open CCHBasicTypes
4847
*)
4948

5049
type machine_sizes_t = {
51-
sizeof_short : xpr_t ;
52-
sizeof_int : xpr_t ;
53-
54-
sizeof_bool : xpr_t ;
55-
sizeof_long : xpr_t ;
56-
57-
sizeof_longlong : xpr_t ;
58-
sizeof_ptr : xpr_t ;
59-
sizeof_enum : xpr_t ;
60-
sizeof_float : xpr_t ;
61-
sizeof_double : xpr_t ;
62-
63-
sizeof_longdouble : xpr_t ;
64-
sizeof_void : xpr_t ;
65-
sizeof_fun : xpr_t ;
66-
67-
alignof_short : xpr_t ;
68-
alignof_int : xpr_t ;
69-
alignof_bool : xpr_t ;
70-
alignof_long : xpr_t ;
71-
72-
alignof_longlong : xpr_t ;
73-
alignof_ptr : xpr_t ;
74-
alignof_enum : xpr_t ;
75-
alignof_float : xpr_t ;
76-
77-
alignof_double : xpr_t ;
78-
alignof_longdouble: xpr_t ;
79-
alignof_str : xpr_t ;
80-
alignof_fun : xpr_t ;
81-
alignof_aligned : xpr_t ;
50+
sizeof_short : xpr_t;
51+
sizeof_int : xpr_t;
52+
53+
sizeof_bool : xpr_t;
54+
sizeof_long : xpr_t;
55+
56+
sizeof_longlong : xpr_t;
57+
sizeof_ptr : xpr_t;
58+
sizeof_enum : xpr_t;
59+
sizeof_float : xpr_t;
60+
sizeof_double : xpr_t;
61+
62+
sizeof_longdouble : xpr_t;
63+
sizeof_void : xpr_t;
64+
sizeof_fun : xpr_t;
65+
66+
alignof_short : xpr_t;
67+
alignof_int : xpr_t;
68+
alignof_bool : xpr_t;
69+
alignof_long : xpr_t;
70+
71+
alignof_longlong : xpr_t;
72+
alignof_ptr : xpr_t;
73+
alignof_enum : xpr_t;
74+
alignof_float : xpr_t;
75+
76+
alignof_double : xpr_t;
77+
alignof_longdouble: xpr_t;
78+
alignof_str : xpr_t;
79+
alignof_fun : xpr_t;
80+
alignof_aligned : xpr_t;
8281
}
8382

8483
type max_sizes_t = {
85-
sizeof_int : int ;
86-
sizeof_float: int ;
87-
sizeof_void : int ;
88-
sizeof_ptr : int ;
89-
sizeof_fun : int ;
84+
sizeof_int : int;
85+
sizeof_float: int;
86+
sizeof_void : int;
87+
sizeof_ptr : int;
88+
sizeof_fun : int;
9089
sizeof_enum : int
9190
}
9291

@@ -510,18 +509,18 @@ type annotated_xpredicate_t = (xpredicate_t * summary_annotation_t)
510509

511510
(* data structure condition *)
512511
type ds_condition_t = {
513-
dsc_name: string ;
514-
dsc_ckey : int ;
512+
dsc_name: string;
513+
dsc_ckey : int;
515514
dsc_fields : xpredicate_t list
516515
}
517516

518517
type function_summary_t = {
519-
fs_fname : string ;
518+
fs_fname : string;
520519
fs_domainref: (string * string) option; (* specialized reasoning domain *)
521-
fs_params : (string * int) list ;
522-
fs_preconditions: annotated_xpredicate_t list ;
523-
fs_postconditions: annotated_xpredicate_t list ;
524-
fs_error_postconditions: annotated_xpredicate_t list ;
520+
fs_params : (string * int) list;
521+
fs_preconditions: annotated_xpredicate_t list;
522+
fs_postconditions: annotated_xpredicate_t list;
523+
fs_error_postconditions: annotated_xpredicate_t list;
525524
fs_sideeffects: annotated_xpredicate_t list
526525
}
527526

@@ -601,8 +600,8 @@ type contract_instr_t =
601600
SetVar of int * s_term_t * s_term_t (* line, lhs, rhs *)
602601

603602
type contract_note_t = {
604-
cn_tag: string ;
605-
cn_prq: string ;
603+
cn_tag: string;
604+
cn_prq: string;
606605
cn_txt: string
607606
}
608607

@@ -630,13 +629,13 @@ class type function_contract_int =
630629
end
631630

632631
type contract_global_var_t = {
633-
cgv_name: string ;
634-
cgv_value: int option ;
635-
cgv_lb: int option ;
636-
cgv_ub: int option ;
637-
cgv_static: bool ;
638-
cgv_const: bool ;
639-
cgv_notnull: bool ;
632+
cgv_name: string;
633+
cgv_value: int option;
634+
cgv_lb: int option;
635+
cgv_ub: int option;
636+
cgv_static: bool;
637+
cgv_const: bool;
638+
cgv_notnull: bool;
640639
cgv_initialized_fields: string list
641640
}
642641

@@ -671,11 +670,16 @@ class type global_contract_int =
671670

672671

673672
type analysis_level_t =
674-
| UndefinedBehavior (* only indicate undefined behavior (Red) *)
675-
| ImplementationDefinedBehavior (* indicate undefined behavior and implementation
676-
defined behavior (Red,Purple) (default) *)
677-
| ValueWrapAround (* indicate undefined behavior, implementation-defined behavior,
678-
and value wrap around of unsigned integers (Red, Purple, Blue) *)
673+
| UndefinedBehavior
674+
(** only indicate undefined behavior (Red) *)
675+
676+
| ImplementationDefinedBehavior
677+
(** indicate undefined behavior and implementation defined behavior
678+
(Red,Purple) (default) *)
679+
680+
| ValueWrapAround
681+
(** indicate undefined behavior, implementation-defined behavior, and value
682+
wrap around of unsigned integers (Red, Purple, Blue) *)
679683

680684

681685
(** Paths and analysis options*)

CodeHawk/CHC/cchlib/cCHSettings.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
(* chlib *)
3131
open CHPretty
3232

33-
(* chutil *)
34-
open CHTimingLog
35-
3633
(* cchlib *)
3734
open CCHLibTypes
3835
open CCHUtilities

CodeHawk/CHC/cchpre/cCHCreatePrimaryProofObligations.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ open CHPretty
3232

3333
(* chutil *)
3434
open CHLogger
35-
open CHTiming
3635
open CHTimingLog
3736

3837
(* cchlib *)

CodeHawk/CHC/cchpre/cCHPreFileIO.ml

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ open CHPretty
3434
open CHFileIO
3535
open CHLogger
3636
open CHPrettyUtil
37-
open CHTiming
3837
open CHTimingLog
3938
open CHXmlDocument
4039
open CHXmlReader
@@ -745,23 +744,7 @@ let read_target_files () =
745744

746745

747746
let get_cfile_basename ():string = ""
748-
(*
749-
try
750-
Filename.concat
751-
system_settings#get_path
752-
(Filename.chop_extension system_settings#get_cfilename)
753-
with
754-
| _ ->
755-
begin
756-
ch_error_log#add
757-
"chop extension" (LBLOCK [STR system_settings#get_cfilename]);
758-
raise
759-
(CCHFailure
760-
(LBLOCK [
761-
STR "Failed to find file : ";
762-
STR (system_settings#get_cfilename)] ))
763-
end
764-
*)
747+
765748

766749
let get_contractfile_basename ():string =
767750
try
@@ -784,16 +767,7 @@ let get_global_contract_filename ():string =
784767

785768

786769
let get_src_directory ():string = ""
787-
(*
788-
try
789-
let semantics_dir = (Filename.dirname system_settings#get_path) in
790-
(Filename.concat semantics_dir "sourcefiles")
791-
with
792-
| _ ->
793-
begin
794-
raise (CCHFailure (STR "get src directory"))
795-
end
796-
*)
770+
797771

798772
let save_cfile_logfile
799773
(log:logger_int) (contenttype:string) (logtype:string) =
@@ -805,10 +779,7 @@ let save_cfile_logfile
805779

806780

807781
let get_xml_summaryresults_name () = ""
808-
(*
809-
Filename.dirname
810-
(Filename.dirname (system_settings#get_path)) ^ "/summaryresults.xml"
811-
*)
782+
812783

813784
let get_xml_file_contract_name () =
814785
(get_contractfile_basename ()) ^ "_c.xml"

CodeHawk/CHC/cchpre/cCHPreFileIO.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,5 @@ val save_cfile_logfile: logger_int -> string -> string -> unit
182182
val get_xml_summaryresults_name: unit -> string
183183
val read_cfile_contract: unit -> unit
184184
val save_cfile_contract: unit -> unit
185-
(* val get_xml_cfile: string -> file *)
185+
val get_savedsource_path: unit -> string
186+
val get_cfile_basename: unit -> string

0 commit comments

Comments
 (0)