From: Justin Seyster Date: Wed, 13 Oct 2010 00:39:20 +0000 (-0400) Subject: Fixed bug caused by trying to do casts directly in advice calls. X-Git-Tag: release-v1.0~39 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=9ad00a0ac1bbeed32046de757ac64bd94d8cadf8;p=interaspect.git Fixed bug caused by trying to do casts directly in advice calls. --- diff --git a/src/aop-weave.c b/src/aop-weave.c index 348534c..9d5cd98 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -142,10 +142,29 @@ build_string_ptr (const char *string) return ret; } +/* Create a temporary variable and assign the given value to that + variable with a cast. Insert the assignment before the join point + and return the temporary value. */ +static tree +insert_cast (tree val, tree cast_type, struct aop_joinpoint *jp) +{ + tree tmp; + tree cast; + gimple cast_assign; + + tmp = create_tmp_var (cast_type, "ia_cast"); + cast = build1 (CONVERT_EXPR, cast_type, val); + + cast_assign = gimple_build_assign (tmp, cast); + jp->pc->insert_before (jp, cast_assign); + + return tmp; +} + /* Whenver InterAspect matches an "all signed" or "all unsigned" value, it needs to cast it up to a long long before passing it. */ static tree -cast_to_all_integer (tree val) +cast_to_all_integer (tree val, struct aop_joinpoint *jp) { tree gcc_type; HOST_WIDE_INT size; @@ -161,8 +180,7 @@ cast_to_all_integer (tree val) tree cast_type = TYPE_UNSIGNED (gcc_type) ? long_long_unsigned_type_node : long_long_integer_type_node; - val = build1 (CONVERT_EXPR, cast_type, val); - return val; + return insert_cast (val, cast_type, jp); } else { @@ -171,8 +189,9 @@ cast_to_all_integer (tree val) } } +/* Similar to cast_to_all_integer, above. */ static tree -cast_to_all_fp (tree val) +cast_to_all_fp (tree val, struct aop_joinpoint *jp) { tree gcc_type; HOST_WIDE_INT size; @@ -185,8 +204,7 @@ cast_to_all_fp (tree val) if (size != 8) { - val = build1 (CONVERT_EXPR, double_type_node, val); - return val; + return insert_cast (val, double_type_node, jp); } else { @@ -203,9 +221,9 @@ build_dynval (struct aop_dynval *dv) val = dv->get_dynval (dv); if (is_all_integer_type (dv->type)) - val = cast_to_all_integer (val); + val = cast_to_all_integer (val, dv->jp); else if (is_all_fp_type (dv->type)) - val = cast_to_all_fp (val); + val = cast_to_all_fp (val, dv->jp); return val; }