diff --git a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp index 96a8fc56..833bbcd8 100644 --- a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp @@ -13,6 +13,7 @@ #include "EnumValues.hh" #include "FieldVisitor.hh" #include "Utilities.hh" +#include "CommentSaver.hh" #include "PrintAttributes.hh" extern llvm::cl::opt< int > debug_level ; @@ -129,8 +130,22 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) { if ( debug_level >= 2 ) { rec->dump() ; std::cout << std::endl ; } + + // Return false to stop processing if there is no definition of this class if ( rec->getDefinition() == NULL ) { - return true ; + return false ; + } + + // Return false to stop processing if this header file is excluded by one of many reasons. + std::string header_file_name = getFileName(ci , rec->getRBraceLoc(), hsd) ; + char * rp = almostRealPath(header_file_name.c_str()) ; + if ( rp == NULL || + !hsd.isPathInUserDir(rp) || + hsd.isPathInExclude(rp) || + hsd.isPathInICGExclude(rp) || + hsd.isPathInExtLib(rp) || + cs.hasICGNo(header_file_name) ) { + return false ; } // If this class needs a default constructor, then the complier will generate one and we can call it. @@ -152,7 +167,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) { cval.setHasPublicDestructor(true) ; } - cval.setFileName(getFileName(ci , rec->getRBraceLoc(), hsd)) ; + cval.setFileName(header_file_name) ; cval.setAbstract(rec->isAbstract()) ; cval.setName(rec->getNameAsString()) ; cval.setPOD(rec->isPOD()) ; diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 5f7f0904..6d370e2f 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -83,6 +83,7 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e // global set of all units processed. hopefully saves time from reparsing same units strings over and over std::set< std::string > valid_units ; +extern llvm::cl::opt< int > debug_level ; void FieldDescription::parseComment(std::string comment) { std::string ret_str ; @@ -98,7 +99,9 @@ void FieldDescription::parseComment(std::string comment) { return ; } - //std::cout << "comment before " << comment << std::endl ; + if ( debug_level >= 5 ) { + std::cout << "comment before " << comment << std::endl ; + } // remove open comment chars comment = get_regex_field(comment , "^(//|/\\*)(.*)" , 2) ; diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index 1ecd6fe7..ed40ac6c 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -388,6 +388,9 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) { return false ; } } + // If the record type is in std:: but not one we can process, set the I/O spec to zero and return. + fdes->setIO(0) ; + return false ; } /* Template specialization types will be processed here because the canonical type diff --git a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp index 95be4b4e..528441df 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp @@ -36,11 +36,6 @@ void PrintFileContents10::printIOHeader(std::ofstream & outfile , std::string he "#define TRICK_IN_IOSRC\n" "#include \n" "\n" -"/* Redefine private and protected to public. This gives the io_code\n" -" access to anything following an access spec keyword. Classes without access\n" -" keywords are immune to this attack. Yes, it's evil! */\n" -"//#define private public\n" -"//#define protected public\n\n" "#include \"trick/MemoryManager.hh\"\n" "#include \"trick/attributes.h\"\n" "#include \"trick/parameter_types.h\"\n"