mirror of
https://github.com/nasa/trick.git
synced 2025-01-18 02:40:08 +00:00
Merge branch '17.0'
This commit is contained in:
commit
c134ffea8f
@ -38,7 +38,8 @@ void ClassValues::addFieldDescription(FieldDescription * in_fdes) {
|
||||
field_name_to_info_map[in_fdes->getName()] = in_fdes ;
|
||||
}
|
||||
|
||||
void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *> in_fdes, unsigned int class_offset ) {
|
||||
void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *> in_fdes,
|
||||
unsigned int class_offset, bool virtual_inherited ) {
|
||||
// Make a copy of all of the FieldDescription variables.
|
||||
field_descripts.insert(field_descripts.end(), in_fdes.begin() , in_fdes.end()) ;
|
||||
|
||||
@ -46,7 +47,9 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
|
||||
// Loop through the incoming inherited variable names
|
||||
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; fdit++ ) {
|
||||
|
||||
(*fdit)->setBaseClassOffset( class_offset ) ;
|
||||
(*fdit)->setInherited( true ) ;
|
||||
(*fdit)->setVirtualInherited( virtual_inherited ) ;
|
||||
// Adds the class offset to the field offset giving the total offset to the inherited variable
|
||||
// The offset is stored in bits so multiply class_offset by 8.
|
||||
(*fdit)->addOffset( class_offset * 8 ) ;
|
||||
|
@ -36,7 +36,8 @@ class ClassValues : public ConstructValues {
|
||||
|
||||
/** Appends a vector of fields to field_descripts.
|
||||
A vector comes from adding all inherited fields at once */
|
||||
void addInheritedFieldDescriptions(std::vector<FieldDescription *>, unsigned int class_offset) ;
|
||||
void addInheritedFieldDescriptions(std::vector<FieldDescription *>,
|
||||
unsigned int class_offset, bool virtual_inherited) ;
|
||||
|
||||
/** Gets the list of fields in this class */
|
||||
std::vector<FieldDescription *> getFieldDescription() ;
|
||||
|
@ -206,7 +206,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
||||
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, false) ;
|
||||
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
||||
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription(),
|
||||
inherit_class_offset) ;
|
||||
inherit_class_offset, false) ;
|
||||
// clear the field list in the inherited class so they are not freed when inherit_cvis
|
||||
// goes out of scope.
|
||||
inherit_cvis.get_class_data()->clearFieldDescription() ;
|
||||
@ -256,7 +256,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
||||
//std::cout << " [34m" << getFileName(ci , rd->getRBraceLoc(), hsd) << "[00m" << std::endl ;
|
||||
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, false) ;
|
||||
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
||||
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription(), inherit_class_offset) ;
|
||||
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription(), inherit_class_offset, true) ;
|
||||
// clear the field list in the inherited class so they are not freed when inherit_cvis goes out of scope.
|
||||
inherit_cvis.get_class_data()->clearFieldDescription() ;
|
||||
// If we are inheriting from a template specialization, don't save the inherited class. This list
|
||||
|
@ -37,9 +37,11 @@ ut_system * FieldDescription::u_system = get_u_system() ;
|
||||
FieldDescription::FieldDescription(
|
||||
std::string in_container_class ) :
|
||||
container_class(in_container_class) ,
|
||||
base_class_offset(0) ,
|
||||
field_offset(0) ,
|
||||
field_width(0) ,
|
||||
inherited(false) ,
|
||||
virtual_inherited(false) ,
|
||||
units("1") ,
|
||||
is_dashdash(false) ,
|
||||
line_no(0) ,
|
||||
@ -314,6 +316,14 @@ void FieldDescription::setContainerClass(std::string in_name ) {
|
||||
container_class = in_name ;
|
||||
}
|
||||
|
||||
void FieldDescription::setBaseClassOffset(unsigned int in_offset) {
|
||||
base_class_offset = in_offset ;
|
||||
}
|
||||
|
||||
unsigned int FieldDescription::getBaseClassOffset() {
|
||||
return base_class_offset ;
|
||||
}
|
||||
|
||||
void FieldDescription::setFieldOffset(unsigned int in_offset) {
|
||||
field_offset = in_offset ;
|
||||
}
|
||||
@ -393,6 +403,14 @@ bool FieldDescription::isInherited() {
|
||||
return inherited ;
|
||||
}
|
||||
|
||||
void FieldDescription::setVirtualInherited(bool in_inherited) {
|
||||
virtual_inherited = in_inherited ;
|
||||
}
|
||||
|
||||
bool FieldDescription::isVirtualInherited() {
|
||||
return virtual_inherited ;
|
||||
}
|
||||
|
||||
void FieldDescription::setAccess( clang::AccessSpecifier in_val ) {
|
||||
access = in_val ;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class FieldDescription : public ConstructValues {
|
||||
/* Accessor functions to the data of the class */
|
||||
std::string getContainerClass() ;
|
||||
void setContainerClass( std::string in_name ) ;
|
||||
void setBaseClassOffset( unsigned int in_offset ) ;
|
||||
unsigned int getBaseClassOffset() ;
|
||||
void setFieldOffset( unsigned int in_offset ) ;
|
||||
unsigned int getFieldOffset() ;
|
||||
@ -80,6 +81,8 @@ class FieldDescription : public ConstructValues {
|
||||
bool isStatic() ;
|
||||
void setInherited( bool yes_no ) ;
|
||||
bool isInherited() ;
|
||||
void setVirtualInherited( bool yes_no ) ;
|
||||
bool isVirtualInherited() ;
|
||||
void setAccess( clang::AccessSpecifier in_val ) ;
|
||||
clang::AccessSpecifier getAccess() ;
|
||||
void addOffset( unsigned int offset ) ;
|
||||
@ -97,6 +100,10 @@ class FieldDescription : public ConstructValues {
|
||||
/** Name of the class this field is in */
|
||||
std::string container_class ;
|
||||
|
||||
/** This is copied from the current class we are processing. It is the class offset to
|
||||
be added to field offset */
|
||||
unsigned int base_class_offset ;
|
||||
|
||||
/** The total offset to the current field in bits */
|
||||
unsigned int field_offset ;
|
||||
|
||||
@ -151,6 +158,9 @@ class FieldDescription : public ConstructValues {
|
||||
/** is this field inherited from parent class */
|
||||
bool inherited ;
|
||||
|
||||
/** is this field virtual inherited from parent class */
|
||||
bool virtual_inherited ;
|
||||
|
||||
/** is an enumeration */
|
||||
bool is_enum ;
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "EnumValues.hh"
|
||||
#include "Utilities.hh"
|
||||
|
||||
extern llvm::cl::opt< bool > no_offset_of ;
|
||||
|
||||
PrintFileContents10::PrintFileContents10() {}
|
||||
|
||||
/** Prints the io_src header information */
|
||||
@ -157,6 +159,7 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ofstream & outfile ,
|
||||
ClassValues * cv , unsigned int index ) {
|
||||
|
||||
// For static variables replace the offset field with the address of the static variable
|
||||
if ( no_offset_of ) {
|
||||
if ( fdes->isStatic() ) {
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
@ -166,6 +169,54 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ofstream & outfile ,
|
||||
printContainerClasses( outfile, cv , "::" ) ;
|
||||
outfile << cv->getName() << "::" << fdes->getName() << " ;\n" ;
|
||||
}
|
||||
} else {
|
||||
if ( fdes->isStatic() ) {
|
||||
// print a special offsetof statement if this is a static
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].offset = (long)(void *)&" ;
|
||||
printNamespaces( outfile, cv , "::" ) ;
|
||||
printContainerClasses( outfile, cv , "::" ) ;
|
||||
outfile << cv->getName() << "::" << fdes->getName() << " ;\n" ;
|
||||
} else if ( fdes->isBitField() ) {
|
||||
// else if this is a bitfield
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].offset = " ;
|
||||
outfile << fdes->getBitFieldByteOffset() << " ;\n" ;
|
||||
// All bitfield offsets are in terms of unsigned ints.
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].size = sizeof(unsigned int) ;\n" ;
|
||||
} else if ( fdes->isVirtualInherited() ) {
|
||||
// else if we have a virtually inherited class.
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].offset = " << fdes->getBaseClassOffset() ;
|
||||
outfile << " + offsetof(" ;
|
||||
outfile << fdes->getContainerClass() << "," << fdes->getName() << ") ;\n" ;
|
||||
} else if ( cv->getMangledTypeName() != cv->getName() ) {
|
||||
// else if we have a template type where mangled_type_name is different then name.
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].offset = offsetof(" ;
|
||||
outfile << cv->getMangledTypeName() << "," << fdes->getName() << ") ;\n" ;
|
||||
} else {
|
||||
// else print an offsetof statement if this is not a special case
|
||||
outfile << " attr" ;
|
||||
printNamespaces( outfile, cv , "__" ) ;
|
||||
printContainerClasses( outfile, cv , "__" ) ;
|
||||
outfile << cv->getMangledTypeName() << "[" << index << "].offset = offsetof(" ;
|
||||
printNamespaces( outfile, cv , "::" ) ;
|
||||
printContainerClasses( outfile, cv , "::" ) ;
|
||||
outfile << cv->getMangledTypeName() << "," << fdes->getName() << ") ;\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( fdes->isSTL()) {
|
||||
outfile << " attr" ;
|
||||
|
@ -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,6 +78,7 @@ 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 ( no_offset_of ) {
|
||||
if ( fdes->isStatic() ) {
|
||||
if ( fdes->isInherited() ) {
|
||||
return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected)
|
||||
@ -85,6 +90,15 @@ 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 ;
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ llvm::cl::list< std::string > input_file_names(llvm::cl::Positional, llvm::cl::d
|
||||
llvm::cl::list< std::string > sink(llvm::cl::Sink, llvm::cl::ZeroOrMore) ;
|
||||
llvm::cl::list< std::string > pre_compiled_headers("include", llvm::cl::Prefix, llvm::cl::desc("pre-compiled headers"),
|
||||
llvm::cl::value_desc("pre_compiled_headers")) ;
|
||||
|
||||
llvm::cl::opt< bool > no_offset_of ("n", llvm::cl::desc("Do not print the offsetof calculations in attributes")) ;
|
||||
llvm::cl::alias no_offset_of_alias ("no-offset-of" , llvm::cl::desc("Alias for -n") , llvm::cl::aliasopt(no_offset_of)) ;
|
||||
|
||||
//llvm::cl::opt< bool > show_units ("u", llvm::cl::desc("List recognized units")) ;
|
||||
|
||||
void ICG_version() {
|
||||
|
Loading…
Reference in New Issue
Block a user