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

@ -8,7 +8,7 @@
#ifdef __APPLE__
#include "llvm/Support/CommandLine.h"
extern llvm::cl::opt< bool > no_offset_of ;
extern llvm::cl::opt< bool > global_compat15 ;
#endif
ClassValues::ClassValues() :
@ -16,7 +16,8 @@ ClassValues::ClassValues() :
is_pod(false) ,
is_abstract(false) ,
has_default_constructor(false) ,
has_public_destructor(false)
has_public_destructor(false),
compat15(false)
{}
ClassValues::~ClassValues() {
@ -30,7 +31,7 @@ void ClassValues::addFieldDescription(FieldDescription * in_fdes) {
field_descripts.push_back(in_fdes) ;
#ifdef __APPLE__
if ( no_offset_of ) {
if ( !global_compat15 and !compat15 ) {
#else
{
#endif
@ -57,7 +58,7 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
std::vector<FieldDescription *>::iterator fdit ;
// Loop through the incoming inherited variable names
#ifdef __APPLE__
if ( no_offset_of ) {
if ( !global_compat15 and !compat15 ) {
#else
{
#endif
@ -203,6 +204,14 @@ bool ClassValues::isPOD() {
return is_pod ;
}
void ClassValues::setSize(unsigned int in_size) {
size = in_size ;
}
unsigned int ClassValues::getSize() {
return size ;
}
void ClassValues::setAbstract(bool in_val) {
is_abstract = in_val ;
}
@ -266,6 +275,14 @@ std::string ClassValues::getFullyQualifiedMangledTypeName() {
return oss.str() ;
}
void ClassValues::setCompat15(bool in_val) {
compat15 = in_val ;
}
bool ClassValues::isCompat15() {
return compat15 ;
}
void ClassValues::print_namespaces(std::ostream & os, const char * delimiter) {
unsigned int ii ;
for ( ii = 0 ; ii < namespaces.size() ; ii++ ) {