[LLVMdev] Mapping of class derivated and interfaces
dblaikie at gmail.com
Sat Aug 27 09:18:59 PDT 2005
> Umm ok, but i've the strange feeling that i'm missing something..
> First a simple question: getelementptr with index 0 just give me the
> same pointer, right?
the first index parameter in the previous example was 'int 0' - this
is just to get the first object pointed to by the pointer. If no other
index parameters were passed to getelementptr, then yes it woudl just
return the same pointer it was passed.
But there was a second argument 'uint 0' - this is the part used to
index the field within the struct - so if the base object was the
second element of the derived object (for multiple inheritence or
whatever other reason you might imagine) then this second parameter
could be 'uint 1'
The rest of your message seems to be based on the idea that the
derived pointer value was just begin converted to a base pointer
directly, which wasn't the case - a pointer to the base object within
the derived object was obtained. It just so happened that the base
object was the first one within the derived object, though this is in
no way a requirement.
-----BEGIN GEEK CODE BLOCK-----
GCS d+@ s++: a-- C++++ ULS++ P L++ !E W++ N+ o? K? w(+) O? M@ V? PS+ PE@
Y+ PGP- t(+) 5 X+ R tv+ b+ DI++ D++ G+ e h! r y-(-)
------END GEEK CODE BLOCK------
More information about the llvm-dev