Skip to content

Commit

Permalink
Merge branch 'develop' into lib-dynlink
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Nov 25, 2024
2 parents c27c240 + 460d4d3 commit adbc57d
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: build and run tests
on:
- push
- pull_request
- workflow_dispatch

jobs:
tests:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.4
* Add `Return` statement expression location (#167).
* Add `availability` attribute support (#168, #171).
* Remove unused `Libmaincil` module (#165).
* Fix some synthetic locations (#166, #167).

## 2.0.3
* Add `asm inline` parsing (#151).
* Ignore top level qualifiers in `__builtin_types_compatible_p` (#157).
Expand Down
4 changes: 2 additions & 2 deletions META.goblint-cil.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

package "default-features" (
requires="goblint-cil.dataslicing goblint-cil.liveness goblint-cil.pta goblint-cil.makecfg goblint-cil.syntacticsearch"
version = "2.0.3"
version = "2.0.4"
)

package "all-features" (
requires="goblint-cil.dataslicing goblint-cil.liveness goblint-cil.pta goblint-cil.makecfg goblint-cil.zrapp goblint-cil.syntacticsearch"
version = "2.0.3"
version = "2.0.4"
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ instance in the OCaml toplevel using [Findlib][findlib]:
# #require "goblint-cil";;
[...]
# GoblintCil.cilVersion;;
- : string = "2.0.3"
- : string = "2.0.4"

[findlib]: http://projects.camlcity.org/projects/findlib.html

Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name goblint-cil)
(implicit_transitive_deps false)
(generate_opam_files true)
(version 2.0.3)
(version 2.0.4)
(source (github goblint/cil))
; (documentation "https://goblint.github.io/cil")
(authors "George Necula" "Scott McPeak" "Westley Weimer" "Gabriel Kerneis" "Ralf Vogler" "Michael Schwarz" "Simmo Saan")
Expand Down
4 changes: 2 additions & 2 deletions goblint-cil.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "2.0.3"
version: "2.0.4"
synopsis:
"A front-end for the C programming language that facilitates program analysis and transformation"
description: """
Expand Down Expand Up @@ -64,4 +64,4 @@ depexts: [
["perl-FindBin"] {os-distribution = "fedora"}
["build-base"] {os-distribution = "alpine"}
]
available: arch = "x86_64"
available: arch = "x86_64" | arch = "arm64"
2 changes: 1 addition & 1 deletion goblint-cil.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ depexts: [
["perl-FindBin"] {os-distribution = "fedora"}
["build-base"] {os-distribution = "alpine"}
]
available: arch = "x86_64"
available: arch = "x86_64" | arch = "arm64"
2 changes: 1 addition & 1 deletion src/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ and checkEnumInfo (isadef: defuse) enum =
(* Add it to the map before we go on *)
H.add enumUsed enum.ename (enum, ref isadef);
checkAttributes enum.eattr;
List.iter (fun (tn, _, _) -> defineName tn) enum.eitems;
List.iter (fun (tn, attrs, _, _) -> defineName tn; checkAttributes attrs) enum.eitems;
end

and checkTypeInfo (isadef: defuse) ti =
Expand Down
20 changes: 16 additions & 4 deletions src/cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ and attrparam =
| AAddrOf of attrparam (** & a **)
| AIndex of attrparam * attrparam (** a1[a2] *)
| AQuestion of attrparam * attrparam * attrparam (** a1 ? a2 : a3 **)
| AAssign of attrparam * attrparam (** a1 = a2 *)


(** Information about a composite type (a struct or a union). Use
Expand Down Expand Up @@ -398,7 +399,7 @@ and fieldinfo = {
enumeration. Make sure you have a [GEnumTag] for each of of these. *)
and enuminfo = {
mutable ename: string; (** The name. Always non-empty *)
mutable eitems: (string * exp * location) list; (** Items with names
mutable eitems: (string * attributes * exp * location) list; (** Items with names
and values. This list
should be
non-empty. The item
Expand Down Expand Up @@ -1874,6 +1875,7 @@ let additiveLevel = 60
let comparativeLevel = 70
let bitwiseLevel = 75
let questionLevel = 100
let assignLevel = 110
let getParenthLevel (e: exp) =
match e with
| Question _ -> questionLevel
Expand Down Expand Up @@ -1924,6 +1926,7 @@ let getParenthLevelAttrParam (a: attrparam) =
| AAddrOf _ -> 30
| ADot _ | AIndex _ | AStar _ -> 20
| AQuestion _ -> questionLevel
| AAssign _ -> assignLevel


let isIntegralType t =
Expand Down Expand Up @@ -4011,8 +4014,10 @@ class defaultCilPrinterClass : cilPrinter = object (self)
text "enum" ++ align ++ text (" " ^ enum.ename) ++
text " {" ++ line
++ (docList ~sep:(chr ',' ++ line)
(fun (n,i, loc) ->
text (n ^ " = ")
(fun (n, attrs, i, loc) ->
text n
++ self#pAttrs () attrs
++ text (n ^ " = ")
++ self#pExp () i)
() enum.eitems)
++ unalign ++ line ++ text "} "
Expand Down Expand Up @@ -4423,6 +4428,9 @@ class defaultCilPrinterClass : cilPrinter = object (self)
self#pAttrParam () a1 ++ text " ? " ++
self#pAttrParam () a2 ++ text " : " ++
self#pAttrParam () a3
| AAssign (a1, a2) ->
self#pAttrParam () a1 ++ text "=" ++
self#pAttrParam () a2


(* A general way of printing lists of attributes *)
Expand Down Expand Up @@ -5561,6 +5569,10 @@ and childrenAttrparam (vis: cilVisitor) (aa: attrparam) : attrparam =
let e3' = fAttrP e3 in
if e1' != e1 || e2' != e2 || e3' != e3
then AQuestion (e1', e2', e3') else aa
| AAssign (e1, e2) ->
let e1' = fAttrP e1 in
let e2' = fAttrP e2 in
if e1' != e1 || e2' != e2 then AAssign (e1', e2') else aa


let rec visitCilFunction (vis : cilVisitor) (f : fundec) : fundec =
Expand Down Expand Up @@ -5612,7 +5624,7 @@ and childrenGlobal (vis: cilVisitor) (g: global) : global =
| GEnumTag (enum, _) ->
(* (trace "visit" (dprintf "visiting global enum %s\n" enum.ename)); *)
(* Do the values and attributes of the enumerated items *)
let itemVisit (name, exp, loc) = (name, visitCilExpr vis exp, loc) in
let itemVisit (name, attrs, exp, loc) = (name, visitCilAttributes vis attrs, visitCilExpr vis exp, loc) in
enum.eitems <- mapNoCopy itemVisit enum.eitems;
enum.eattr <- visitCilAttributes vis enum.eattr;
g
Expand Down
3 changes: 2 additions & 1 deletion src/cil.mli
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ and attrparam =
| AAddrOf of attrparam (** & a **)
| AIndex of attrparam * attrparam (** a1[a2] *)
| AQuestion of attrparam * attrparam * attrparam (** a1 ? a2 : a3 **)
| AAssign of attrparam * attrparam (** a1 = a2 *)

(** {b Structures.} The {!compinfo} describes the definition of a
structure or union type. Each such {!compinfo} must be defined at the
Expand Down Expand Up @@ -422,7 +423,7 @@ and fieldinfo = {
and enuminfo = {
mutable ename: string;
(** The name. Always non-empty. *)
mutable eitems: (string * exp * location) list;
mutable eitems: (string * attributes * exp * location) list;
(** Items with names and values. This list should be non-empty. The item
values must be compile-time constants. *)
mutable eattr: attributes;
Expand Down
18 changes: 17 additions & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(public_name goblint-cil)
(name goblintCil)
(libraries zarith unix str stdlib-shims)
(modules (:standard \ main mainFeature ciloptions machdepConfigure modelConfigure))
(modules (:standard \ main mainFeature ciloptions machdepConfigure machdepArchConfigure modelConfigure))
)

(executable
Expand All @@ -21,6 +21,21 @@
(target machdep-ml.exe)
(action (run %{read-lines:../bin/real-gcc} -D_GNUCC machdep-ml.c -o %{target})))

(executable
(name machdepArchConfigure)
(modules machdepArchConfigure)
(libraries dune-configurator))

(rule
(deps machdep-config.h machdep-ml.c)
(target machdep32)
(action (with-stdout-to %{target} (run ./machdepArchConfigure.exe --real-gcc %{read-lines:../bin/real-gcc} -m 32))))

(rule
(deps machdep-config.h machdep-ml.c)
(target machdep64)
(action (with-stdout-to %{target} (run ./machdepArchConfigure.exe --real-gcc %{read-lines:../bin/real-gcc} -m 64))))

; for Cilly.pm
(executable
(name modelConfigure)
Expand All @@ -40,6 +55,7 @@
(action (with-stdout-to %{target} (run ./modelConfigure.exe --real-gcc %{read-lines:../bin/real-gcc} -m 64))))

(rule
(deps machdep32 machdep64)
(target machdep.ml)
(action (run %{bin:cppo} -V OCAML:%{ocaml_version}
%{dep:machdep.cppo.ml} -x machdep:./%{dep:machdep-ml.exe}
Expand Down
6 changes: 4 additions & 2 deletions src/ext/zrapp/zrapp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ class zraCilPrinterClass : cilPrinter = object (self)
text "enum" ++ align ++ text (" " ^ enum.ename) ++
self#pAttrs () enum.eattr ++ text " {" ++ line
++ (docList ~sep:(chr ',' ++ line)
(fun (n,i, loc) ->
text (n ^ " = ")
(fun (n, attrs, i, loc) ->
text n
++ self#pAttrs () attrs
++ text (n ^ " = ")
++ self#pExp () i)
() enum.eitems)
++ unalign ++ line ++ text "};\n"
Expand Down
2 changes: 1 addition & 1 deletion src/frontc/cabs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ and init_name = name * init_expression
and single_name = specifier * name


and enum_item = string * expression * cabsloc
and enum_item = string * attribute list * expression * cabsloc

(*
** Declaration definition (at toplevel)
Expand Down
17 changes: 10 additions & 7 deletions src/frontc/cabs2cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2675,7 +2675,7 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
| [A.Tenum (n, Some eil, extraAttrs)] -> (* A definition of an enum *)
let rec justNames eil = match eil with
[] -> []
| (str, expr, loc) :: eis -> str :: justNames eis
| (str, attrs, expr, loc) :: eis -> str :: justNames eis
in
let names = justNames eil in
let n' =
Expand Down Expand Up @@ -2721,7 +2721,7 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
else IULongLong (* assume there can be not enum constants that don't fit in long long since there can only be 128bit constants if long long is also 128bit *)
in
(* as each name,value pair is determined, this is called *)
let rec processName kname (i: exp) loc rest = begin
let rec processName kname attrs (i: exp) loc rest = begin
(* add the name to the environment, but with a faked 'typ' field;
we don't know the full type yet (since that includes all of the
tag values), but we won't need them in here *)
Expand All @@ -2731,16 +2731,16 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
environment when we're finished *)
let newname, _ = newAlphaName true "" kname in

(kname, (newname, i, loc)) :: loop (increm i 1) rest
(kname, (newname, doAttributes attrs, i, loc)) :: loop (increm i 1) rest
end

and loop i = function
[] -> []
| (kname, A.NOTHING, cloc) :: rest ->
| (kname, attrs, A.NOTHING, cloc) :: rest ->
(* use the passed-in 'i' as the value, since none specified *)
processName kname i (convLoc cloc) rest
processName kname attrs i (convLoc cloc) rest

| (kname, e, cloc) :: rest ->
| (kname, attrs, e, cloc) :: rest ->
(* constant-eval 'e' to determine tag value *)
let e' = getIntConstExp e in
let e'' =
Expand All @@ -2750,7 +2750,7 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
if !lowerConstants then kintegerCilint ik n else e'
| _ -> E.s (error "Constant initializer %a not an integer" d_exp e')
in
processName kname e'' (convLoc cloc) rest
processName kname attrs e'' (convLoc cloc) rest
in

let fields = loop zero eil in
Expand Down Expand Up @@ -2927,6 +2927,7 @@ and doAttr (a: A.attribute) : attribute list =
| _ ->
E.s (error "Invalid attribute constant: %s")
end
| A.CONSTANT (A.CONST_FLOAT str) -> ACons (str, [])
| A.CALL(A.VARIABLE n, args) -> begin
let n' = if strip then stripUnderscore n else n in
let ae' = Util.list_map ae args in
Expand All @@ -2940,6 +2941,8 @@ and doAttr (a: A.attribute) : attribute list =
ABinOp(LAnd, ae aa1, ae aa2)
| A.BINARY(A.OR, aa1, aa2) ->
ABinOp(LOr, ae aa1, ae aa2)
| A.BINARY(A.ASSIGN, aa1, aa2) ->
AAssign(ae aa1, ae aa2)
| A.BINARY(abop, aa1, aa2) ->
ABinOp (convBinOp abop, ae aa1, ae aa2)
| A.UNARY(A.PLUS, aa) -> ae aa
Expand Down
5 changes: 3 additions & 2 deletions src/frontc/cabsvisit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ and childrenTypeSpecifier vis ts =
let fg' = mapNoCopy childrenFieldGroup fg in
if fg' != fg then Tunion( n, Some fg', extraAttrs) else ts
| Tenum (n, Some ei, extraAttrs) ->
let doOneEnumItem ((s, e, loc) as ei) =
let doOneEnumItem ((s, attrs, e, loc) as ei) =
let attrs' = visitCabsAttributes vis attrs in
let e' = visitCabsExpression vis e in
if e' != e then (s, e', loc) else ei
if attrs' != attrs || e' != e then (s, attrs', e', loc) else ei
in
vis#vEnterScope ();
let ei' = mapNoCopy doOneEnumItem ei in
Expand Down
12 changes: 9 additions & 3 deletions src/frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,8 @@ enum_list: /* (* ISO 6.7.2.2 *) */
| enum_list COMMA error { $1 }
;
enumerator:
IDENT {(fst $1, NOTHING, snd $1)}
| IDENT EQ expression {(fst $1, fst $3, snd $1)}
IDENT attributes {(fst $1, $2, NOTHING, snd $1)}
| IDENT attributes EQ expression {(fst $1, $2, fst $4, snd $1)}
;


Expand Down Expand Up @@ -1494,6 +1494,8 @@ primary_attr:
| LPAREN attr RPAREN { $2 }
| IDENT IDENT { CALL(VARIABLE (fst $1), [VARIABLE (fst $2)]) }
| CST_INT { CONSTANT(CONST_INT (fst $1)) }
| CST_FLOAT { CONSTANT(CONST_FLOAT (fst $1)) }
| CST_FLOAT CST_FLOAT { CONSTANT(CONST_FLOAT (fst $1 ^ fst $2)) } /* Clang-like hack to parse version numbers like "10.13.4" (https://github.com/goblint/cil/pull/171#issuecomment-2250670652). We lex them as "10.13" and ".4". */
| const_string_or_wstring { CONSTANT(fst $1) }
/*(* Const when it appears in
attribute lists, is translated
Expand Down Expand Up @@ -1619,8 +1621,12 @@ conditional_attr:
| logical_or_attr QUEST conditional_attr COLON conditional_attr
{ QUESTION($1, $3, $5) }

assignment_attr:
conditional_attr { $1 }
| unary_attr EQ assignment_attr { BINARY(ASSIGN, $1, $3) }

attr: conditional_attr { $1 }

attr: assignment_attr { $1 }
;

attr_list_ne:
Expand Down
3 changes: 2 additions & 1 deletion src/frontc/cprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,11 @@ and print_enum_items items =
indent ();
print_commas
true
(fun (id, exp, loc) -> print id;
(fun (id, attrs, exp, loc) -> print id;
if exp = NOTHING then ()
else begin
space ();
print_attributes attrs;
print "= ";
print_expression exp
end)
Expand Down
7 changes: 7 additions & 0 deletions src/machdep.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ let gcc = {
#ext machdep
#endext
}

let gcc32 =
#include "machdep32"

let gcc64 =
#include "machdep64"

let theMachine : mach ref = ref gcc
21 changes: 21 additions & 0 deletions src/machdepArchConfigure.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module C = Configurator.V1

let () =
let real_gcc = ref "" in
let m = ref "" in
let args = Arg.[
("--real-gcc", Set_string real_gcc, "");
("-m", Set_string m, "");
]
in
C.main ~name:"model" ~args (fun c ->
let exe = "./machdep" ^ !m ^ "-ml.exe" in
let {C.Process.exit_code; stdout; stderr} = C.Process.run c !real_gcc ["-D_GNUCC"; "-m" ^ !m; "machdep-ml.c"; "-o"; exe] in
if exit_code = 0 then (
let {C.Process.stdout; stderr; exit_code} = C.Process.run c exe [] in
assert (exit_code = 0);
Printf.printf "Some {%s}" stdout
)
else
Printf.printf "None"
)
Loading

0 comments on commit adbc57d

Please sign in to comment.