Skip to content
Snippets Groups Projects
Commit 7836d10a authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[compliance] add comments and references to hard-coded type list of GCC builtins

parent 90ca5329
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"source":"Mostly https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html, from pages with 'Builtins' in their title", "source":"Mostly https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html, from pages with 'Builtins' in their title",
"notes": { "notes": {
"rettype":"Return type of the builtin. Whitespace is important: types are matched as exact strings, with a single space between components.", "rettype":"Return type of the builtin. Whitespace is important: types are matched as exact strings, with a single space between components.",
"args":"List of the types of the builtin arguments. Whitespace is important: types are matched as exact strings, with a single space between components.", "args":"List of the types of the builtin arguments. Whitespace is important: types are matched as exact strings, with a single space between components. The full list of 'known' type names is available in cil_builtins.ml.",
"types":"When present, a list indicating that this is a builtin template, to be instantiated for each type in the list. Instantiation is the replacement of each occurrence of 'type' in 'rettype' and 'args' with the elements of this list.", "types":"When present, a list indicating that this is a builtin template, to be instantiated for each type in the list. Instantiation is the replacement of each occurrence of 'type' in 'rettype' and 'args' with the elements of this list.",
"variadic":"When present, this builtin behaves as a variadic function." "variadic":"When present, this builtin behaves as a variadic function."
}, },
......
...@@ -241,7 +241,12 @@ end ...@@ -241,7 +241,12 @@ end
(* For performance, this table provides O(1) lookups between type names (* For performance, this table provides O(1) lookups between type names
and the underlying Cil types. Some types may be unavailable in some and the underlying Cil types. Some types may be unavailable in some
machdeps, so the table returns an option type. *) machdeps, so the table returns an option type.
Note that the type strings must follow a strict format (also used
in gcc_builtins.json), with a single space between type names and
asterisks (for pointers); otherwise we would have to do some expensive
matching.
*)
let build_type_table () : (string, typ option) Hashtbl.t = let build_type_table () : (string, typ option) Hashtbl.t =
let int8_t = Some Cil.scharType in let int8_t = Some Cil.scharType in
let int16_t = try Some (Cil.int16_t ()) with Not_found -> None in let int16_t = try Some (Cil.int16_t ()) with Not_found -> None in
...@@ -317,6 +322,9 @@ let build_type_table () : (string, typ option) Hashtbl.t = ...@@ -317,6 +322,9 @@ let build_type_table () : (string, typ option) Hashtbl.t =
] in ] in
Hashtbl.of_seq (List.to_seq types) Hashtbl.of_seq (List.to_seq types)
(* Note that [s] (the type string) follows a stricter format than the ones
allowed by the C standard w.r.t. type names; a single space must be
present between type names and asterisks. *)
let parse_type ?(template="") type_table s = let parse_type ?(template="") type_table s =
try try
if String.get s 0 == 'T' then if String.get s 0 == 'T' then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment