how to mapping from struct index to name

Hi!

How can I find out the mapping between structure element names and index used
in getelementptr?
If I have the following program:

struct Foo
{
     int i;
     float j;
};

Foo foo;

void main()
{
     foo.j = 1.0f
}

I get an instruction containing getelementptr (%Foo* @foo, i32 0, i32 1)
Member i is at index 0 and member j is at index 1.
This is what I want to find out.
Perhaps it can be done using debug info?

-Jochen

Ah, this explains later message.

Why do you want to do this? Are you prepared to handle bit-fields?

- Daniel

Hi!

Why do you want to do this? Are you prepared to handle bit-fields?
   

bit-fields will not appear in my input code.
If llvm ir accesses a field (only bool, int or float) i want to find out the field name.
But seems i can copy the implementation of CodeGeneratorImpl in ModuleBuilder.cpp
and then access the CodeGenTypes.

-Jochen

Hi!

For me it would be convenient if CodeGeneratorImpl is visible in a header file instead of
being hidden in an anonymous namespace.

-Jochen