typedef struct

Hi all,

If I have a C struct declaration like this:

typedef struct typeA {...} typeB;

In the type symbol table generated should it contain an entry for struct.typeA or struct.typeB? I seem to have seen both cases using the same llvm toolchain so I just wonder if I have done something wrong.

Thanks,
Alvin

Hi Alvin,

If I have a C struct declaration like this:

typedef struct typeA {...} typeB;

In the type symbol table generated should it contain an entry for struct.typeA or struct.typeB? I seem to have seen both cases using the same llvm toolchain so I just wonder if I have done something wrong.

it doesn't matter what the name is since it has no effect on generated
code. It's only in debug info that type names matter, so if you are not
seeing this in debug info I wouldn't worry about it if I were you.

Ciao,

Duncan.

Hi Duncan,

Actually what I am doing is matching up each Type with its corresponding debug info. I have checked that the debug info generated is consistent (i.e., typeA is recorded as a derived type from composite type typeB in my example), but I have seen cases where the name recorded in the Type object is typeA and sometimes typeB, that's why I am confused.

Alvin

Duncan Sands wrote:

Hi Alvin,

Actually what I am doing is matching up each Type with its corresponding debug info. I have checked that the debug info generated is consistent (i.e., typeA is recorded as a derived type from composite type typeB in my example), but I have seen cases where the name recorded in the Type object is typeA and sometimes typeB, that's why I am confused.

do you get this naming strangeness in the debug info, or in other parts
of the LLVM IR? LLVM uses structural equivalence, so for example two
struct types with the same fields are considered to be the same. This
can result in the "wrong" name being used for the type in the IR. So if
that's the phenomenon you are seeing then there is nothing wrong because
this is not visible to users. However if the wrong name is being output
in debug info (so in gdb you would see the wrong name) then that sounds
like a bug. So can you please be more clear about exactly when you see
this strangeness.

Ciao,

Duncan.