Skip to content

Commit 0067d37

Browse files
committed
Remove C11 generic from CIL
1 parent d9a7510 commit 0067d37

File tree

5 files changed

+5
-54
lines changed

5 files changed

+5
-54
lines changed

src/check.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ let rec checkType (t: typ) (ctx: ctxType) =
278278
(fun (an, at, aa) ->
279279
checkType at CTFArg;
280280
checkAttributes aa) (argsToList targs)
281-
| TDefault -> ()
282281

283282
(* Check that a type is a promoted integral type *)
284283
and checkIntegralType (t: typ) =
@@ -619,12 +618,7 @@ and checkExp (isconst: bool) (e: exp) : typ =
619618
(* | TComp _ -> E.s (bug "Cast of a composite type") *)
620619
| TVoid _ -> E.s (bug "Cast of a void type")
621620
| _ -> tres
622-
end
623-
| Generic (exp, lst) ->
624-
let typ = checkExp false exp in
625-
List.iter (fun (t, e) -> checkType t CTExp; ignore (checkExp false e)) lst;
626-
typ
627-
)
621+
end)
628622
() (* The argument of withContext *)
629623

630624
and checkInit (i: init) : typ =

src/cil.ml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ and typ =
277277

278278
| TBuiltin_va_list of attributes
279279
(** This is the same as the gcc's type with the same name *)
280-
| TDefault
281280

282281
(** Various kinds of integers *)
283282
and ikind =
@@ -538,7 +537,6 @@ and exp =
538537
* It is not printed. Given an lval of type
539538
* [TArray(T)] produces an expression of type
540539
* [TPtr(T)]. *)
541-
| Generic of exp * ((typ * exp) list)
542540

543541

544542
(** Literal constants *)
@@ -1528,7 +1526,6 @@ let rec typeAttrs = function
15281526
| TEnum (enum, a) -> addAttributes enum.eattr a
15291527
| TFun (_, _, _, a) -> a
15301528
| TBuiltin_va_list a -> a
1531-
| TDefault -> []
15321529

15331530

15341531
let setTypeAttrs t a =
@@ -1543,7 +1540,6 @@ let setTypeAttrs t a =
15431540
| TEnum (enum, _) -> TEnum (enum, a)
15441541
| TFun (r, args, v, _) -> TFun(r,args,v,a)
15451542
| TBuiltin_va_list _ -> TBuiltin_va_list a
1546-
| TDefault -> TDefault
15471543

15481544

15491545
let typeAddAttributes a0 t =
@@ -1566,7 +1562,6 @@ begin
15661562
| TComp (comp, a) -> TComp (comp, add a)
15671563
| TNamed (t, a) -> TNamed (t, add a)
15681564
| TBuiltin_va_list a -> TBuiltin_va_list (add a)
1569-
| TDefault -> TDefault
15701565
end
15711566

15721567
let typeRemoveAttributes (anl: string list) t =
@@ -1582,7 +1577,6 @@ let typeRemoveAttributes (anl: string list) t =
15821577
| TComp (comp, a) -> TComp (comp, drop a)
15831578
| TNamed (t, a) -> TNamed (t, drop a)
15841579
| TBuiltin_va_list a -> TBuiltin_va_list (drop a)
1585-
| TDefault -> TDefault
15861580

15871581
let unrollType (t: typ) : typ =
15881582
let rec withAttrs (al: attributes) (t: typ) : typ =
@@ -1863,7 +1857,6 @@ let getParenthLevel (e: exp) =
18631857

18641858
| Lval(Var _, NoOffset) -> 0 (* Plain variables *)
18651859
| Const _ -> 0 (* Constants *)
1866-
| Generic _ -> 0 (*TODO*)
18671860

18681861

18691862
let getParenthLevelAttrParam (a: attrparam) =
@@ -1960,14 +1953,6 @@ let rec typeOf (e: exp) : typ =
19601953
TArray (t,_, a) -> TPtr(t, a)
19611954
| _ -> E.s (E.bug "typeOf: StartOf on a non-array")
19621955
end
1963-
| Generic (exp, lst) ->
1964-
let typeOfExp = typeOf exp in
1965-
let rec findType lst =
1966-
match lst with
1967-
[] -> voidType
1968-
| (t, e) :: rest -> if t = typeOfExp then typeOf e else findType rest
1969-
in
1970-
findType lst
19711956

19721957
and typeOfInit (i: init) : typ =
19731958
match i with
@@ -2257,7 +2242,6 @@ let rec alignOf_int t =
22572242

22582243
| TFun _ as t -> raise (SizeOfError ("function", t))
22592244
| TVoid _ as t -> raise (SizeOfError ("void", t))
2260-
| TDefault -> raise (SizeOfError ("default", t))
22612245
in
22622246
match filterAttributes "aligned" (typeAttrs t) with
22632247
[] ->
@@ -2570,7 +2554,6 @@ and bitsSizeOf t =
25702554
0
25712555

25722556
| TFun _ -> raise (SizeOfError ("function", t))
2573-
| TDefault -> raise (SizeOfError("default", t))
25742557

25752558

25762559
and addTrailing nrbits roundto =
@@ -2838,8 +2821,6 @@ let rec isConstant = function
28382821
| AddrOf (Mem e, off) | StartOf(Mem e, off)
28392822
-> isConstant e && isConstantOffset off
28402823
| AddrOfLabel _ -> true
2841-
| Generic _ -> false (*TODO*)
2842-
28432824
and isConstantOffset = function
28442825
NoOffset -> true
28452826
| Field(fi, off) -> isConstantOffset off
@@ -3543,14 +3524,6 @@ class defaultCilPrinterClass : cilPrinter = object (self)
35433524

35443525
| StartOf(lv) -> self#pLval () lv
35453526

3546-
| Generic(e, lst) ->
3547-
let rec print_generic_exp l doc =
3548-
match l with
3549-
| [] -> doc
3550-
| (t, e1) :: rest -> print_generic_exp rest (doc ++ text ", " ++ (self#pType None () t) ++ text ":" ++ self#pExp () e1)
3551-
in
3552-
text "_Generic(" ++ self#pExp () e ++ print_generic_exp lst nil ++ text ")"
3553-
35543527
(* Print an expression, given the precedence of the context in which it
35553528
* appears. *)
35563529
method private pExpPrec (contextprec: int) () (e: exp) =
@@ -4487,7 +4460,6 @@ class defaultCilPrinterClass : cilPrinter = object (self)
44874460
++ self#pAttrs () a
44884461
++ text " "
44894462
++ name
4490-
| TDefault -> text "default"
44914463

44924464

44934465
(**** PRINTING ATTRIBUTES *********)
@@ -4823,7 +4795,6 @@ class plainCilPrinterClass =
48234795
end
48244796
| TBuiltin_va_list a ->
48254797
dprintf "TBuiltin_va_list(%a)" self#pAttrs a
4826-
| TDefault -> dprintf "TDefault"
48274798

48284799

48294800
(* Some plain pretty-printers. Unlike the above these expose all the
@@ -4902,13 +4873,6 @@ class plainCilPrinterClass =
49024873
| StartOf lv -> dprintf "StartOf(%a)" self#pLval lv
49034874
| AddrOf (lv) -> dprintf "AddrOf(%a)" self#pLval lv
49044875
| AddrOfLabel (sref) -> dprintf "AddrOfLabel(%a)" self#pStmt !sref
4905-
| Generic(e, lst) ->
4906-
let rec print_generic_exp l doc =
4907-
match l with
4908-
| [] -> doc
4909-
| (t, e1) :: rest -> print_generic_exp rest (doc ++ text "," ++ (self#pType None () t) ++ text ":" ++ self#pExp () e1)
4910-
in
4911-
text "_Generic(" ++ self#pExp () e ++ text "," ++ print_generic_exp lst nil
49124876

49134877

49144878

@@ -5422,8 +5386,6 @@ and childrenExp (vis: cilVisitor) (e: exp) : exp =
54225386
| StartOf lv ->
54235387
let lv' = vLval lv in
54245388
if lv' != lv then StartOf lv' else e
5425-
| Generic(e, lst) -> e (*TODO*)
5426-
54275389

54285390
and visitCilInit (vis: cilVisitor) (forglob: varinfo)
54295391
(atoff: offset) (i: init) : init =
@@ -6208,7 +6170,6 @@ let rec typeSigWithAttrs ?(ignoreSign=false) doattr t =
62086170
TSFun(typeSig rt, (Util.list_map_opt (fun (_, atype, _) -> (typeSig atype)) args), isva, doattr a)
62096171
| TNamed(t, a) -> typeSigAddAttrs (doattr a) (typeSig t.ttype)
62106172
| TBuiltin_va_list al -> TSBase (TBuiltin_va_list (doattr al))
6211-
| TDefault -> TSBase (TDefault)
62126173

62136174
let typeSig t =
62146175
typeSigWithAttrs (fun al -> al) t

src/cil.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ and typ =
242242

243243
| TBuiltin_va_list of attributes
244244
(** This is the same as the gcc's type with the same name *)
245-
| TDefault
246245

247246
(**
248247
There are a number of functions for querying the kind of a type. These are
@@ -632,7 +631,6 @@ and exp =
632631
* not sure which one to use. In C this operation is implicit, the
633632
* [StartOf] operator is not printed. We have it in CIL because it makes
634633
* the typing rules simpler. *)
635-
| Generic of exp * ((typ * exp) list)
636634

637635
(** {b Constants.} *)
638636

src/ext/pta/ptranal.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ and analyze_expr (e : exp ) : A.tau =
257257
| SizeOfE _ -> A.bottom ()
258258
| Imag __ -> A.bottom ()
259259
| Real __ -> A.bottom ()
260-
| Generic (_, _) -> failwith "not implemented yet"
261260
in
262261
H.add expressions e result;
263262
result

src/frontc/cabs2cil.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ let rec stripConstLocalType (t: typ) : typ =
669669
let a' = dc a in if a != a' then TVoid a' else t
670670
| TBuiltin_va_list a ->
671671
let a' = dc a in if a != a' then TBuiltin_va_list a' else t
672-
| TDefault -> t
673672

674673

675674
let constFoldTypeVisitor = object (self)
@@ -1573,7 +1572,6 @@ let cabsTypeAddAttributes a0 t =
15731572
| TComp (comp, a) -> TComp (comp, addA0To a)
15741573
| TNamed (t, a) -> TNamed (t, addA0To a)
15751574
| TBuiltin_va_list a -> TBuiltin_va_list (addA0To a)
1576-
| TDefault -> TDefault
15771575
end
15781576

15791577

@@ -2463,7 +2461,7 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
24632461
| [A.Tfloat128] -> TFloat(FLongDouble, []) (* TODO: Correct? *)
24642462

24652463
(* Now the other type specifiers *)
2466-
| [A.Tdefault] -> TDefault
2464+
(* | [A.Tdefault] -> TDefault *)
24672465
| [A.Tnamed n] -> begin
24682466
if n = "__builtin_va_list" &&
24692467
!Machdep.theMachine.Machdep.__builtin_va_list then begin
@@ -4864,7 +4862,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48644862
let default_typ = ref voidType in
48654863
let typ =
48664864
let rec get_typ lst = match lst with
4867-
| (TDefault, e) :: rest -> default_typ := typeOf e; get_typ rest
4865+
(* | (TDefault, e) :: rest -> default_typ := typeOf e; get_typ rest *)
48684866
| (t, e) :: rest -> if t = exp_typ then typeOf e else get_typ rest
48694867
| [] ->
48704868
if !default_typ = voidType then
@@ -4873,7 +4871,8 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48734871
in
48744872
get_typ cil_list
48754873
in
4876-
finishExp empty (Generic(exp, (cil_list))) typ
4874+
(* finishExp empty (Generic(exp, (cil_list))) typ *)
4875+
failwith "TODO"
48774876

48784877
with e when continueOnError -> begin
48794878
(*ignore (E.log "error in doExp (%s)" (Printexc.to_string e));*)

0 commit comments

Comments
 (0)