search for: mbr_offset_of

Displaying 5 results from an estimated 5 matches for "mbr_offset_of".

2012 Oct 02
2
[LLVMdev] Offset to C++ structure members
...I'd rather not do, not to mention that it's fairly "brittle" even if I could manage to get it right. (Simple structs would probably be easy, but struct that have virtual functions or multiple base classes would be much harder.) > I'm not entirely sure how you're using mbr_offset_of Given 't', an instance of some class T, and some member T::m, find the integer offset in bytes from &t to &t.m. This offset, when added to &t, should be &t.m. I'm using mbr_offset_of to get the C++ compiler to do the work of telling me what the correct offset is for t...
2012 Oct 02
2
[LLVMdev] Offset to C++ structure members
...er to call it. However, assume that there is no such S member function. I therefore need a way to get the offset of 'b' and add it to 's' so that I can call T_string_M_assign_Pv() on it. Given this helper function: template<class ClassType,class MbrType> inline ptrdiff_t mbr_offset_of( MbrType ClassType::*p ) { ClassType const *const c = static_cast<ClassType*>( nullptr ); return reinterpret_cast<ptrdiff_t>( &(c->*p) ); } I could take a Pointer to an S, use ptrtoint, add the offset, use inttoptr, and use that pointer to pass as the 'this' argum...
2012 Oct 02
0
[LLVMdev] Offset to C++ structure members
...there is no such S member function. I therefore need a way to get the offset of 'b' and add it to 's' so that I can call T_string_M_assign_Pv() on it. > > Given this helper function: > > template<class ClassType,class MbrType> inline > ptrdiff_t mbr_offset_of( MbrType ClassType::*p ) { > ClassType const *const c = static_cast<ClassType*>( nullptr ); > return reinterpret_cast<ptrdiff_t>( &(c->*p) ); > } > > I could take a Pointer to an S, use ptrtoint, add the offset, use inttoptr, and use tha...
2012 Oct 02
0
[LLVMdev] Offset to C++ structure members
...would probably be easy, but struct that have virtual functions or multiple base classes would be much harder.) No, you don't have to... you can just use GEP on i8*'s. The LLVM type system doesn't have any semantic significance. >> I'm not entirely sure how you're using mbr_offset_of > > Given 't', an instance of some class T, and some member T::m, find the integer offset in bytes from &t to &t.m. This offset, when added to &t, should be &t.m. > > I'm using mbr_offset_of to get the C++ compiler to do the work of telling me what the corre...
2012 Oct 02
1
[LLVMdev] Offset to C++ structure members
...ons or multiple base classes would be much harder.) > > No, you don't have to... you can just use GEP on i8*'s. The LLVM type > system doesn't have any semantic significance. Oh! I just tried it and it works. :-) >>> I'm not entirely sure how you're using mbr_offset_of >> >> Given 't', an instance of some class T, and some member T::m, find the integer offset in bytes from &t to &t.m. This offset, when added to &t, should be &t.m. >> >> I'm using mbr_offset_of to get the C++ compiler to do the work of telling...