Fix io code for classes with excluded parents

Check the return value of CXXRecordVisitor::TraverseCXXRecordDecl and
don't add information from excluded parents.
Add a parameter to PrintAttributes::isHeaderExcluded to toggle exlusion
of TRICK_EXT_LIB_DIRS paths. When traversing a CXX record, we don't
actually want to skip these paths since their io code should exist in
the Trickified library.
Fix memory leak.

Refs #435
This commit is contained in:
Derek Bankieris
2017-05-24 09:57:07 -05:00
parent 56bdafc68b
commit 1dbeb3e2d4
4 changed files with 26 additions and 25 deletions

View File

@ -152,7 +152,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
// Return false to stop processing if this header file is excluded by one of many reasons.
std::string header_file_name = getFileName(ci , rec->RBRACELOC(), hsd) ;
char * rp = almostRealPath(header_file_name.c_str()) ;
if ( rp == NULL || pa.isHeaderExcluded(header_file_name) ) {
if ( rp == NULL || pa.isHeaderExcluded(header_file_name, false) ) {
// mark the header as visited so PrintAttributes doesn't process it during addEmptyFiles()
pa.markHeaderAsVisited(header_file_name);
return false ;
@ -212,26 +212,26 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
//std::cout << " inherit_class_offset = " << inherit_class_offset << "" << std::endl ;
//std::cout << " " << getFileName(ci , rd->RBRACELOC(), hsd) << "" << 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()->getFieldDescriptions(),
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() ;
// If we are inheriting from a template specialization, don't save the inherited class. This list
// is maintained to call init_attr of the inherited classes. A template specialization does not
// havethese attributes.
if ( ! isTypeTemplateSpecialization(temp) ) {
// We want to save the inherited class data, but it's going to go out of scope so we need
// to make a copy of it.
ClassValues * icv = new ClassValues(*(inherit_cvis.get_class_data())) ;
// The inherited classes of this inherited class are not required in the copy,
// and they are going out of scope
cval.saveInheritAncestry(icv) ;
icv->clearInheritedClass() ;
if (inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd))) {
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescriptions(), 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() ;
// If we are inheriting from a template specialization, don't save the inherited class. This list
// is maintained to call init_attr of the inherited classes. A template specialization does not
// havethese attributes.
if ( ! isTypeTemplateSpecialization(temp) ) {
// We want to save the inherited class data, but it's going to go out of scope so we need
// to make a copy of it.
ClassValues * icv = new ClassValues(*(inherit_cvis.get_class_data())) ;
// The inherited classes of this inherited class are not required in the copy,
// and they are going out of scope
cval.saveInheritAncestry(icv) ;
icv->clearInheritedClass() ;
// Save the copy of the inherited class to the current class
cval.addInheritedClass(inherit_cvis.get_class_data()->getFullyQualifiedTypeName()) ;
// Save the copy of the inherited class to the current class
cval.addInheritedClass(inherit_cvis.get_class_data()->getFullyQualifiedTypeName()) ;
}
}
}
}