[PATCH] [Annotalysis] Fixes virtual method calls when type is unknown

Diego Novillo dnovillo@google.com
Thu Jun 30 17:32:00 GMT 2011


On 11-06-30 13:01 , Delesley Hutchins wrote:
> This bug fixes a failure in annotalysis that is caused when gcc does
> not return the correct static type for the callee of a virtual method.
>
> Bootstrapped and passed GCC regression testsuite on x86_64-unknown-linux-gnu.
>
> Okay for branches/annotalysis and google/main?

OK with some minor formatting nits below.

> 2011-06-30   DeLesley Hutchins<delesley@google.com>
>          * tree-threadsafe-analyze.c (handle_call_gs): Fixes case where
> the virtual
>          method callee has unknown type.

Blank line after address line.
Watch for line wrapping past 80 columns.


>             tree objtype = TREE_TYPE (TREE_TYPE (OBJ_TYPE_REF_OBJECT (callee)));
> -          fdecl = lang_hooks.get_virtual_function_decl (callee, objtype);
> +          /* Check to make sure objtype is a valid type.
> +           * OBJ_TYPE_REF_OBJECT does not always return the correct
> static type of the callee.
> +           * For example:  Given  foo(void* ptr) { ((Foo*)
> ptr)->doSomething(); }
> +           * objtype will be void, not Foo.  Whether or not this
> happens depends on the details
> +           * of how a particular call is lowered to GIMPLE, and there
> is no easy fix that works
> +           * in all cases.  For now, we simply rely on gcc's type
> information; if that information
> +           * is not accurate, then the analysis will be less precise.
> +           */

Don't use leading '*' in multi-line comments.
s/gcc/GCC/

> +          if (TREE_CODE(objtype) == RECORD_TYPE)  /* if objtype is an
> object type... */

Comments at the end of a line are rarely used.  No need to add one in 
this case.

> +            {
> +              fdecl = lang_hooks.get_virtual_function_decl (callee, objtype);
> +            }

No need to add braces here.


Thanks.  Diego.



More information about the Gcc-patches mailing list