Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing support for 'asm inline', a few gcc builtin's and an error-state reset function #151

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,7 @@ let initGccBuiltins () : unit =
H.add h "__builtin_inff" (floatType, [], false);
H.add h "__builtin_infl" (longDoubleType, [], false);
H.add h "__builtin_memcpy" (voidPtrType, [ voidPtrType; voidConstPtrType; sizeType ], false);
H.add h "__builtin_memchr" (voidPtrType, [voidConstPtrType; intType; ulongType], false);
H.add h "__builtin_mempcpy" (voidPtrType, [ voidPtrType; voidConstPtrType; sizeType ], false);
H.add h "__builtin_memset" (voidPtrType,
[ voidPtrType; intType; intType ], false);
Expand Down Expand Up @@ -3052,6 +3053,7 @@ let initGccBuiltins () : unit =
H.add h "__builtin_sqrtl" (longDoubleType, [ longDoubleType ], false);

H.add h "__builtin_stpcpy" (charPtrType, [ charPtrType; charConstPtrType ], false);
H.add h "__builtin_strcat" (charPtrType, [charPtrType; charConstPtrType], false);
H.add h "__builtin_strchr" (charPtrType, [ charPtrType; intType ], false);
H.add h "__builtin_strcmp" (intType, [ charConstPtrType; charConstPtrType ], false);
H.add h "__builtin_strcpy" (charPtrType, [ charPtrType; charConstPtrType ], false);
Expand Down
11 changes: 6 additions & 5 deletions src/frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ asmattr:
/* empty */ { [] }
| VOLATILE asmattr { ("volatile", []) :: $2 }
| CONST asmattr { ("const", []) :: $2 }
| INLINE asmattr { ("inline", []) :: $2 }
;
asmtemplate:
one_string_constant { [$1] }
Expand Down Expand Up @@ -1682,15 +1683,15 @@ asmopname:

asmclobber:
/* empty */ { [] }
| COLON asmcloberlst { $2 }
| COLON asmclobberlst { $2 }
;
asmcloberlst:
asmclobberlst:
/* empty */ { [] }
| asmcloberlst_ne { $1 }
| asmclobberlst_ne { $1 }
;
asmcloberlst_ne:
asmclobberlst_ne:
one_string_constant { [$1] }
| one_string_constant COMMA asmcloberlst_ne { $1 :: $3 }
| one_string_constant COMMA asmclobberlst_ne { $1 :: $3 }
;

%%
2 changes: 2 additions & 0 deletions src/frontc/frontc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ let args : (string * Arg.spec * string) list =
exception ParseError of string
exception CabsOnly

let resetErrors () = E.hadErrors := false

(* parse, and apply patching *)
let rec parse_to_cabs fname =
begin
Expand Down
2 changes: 2 additions & 0 deletions src/frontc/frontc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ val args: (string * Arg.spec * string) list

(* the main command to parse a file. Return a thunk that can be used to
convert the AST to CIL. *)
val resetErrors: unit -> unit

val parse: string -> (unit -> Cil.file)

val parse_with_cabs: string -> (unit -> Cabs.file * Cil.file)
Expand Down