ICG exclude of class member variables now defines incorrect memory offsets in io_src #311

Missed some bitfield offset calculations.
This commit is contained in:
Alex Lin 2016-09-16 09:46:03 -05:00
parent ae07b26243
commit 00a0e8be44
3 changed files with 13 additions and 0 deletions

View File

@ -443,6 +443,14 @@ void FieldDescription::setBitFieldWidth(unsigned int len) {
bitfield_width = len ; bitfield_width = len ;
} }
void FieldDescription::setBitFieldStart(unsigned int sb) {
bitfield_start_bit = sb ;
}
void FieldDescription::setBitFieldByteOffset(unsigned int wo) {
bitfield_word_offset = wo ;
}
unsigned int FieldDescription::getBitFieldWidth() { unsigned int FieldDescription::getBitFieldWidth() {
return bitfield_width ; return bitfield_width ;
} }

View File

@ -62,6 +62,8 @@ class FieldDescription : public ConstructValues {
std::string getEnumString() ; std::string getEnumString() ;
void setBitField( bool yes_no ) ; void setBitField( bool yes_no ) ;
void setBitFieldWidth( unsigned int len ) ; void setBitFieldWidth( unsigned int len ) ;
void setBitFieldStart( unsigned int len ) ;
void setBitFieldByteOffset( unsigned int len ) ;
unsigned int getBitFieldWidth() ; unsigned int getBitFieldWidth() ;
unsigned int getBitFieldStart() ; unsigned int getBitFieldStart() ;
unsigned int getBitFieldByteOffset() ; unsigned int getBitFieldByteOffset() ;

View File

@ -215,6 +215,9 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) {
if ( field->isBitField()) { if ( field->isBitField()) {
fdes->setBitField(true) ; fdes->setBitField(true) ;
fdes->setBitFieldWidth(field->getBitWidthValue(field->getASTContext())) ; fdes->setBitFieldWidth(field->getBitWidthValue(field->getASTContext())) ;
unsigned int field_offset_bits = field->getASTContext().getFieldOffset(field) + fdes->getBaseClassOffset() * 8 ;
fdes->setBitFieldStart( 32 - (field_offset_bits % 32) - fdes->getBitFieldWidth()) ;
fdes->setBitFieldByteOffset((field_offset_bits / 32) * 4 ) ;
} }
if ( debug_level >= 3 ) { if ( debug_level >= 3 ) {