[cfe-dev] Unions in the Clang Static Analyzer

Keno Fischer via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 2 12:20:01 PST 2017


On Thu, Mar 2, 2017 at 12:12 PM, Artem Dergachev <noqnoqneo at gmail.com> wrote:
> How would we unify these values? If you come up with a single symbol to
> represent them, what would be the type of that symbol?

My rough conception on how this would work is that the first access
would create the symbol and determine the type and then accesses
through other members would be equivalent to a cast to the other type.

At the very least, I would like to make sure that symbols are
preserved through union assignment (and passing unions to functions),
if they are only every accessed through the same union member, as well
as simple cases like:

union {
int *intptr;
float *floatptr;
}

Just having that work reliably would probably have fixed 90% of the
trouble I was having here.

Keno



More information about the cfe-dev mailing list