On Fri, Feb 17, 2012 at 03:46:14PM +0100, Oliver Schwahn wrote:
> I need to preserve the original function parameter types, including any
> qualifiers, for my CIL analysis. Is there a way to prevent the const
> removal and preserve type qualifiers for such non-pointer type function
> parameters?
Many thanks for the report, this bug seems to have been tentatively fixed back
in 2002 (!) but nobody tested it and it remained pending until your report.
I think the following patch solves the issue:
diff --git a/src/frontc/cabs2cil.ml b/src/frontc/cabs2cil.ml
index b8acaa6..4b2124c 100644
--- a/src/frontc/cabs2cil.ml
+++ b/src/frontc/cabs2cil.ml
@@ -2559,6 +2559,8 @@ and makeVarInfoCabs
vtype
in
let vi = makeVarinfo isglobal n t in
+ (* makeVarinfo removes "const" even for formals, please respect my choices!
*)
+ vi.vtype <- t;
vi.vstorage <- sto;
vi.vattr <- nattr;
vi.vdecl <- ldecl;
@@ -5781,6 +5783,8 @@ and doDecl (isglobal: bool) : A.definition -> chunk =
function
(* sfg: extract locations for the formals from dt *)
let doFormal (loc : location) (fn, ft, fa) =
let f = makeVarinfo false fn ft in
+ (* makeVarinfo removes const qualifier even on formals *)
+ f.vtype <- ft;
(f.vdecl <- loc;
f.vattr <- fa;
alphaConvertVarAndAddToEnv true f)
Could you test it please?
I’ll commit it as soon as I find the time to check it does not introduce any
regression.
Best regards,
--
Gabriel
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users