diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2015-10-20 14:45:56 +0200 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2015-10-20 14:45:56 +0200 |
commit | ed6043fe910f7a320f7af6d3f9d35f39f5cf7ee1 (patch) | |
tree | 3fab134f5444f0472a1ff8c06e5b7686a40648dc /cparser/Cutil.ml | |
parent | 4d542bc7eafadb16b845cf05d1eb4988eb55ed0f (diff) | |
parent | 8a95c3e07fd02eaa87f8cca447bc7d7c2642eb22 (diff) | |
download | compcert-ed6043fe910f7a320f7af6d3f9d35f39f5cf7ee1.tar.gz compcert-ed6043fe910f7a320f7af6d3f9d35f39f5cf7ee1.zip |
Merge remote-tracking branch 'origin/master' into named-externals
Conflicts:
arm/TargetPrinter.ml
backend/CMparser.mly
backend/SelectLongproof.v
backend/Selectionproof.v
cfrontend/C2C.ml
checklink/Asm_printers.ml
checklink/Check.ml
checklink/Fuzz.ml
common/AST.v
debug/DebugInformation.ml
debug/DebugInit.ml
debug/DwarfPrinter.ml
debug/DwarfTypes.mli
debug/Dwarfgen.ml
exportclight/ExportClight.ml
ia32/TargetPrinter.ml
powerpc/Asm.v
powerpc/SelectOpproof.v
powerpc/TargetPrinter.ml
Diffstat (limited to 'cparser/Cutil.ml')
-rw-r--r-- | cparser/Cutil.ml | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 074a0802..a86c779f 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -177,6 +177,48 @@ let remove_attributes_type env attr t = let erase_attributes_type env t = change_attributes_type env (fun a -> []) t +(* Remove all attributes from type that are not contained in attr *) +let strip_attributes_type t attr = + let strip = List.filter (fun a -> List.mem a attr) in + match t with + | TVoid at -> TVoid (strip at) + | TInt (k,at) -> TInt (k,strip at) + | TFloat (k,at) -> TFloat(k,strip at) + | TPtr (t,at) -> TPtr(t,strip at) + | TArray (t,s,at) -> TArray(t,s,strip at) + | TFun (t,arg,v,at) -> TFun(t,arg,v,strip at) + | TNamed (n,at) -> TNamed(n,strip at) + | TStruct (n,at) -> TStruct(n,strip at) + | TUnion (n,at) -> TUnion(n,strip at) + | TEnum (n,at) -> TEnum(n,strip at) + +(* Remove the last attribute from the toplevel and return the changed type *) +let strip_last_attribute typ = + let rec hd_opt l = match l with + [] -> None,[] + | a::rest -> Some a,rest in + match typ with + | TVoid at -> let l,r = hd_opt at in + l,TVoid r + | TInt (k,at) -> let l,r = hd_opt at in + l,TInt (k,r) + | TFloat (k,at) -> let l,r = hd_opt at in + l,TFloat (k,r) + | TPtr (t,at) -> let l,r = hd_opt at in + l,TPtr(t,r) + | TArray (t,s,at) -> let l,r = hd_opt at in + l,TArray(t,s,r) + | TFun (t,arg,v,at) -> let l,r = hd_opt at in + l,TFun(t,arg,v,r) + | TNamed (n,at) -> let l,r = hd_opt at in + l,TNamed(n,r) + | TStruct (n,at) -> let l,r = hd_opt at in + l,TStruct(n,r) + | TUnion (n,at) -> let l,r = hd_opt at in + l,TUnion(n,r) + | TEnum (n,at) -> let l,r = hd_opt at in + l,TEnum(n,r) + (* Extracting alignment value from a set of attributes. Return 0 if none. *) let alignas_attribute al = |