New STL framework doesn't support const #293

So using consts as arguments to STLs causes errors in our io code and SWIG.
Added a check for const template arguments and going to ignore them for
both ICG and what we input to SWIG.
This commit is contained in:
Alex Lin 2016-08-25 08:42:43 -05:00
parent 0072e7d6f0
commit 858602fe01
2 changed files with 60 additions and 22 deletions

View File

@ -629,6 +629,8 @@ sub process_class($$$$$) {
}
if ( $template_var_def_str ne "" ) {
# if there is a whiff of const in the template we are punting.
if ( $template_var_def_str !~ /^const|[<,\s]const\s/ ) {
#print "*** template_var = $template_var_def_str ***\n" ;
$template_var_def_str =~ /(.*?)([_A-Za-z]\w*)\s*;/s ;
my ($template_full_type) = $1 ;
@ -657,6 +659,7 @@ sub process_class($$$$$) {
}
}
}
}
#print "*** unprocessed extracted = $extracted ***\n" ;
push @$class_names_ref , "$curr_namespace$class_name" ;

View File

@ -372,6 +372,35 @@ static bool checkForPrivateTemplateArgs( clang::ClassTemplateSpecializationDecl
return false ;
}
static bool checkForConstTemplateArgs( clang::ClassTemplateSpecializationDecl * ctsd ) {
unsigned int ii ;
for ( ii = 0 ; ii < ctsd->getTemplateArgs().size() ; ii++ ) {
const clang::TemplateArgument & ta = ctsd->getTemplateArgs().get(ii) ;
if ( ta.getKind() == clang::TemplateArgument::Type ) {
clang::QualType qt = ta.getAsType() ;
//std::cout << qt.getAsString() << std::endl ;
if ( qt.isConstQualified() ) {
//std::cout << " is const qualified" << std::endl ;
return true ;
} else {
//std::cout << " is public embedded class" << std::endl ;
const clang::Type * t = qt.getTypePtrOrNull() ;
if ( t != NULL ) {
if (t->getTypeClass() == clang::Type::Record ) {
clang::CXXRecordDecl * crd = t->getAsCXXRecordDecl() ;
if ( clang::isa<clang::ClassTemplateSpecializationDecl>(crd) ) {
clang::ClassTemplateSpecializationDecl * inner_ctsd ;
inner_ctsd = clang::cast<clang::ClassTemplateSpecializationDecl>(crd) ;
return checkForConstTemplateArgs(inner_ctsd) ;
}
}
}
}
}
}
return false ;
}
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
@ -430,6 +459,12 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
fdes->setIO(0) ;
}
// If the template is using a const type the STL checkpoint code will not compile,
// we need to ignore the variable.
if ( checkForConstTemplateArgs( ctsd )) {
fdes->setIO(0) ;
}
fdes->setEnumString("TRICK_STL") ;
fdes->setSTL(true) ;
fdes->setTypeName(tst_string) ;