mirror of
https://github.com/nasa/trick.git
synced 2025-06-21 08:29:39 +00:00
ICG exclude of class member variables now defines incorrect memory offsets in io_src #311
Added back the code that set the offset of variables with the offsetof function. This code is running by default. Any code that includes #ifndef TRICK_ICG in classes/structures will want this on. Added a flag to ICG that allows us to turn off writing of these lines. If the flag is present, ICG may write out io_src code for private/protected variables that it could not reach if an offsetof function was required. Code cannot have any #ifndef TRICK_ICG present in classes/structures for this to work.
This commit is contained in:
@ -6,11 +6,15 @@
|
||||
#include <string.h>
|
||||
#include <iomanip>
|
||||
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
#include "PrintFileContentsBase.hh"
|
||||
#include "FieldDescription.hh"
|
||||
#include "ClassValues.hh"
|
||||
#include "EnumValues.hh"
|
||||
|
||||
extern llvm::cl::opt< bool > no_offset_of ;
|
||||
|
||||
PrintFileContentsBase::PrintFileContentsBase() {}
|
||||
|
||||
// provide empty default implementation of these routines.
|
||||
@ -74,7 +78,19 @@ void PrintFileContentsBase::print_close_extern_c(std::ofstream & outfile) {
|
||||
*/
|
||||
bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescription * fdes ) {
|
||||
if ( fdes->getTypeName().compare("void") and fdes->getIO() != 0 and fdes->getEnumString().compare("TRICK_VOID")) {
|
||||
if ( fdes->isStatic() ) {
|
||||
if ( no_offset_of ) {
|
||||
if ( fdes->isStatic() ) {
|
||||
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 {
|
||||
return true ;
|
||||
}
|
||||
} else {
|
||||
if ( fdes->isInherited() ) {
|
||||
return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected)
|
||||
|| (fdes->getAccess() == clang::AS_public)) ;
|
||||
@ -82,8 +98,6 @@ bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescripti
|
||||
return (c->getHasInitAttrFriend()
|
||||
|| (fdes->getAccess() == clang::AS_public)) ;
|
||||
}
|
||||
} else {
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
|
Reference in New Issue
Block a user