mirror of
https://github.com/nasa/trick.git
synced 2025-06-20 08:03:55 +00:00
Add direct STL checkpointing
Removed saving the namespace of a variable it is in the std namespace. Added a check for STLs residing in std::__1 as they do on Macs. refs #206
This commit is contained in:
@ -40,8 +40,11 @@ void ConstructValues::getNamespacesAndClasses( const clang::DeclContext * Ctx )
|
|||||||
if (const clang::NamespaceDecl *nd = clang::dyn_cast<clang::NamespaceDecl>(*I)) {
|
if (const clang::NamespaceDecl *nd = clang::dyn_cast<clang::NamespaceDecl>(*I)) {
|
||||||
if (! nd->isAnonymousNamespace()) {
|
if (! nd->isAnonymousNamespace()) {
|
||||||
//std::cout << "namespace " << nd->getIdentifier()->getName().str() << std::endl ;
|
//std::cout << "namespace " << nd->getIdentifier()->getName().str() << std::endl ;
|
||||||
|
std::string temp_name = nd->getIdentifier()->getName().str() ;
|
||||||
|
if ( temp_name.compare("std") and temp_name.compare("__1")) {
|
||||||
addNamespace(nd->getIdentifier()->getName().str()) ;
|
addNamespace(nd->getIdentifier()->getName().str()) ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (const clang::RecordDecl *rd = clang::dyn_cast<clang::RecordDecl>(*I)) {
|
} else if (const clang::RecordDecl *rd = clang::dyn_cast<clang::RecordDecl>(*I)) {
|
||||||
if (rd->getIdentifier()) {
|
if (rd->getIdentifier()) {
|
||||||
//std::cout << "in class " << rd->getName().str() << std::endl ;
|
//std::cout << "in class " << rd->getName().str() << std::endl ;
|
||||||
|
@ -259,20 +259,6 @@ bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl *
|
|||||||
|
|
||||||
size_t pos ;
|
size_t pos ;
|
||||||
|
|
||||||
/*
|
|
||||||
if ((pos = in_name.find("class ")) != std::string::npos ) {
|
|
||||||
in_name.erase(pos , 6) ;
|
|
||||||
}
|
|
||||||
// clang changes bool to _Bool. We need to change it back
|
|
||||||
if ((pos = in_name.find("<_Bool")) != std::string::npos ) {
|
|
||||||
in_name.replace(pos , 6, "<bool") ;
|
|
||||||
}
|
|
||||||
while ((pos = in_name.find(" _Bool")) != std::string::npos ) {
|
|
||||||
in_name.replace(pos , 6, " bool") ;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// NOTE: clang also changes FILE * to struct _SFILE *. We may need to change that too.
|
|
||||||
|
|
||||||
// Check to see if we've processed this template before
|
// Check to see if we've processed this template before
|
||||||
// If not we need to create attributes for this template
|
// If not we need to create attributes for this template
|
||||||
if ( processed_templates.find(in_name) == processed_templates.end() ) {
|
if ( processed_templates.find(in_name) == processed_templates.end() ) {
|
||||||
@ -320,29 +306,22 @@ static std::map<std::string, bool> init_stl_classes() {
|
|||||||
my_map.insert(std::pair<std::string, bool>("std::set", 1)) ;
|
my_map.insert(std::pair<std::string, bool>("std::set", 1)) ;
|
||||||
my_map.insert(std::pair<std::string, bool>("std::stack", 0)) ;
|
my_map.insert(std::pair<std::string, bool>("std::stack", 0)) ;
|
||||||
my_map.insert(std::pair<std::string, bool>("std::vector", 1)) ;
|
my_map.insert(std::pair<std::string, bool>("std::vector", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::deque", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::list", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::map", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::multiset", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::multimap", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::pair", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::priority_queue", 0)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::queue", 0)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::set", 1)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::stack", 0)) ;
|
||||||
|
my_map.insert(std::pair<std::string, bool>("std::__1::vector", 1)) ;
|
||||||
return my_map ;
|
return my_map ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
|
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// C++ 11 style initialization
|
|
||||||
// list of handled STL types and if they have a clear function.
|
|
||||||
static std::map<std::string, bool> stl_classes = {
|
|
||||||
{"std::deque", 1},
|
|
||||||
{"std::list", 1},
|
|
||||||
{"std::map", 1},
|
|
||||||
{"std::multiset", 1},
|
|
||||||
{"std::multimap", 1},
|
|
||||||
{"std::pair", 0},
|
|
||||||
{"std::priority_queue", 0},
|
|
||||||
{"std::queue", 0},
|
|
||||||
{"std::set", 1},
|
|
||||||
{"std::stack", 0},
|
|
||||||
{"std::vector", 1}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
||||||
if ( debug_level >= 3 ) {
|
if ( debug_level >= 3 ) {
|
||||||
std::cout << "FieldVisitor VisitRecordType" << std::endl ;
|
std::cout << "FieldVisitor VisitRecordType" << std::endl ;
|
||||||
@ -371,13 +350,13 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
|||||||
while ((pos = tst_string.find(" _Bool")) != std::string::npos ) {
|
while ((pos = tst_string.find(" _Bool")) != std::string::npos ) {
|
||||||
tst_string.replace(pos , 6, " bool") ;
|
tst_string.replace(pos , 6, " bool") ;
|
||||||
}
|
}
|
||||||
|
// NOTE: clang also changes FILE * to struct _SFILE *. We may need to change that too.
|
||||||
|
|
||||||
// Test if we have some type from std.
|
// Test if we have some type from std.
|
||||||
if (!tst_string.compare( 0 , 5 , "std::")) {
|
if (!tst_string.compare( 0 , 5 , "std::")) {
|
||||||
// If we have some type from std, figure out if it is one we support.
|
// If we have some type from std, figure out if it is one we support.
|
||||||
for ( std::map<std::string, bool>::iterator it = stl_classes.begin() ; it != stl_classes.end() ; it++ ) {
|
for ( std::map<std::string, bool>::iterator it = stl_classes.begin() ; it != stl_classes.end() ; it++ ) {
|
||||||
/* Mark STL types that are not strings and exit */
|
/* Mark STL types that are not strings and exit */
|
||||||
//if (!tst_string.compare( 0 , 11 , "class std::") or !tst_string.compare( 0 , 12 , "struct std::")) {
|
|
||||||
if (!tst_string.compare( 0 , (*it).first.size() , (*it).first)) {
|
if (!tst_string.compare( 0 , (*it).first.size() , (*it).first)) {
|
||||||
fdes->setEnumString("TRICK_STL") ;
|
fdes->setEnumString("TRICK_STL") ;
|
||||||
fdes->setSTL(true) ;
|
fdes->setSTL(true) ;
|
||||||
|
Reference in New Issue
Block a user