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

This changes back the default behavior to not use offsetof in io_src code.
Added a flag to ICG, -c or --compat15, to globally generate offsetof statements.
Added an ENV variable that can be used to generate offsetof statements by file or directory.
Added in a warning if classes parsed at ICG time are different in size than at runtime.
This commit is contained in:
Alex Lin
2016-10-21 09:30:55 -05:00
parent 5484e39f11
commit f1cbacd646
13 changed files with 233 additions and 125 deletions

View File

@ -12,7 +12,7 @@
#include "ClassValues.hh"
#include "EnumValues.hh"
extern llvm::cl::opt< bool > no_offset_of ;
extern llvm::cl::opt< bool > global_compat15 ;
PrintFileContentsBase::PrintFileContentsBase() {}
@ -77,7 +77,15 @@ void PrintFileContentsBase::print_close_extern_c(std::ostream & ostream) {
*/
bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescription * fdes ) {
if ( fdes->getTypeName().compare("void") and fdes->getIO() != 0 and fdes->getEnumString().compare("TRICK_VOID")) {
if ( no_offset_of ) {
if ( global_compat15 or c->isCompat15()) {
if ( fdes->isInherited() ) {
return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected)
|| (fdes->getAccess() == clang::AS_public)) ;
} else {
return (c->getHasInitAttrFriend()
|| (fdes->getAccess() == clang::AS_public)) ;
}
} else {
if ( fdes->isStatic() ) {
if ( fdes->isInherited() ) {
return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected)
@ -89,14 +97,7 @@ bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescripti
} else {
return true ;
}
} else {
if ( fdes->isInherited() ) {
return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected)
|| (fdes->getAccess() == clang::AS_public)) ;
} else {
return (c->getHasInitAttrFriend()
|| (fdes->getAccess() == clang::AS_public)) ;
}
}
}
return false ;