3#include "markLhsValues.h"
5#include "FileUtility.h"
6#include <Sawyer/Message.h>
8#include "AstJSONGeneration.h"
10#include "SgNodeHelper.h"
12#include "Rose/AST/Utility.h"
14#include "sageInterface.h"
15#include "Combinatorics.h"
18#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
19#include "replaceExpressionWithStatement.h"
21#include "constantFolding.h"
28#include "sageBuilder.h"
34#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
37#include "AstInterface_ROSE.h"
38#include "LoopTransformInterface.h"
40#include "DepInfoAnal.h"
41#include "ArrayAnnot.h"
42#include "ArrayInterface.h"
44#include "LoopUnroll.h"
45#include "abstract_handle.h"
46#include "roseAdapter.h"
49#include <boost/lexical_cast.hpp>
50#include <boost/foreach.hpp>
56#include <unordered_map>
58#ifdef ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
66 extern jclass currentJavaTraversalClass;
67 extern JNIEnv *currentEnvironment;
68 extern jmethodID mainMethod;
69 extern jmethodID hasConflictsMethod;
70 extern jmethodID getTempDirectoryMethod;
71 extern jmethodID createTempFileMethod;
72 extern jmethodID createTempNamedFileMethod;
73 extern jmethodID createTempNamedDirectoryMethod;
80using namespace Rose::Frontend::Java::Ecj;
86namespace EDG_ROSE_Translation
89#if defined(ROSE_BUILD_CXX_LANGUAGE_SUPPORT) && !defined(ROSE_USE_CLANG_FRONTEND)
91 extern std::map<std::string, SgIncludeFile*> edg_include_file_map;
94 std::map<std::string, SgIncludeFile*> edg_include_file_map;
101#include "detectMacroOrIncludeFileExpansions.h"
104 template<
class T>
void setSourcePositionToDefault( T* node );
108#ifdef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
109 #include "transformationSupport.h"
113#include "rose_config.h"
119#include "AST_FILE_IO.h"
124#define OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS 1
134typedef std::set<SgLabelStatement*> SgLabelStatementPtrSet;
153 vector<SgBasicBlock*> addedBasicBlockNodes;
170 std::vector<SgNode*> resultlist;
171 void visit (
SgNode* node)
174 ROSE_ASSERT(result != NULL);
176 printf (
"In SageInterface::deleteAllNodes(): result = %p = %s \n",result,result->
class_name().c_str());
181 resultlist.push_back(result);
184 resultlist.push_back(result);
188 virtual ~MyTraversal() {}
192 size_t numberOfNodes_before = numberOfNodes();
194 MyTraversal my_traversal;
198 my_traversal.traverseMemoryPool();
204 vector<SgNode*> & nodeList = my_traversal.resultlist;
206 printf (
"In SageInterface::deleteAllNodes(): get list of SgNode: nodeList.size() = %zu \n",nodeList.size());
208 vector<SgNode*>::iterator i = nodeList.begin();
211 while (i != nodeList.end())
217 printf (
" --- calling delete (and thus the destructor) node = %p = %s \n",node,node->
class_name().c_str());
227 vector<SgFunctionDeclaration*> functionDeclarationList = getSgNodeListFromMemoryPool<SgFunctionDeclaration>();
228 printf (
"In SageInterface::deleteAllNodes(): get list of SgFunctionDeclaration: functionDeclarationList.size() = %zu \n",functionDeclarationList.size());
232 AST_FILE_IO::clearAllMemoryPools();
234 size_t numberOfNodes_after = numberOfNodes();
237 printf (
"Leaving SageInterface::deleteAllNodes(): numberOfNodes_before = %zu numberOfNodes_after = %zu \n",numberOfNodes_before,numberOfNodes_after);
266 void visit (
SgNode* node)
273 resultlist.push_back(result);
276 virtual ~MyTraversal() {}
280 size_t numberOfNodes_before = numberOfNodes();
282 MyTraversal my_traversal;
286 my_traversal.traverseMemoryPool();
295 ASSERT_not_null(decl);
298 printf (
"TOP of SageInterface::DeclarationSets::addDeclaration(): decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
303 if (firstNondefiningDeclaration ==
nullptr)
307 printf (
"WARNING: SageInterface::DeclarationSets::addDeclaration(): firstNondefiningDeclaration == NULL: decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
311 ASSERT_not_null(firstNondefiningDeclaration);
313 if (decl == firstNondefiningDeclaration)
316 if (isSgTypedefDeclaration(decl) !=
nullptr)
318 printf (
"TOP of SageInterface::DeclarationSets::addDeclaration(): decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
321 if (declarationMap.find(firstNondefiningDeclaration) == declarationMap.end())
324 printf (
"In SageInterface::DeclarationSets::addDeclaration(): Add a set for decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
327 if (isSgTypedefDeclaration(decl) !=
nullptr)
329 printf (
"In SageInterface::DeclarationSets::addDeclaration(): Add a set for decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
333 declarationMap[decl] =
new set<SgDeclarationStatement*>();
335 ROSE_ASSERT (declarationMap.find(firstNondefiningDeclaration) != declarationMap.end());
336 ROSE_ASSERT(declarationMap[decl] !=
nullptr);
339 declarationMap[firstNondefiningDeclaration]->insert(decl);
343 if (declarationMap[firstNondefiningDeclaration]->find(decl) == declarationMap[firstNondefiningDeclaration]->end())
346 printf (
"In SageInterface::DeclarationSets::addDeclaration(): Add the declaration to the existing set: decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
349 if (isSgTypedefDeclaration(decl) !=
nullptr)
351 printf (
"In SageInterface::DeclarationSets::addDeclaration(): Add the declaration to the existing set: decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
355 declarationMap[firstNondefiningDeclaration]->insert(decl);
360 printf (
"WARNING: SageInterface::DeclarationSets::addDeclaration(): A set already exists for decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
364 bool ignore_error = (isSgFunctionParameterList(decl) !=
nullptr);
375 bool isInTemplateFunctionDeclaration = enclosingFunction !=
nullptr && (isSgTemplateMemberFunctionDeclaration(enclosingFunction) || isSgTemplateFunctionDeclaration(enclosingFunction));
379 bool isInTemplateClassDefinition = enclosingClassDefinition !=
nullptr && isSgTemplateClassDefinition(enclosingClassDefinition);
381 bool isInTemplateDeclaration = isInTemplateFunctionDeclaration || isInTemplateClassDefinition;
383 ignore_error = ignore_error || (isSgTypedefDeclaration(decl) !=
nullptr) || (isSgTemplateInstantiationDecl(decl) !=
nullptr) || (isInTemplateDeclaration ==
true);
388 if (isSgClassDeclaration(decl) !=
nullptr)
390 ignore_error = ignore_error || (isSgClassDeclaration(decl)->get_isUnNamed() ==
true);
398 if (declarationMap.find(firstNondefiningDeclaration) != declarationMap.end())
401 ROSE_ASSERT (declarationMap[firstNondefiningDeclaration] !=
nullptr);
402 if (declarationMap[firstNondefiningDeclaration]->find(decl) == declarationMap[firstNondefiningDeclaration]->end())
405 declarationMap[firstNondefiningDeclaration]->insert(decl);
410 printf (
"This declaration is already in the set (skip adding it twice): decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
419 printf (
"In SageInterface::DeclarationSets::addDeclaration(): Adding set and declaration for the firstNondefiningDeclaration = %p = %s = %s \n",
420 firstNondefiningDeclaration,firstNondefiningDeclaration->
class_name().c_str(),
get_name(firstNondefiningDeclaration).c_str());
427 declarationMap[firstNondefiningDeclaration] =
new set<SgDeclarationStatement*>();
429 ROSE_ASSERT (declarationMap.find(firstNondefiningDeclaration) != declarationMap.end());
433 declarationMap[firstNondefiningDeclaration]->insert(decl);
436 ROSE_ASSERT(declarationMap[firstNondefiningDeclaration]->find(decl) != declarationMap[firstNondefiningDeclaration]->end());
438 printf (
"SageInterface::DeclarationSets::addDeclaration(): No set exists for the firstNondefiningDeclaration = %p = %s = %s \n",firstNondefiningDeclaration,firstNondefiningDeclaration->
class_name().c_str(),
get_name(firstNondefiningDeclaration).c_str());
445 printf (
"Leaving SageInterface::DeclarationSets::addDeclaration(): decl = %p = %s = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
449const std::set<SgDeclarationStatement*>*
455 ROSE_ASSERT(declarationMap.find(firstNondefiningDeclaration) != declarationMap.end());
457 const set<SgDeclarationStatement*>* declarationSet = declarationMap[firstNondefiningDeclaration];
460 return declarationSet;
463std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > &
464SageInterface::DeclarationSets::getDeclarationMap()
466 return declarationMap;
482#define DEBUG_LOCATED_IN_DEFINING_SCOPE 0
485 ROSE_ASSERT(firstNondefiningDeclaration !=
nullptr);
487 set<SgDeclarationStatement*>* declarationSet = declarationMap[firstNondefiningDeclaration];
488 ROSE_ASSERT(declarationSet !=
nullptr);
490 set<SgDeclarationStatement*>::iterator i = declarationSet->begin();
492 bool isDefinedInNamedScope =
false;
494#if DEBUG_LOCATED_IN_DEFINING_SCOPE
495 printf (
"In DeclarationSets::isLocatedInDefiningScope(): decl = %p = %s \n",decl,decl->
class_name().c_str());
496 printf (
" --- declarationSet->size() = %" PRIuPTR
" \n",declarationSet->size());
499 while (isDefinedInNamedScope ==
false && i != declarationSet->end())
501 ROSE_ASSERT(*i !=
nullptr);
502#if DEBUG_LOCATED_IN_DEFINING_SCOPE
503 printf (
" --- *i = %p = %s \n",*i,(*i)->class_name().c_str());
507 SgScopeStatement* structural_scope = isSgScopeStatement((*i)->get_parent());
509#if DEBUG_LOCATED_IN_DEFINING_SCOPE
510 printf (
" --- semantic_scope = %p = %s \n",semantic_scope,semantic_scope->
class_name().c_str());
511 printf (
" --- structural_scope = %p = %s \n",structural_scope,structural_scope->
class_name().c_str());
514 SgScopeStatement* scope = isSgClassDefinition(semantic_scope) !=
nullptr ? semantic_scope : structural_scope;
515 ASSERT_not_null(scope);
517#if DEBUG_LOCATED_IN_DEFINING_SCOPE
518 printf (
" --- scope = %p = %s \n",scope,scope->
class_name().c_str());
519 printf (
" --- scope->isNamedScope() = %s \n",scope->
isNamedScope() ?
"true" :
"false");
521 SgGlobal* globalScope = isSgGlobal(scope);
524 if (globalScope !=
nullptr || (scope->
isNamedScope() ==
true && isSgClassDefinition(structural_scope) ==
nullptr) )
527 bool willBeOutput = ((*i)->get_file_info()->isCompilerGenerated() ==
false ||
528 ((*i)->get_file_info()->isCompilerGenerated() &&
529 (*i)->get_file_info()->isOutputInCodeGeneration()) );
530#if DEBUG_LOCATED_IN_DEFINING_SCOPE
531 printf (
" --- before: willBeOutput = %s \n",willBeOutput ?
"true" :
"false");
534 willBeOutput = willBeOutput && scope == structural_scope;
536#if DEBUG_LOCATED_IN_DEFINING_SCOPE
537 printf (
" --- after: willBeOutput = %s \n",willBeOutput ?
"true" :
"false");
543 isDefinedInNamedScope = willBeOutput;
549#if DEBUG_LOCATED_IN_DEFINING_SCOPE
550 if (associatedDeclaration !=
nullptr)
552 printf (
"Leaving DeclarationSets::isLocatedInDefiningScope(): associatedDeclaration = %p = %s \n",associatedDeclaration,
associatedDeclaration->
class_name().c_str());
556 printf (
"Leaving DeclarationSets::isLocatedInDefiningScope(): associatedDeclaration = %p \n",associatedDeclaration);
560 return isDefinedInNamedScope;
564SageInterface::buildDeclarationSets(
SgNode* n)
566 DeclarationSets* declarationSet =
new DeclarationSets();
571 DeclarationSets* declarationSet;
574 DeclarationSetTraversal(DeclarationSets* ds) : declarationSet(ds) {}
580 declarationSet->addDeclaration(decl);
586 DeclarationSetTraversal traversal(declarationSet);
587 traversal.traverse(n, preorder);
589 return declarationSet;
596string getVariantName ( VariantT v )
598 ROSE_ASSERT(
int(v) <
int(V_SgNumVariants));
605 extern const char* roseGlobalVariantNameList[];
606 return string(roseGlobalVariantNameList[v]);
613 bool usingTemplateSyntax =
false;
614 string nameString = name.getString();
617 usingTemplateSyntax = (nameString.find(
'<') != string::npos) && (nameString.find(
'>') != string::npos);
621 if (nameString ==
"<unnamed>")
623 printf (
"In SageInterface::hasTemplateSyntax(): Identified case of name == <unnamed> \n");
625 usingTemplateSyntax =
false;
629 return usingTemplateSyntax;
641 ROSE_ASSERT(node != NULL);
645 ROSE_ASSERT(isSgFile(node) == NULL);
646 ROSE_ASSERT(isSgFileList(node) == NULL);
647 ROSE_ASSERT(isSgProject(node) == NULL);
652 while (parent !=
nullptr && isSgFileList(parent) ==
nullptr)
656 printf (
"--- parent = %p = %s \n",parent,parent->
class_name().c_str());
659 parent->
get_file_info()->display(
"In SageInterface::whereAmI() diagnostics support");
686 ifstmt->setCaseInsensitive(
true);
689 if (conditional) conditional->
set_parent(ifstmt);
691 if (false_body) false_body->
set_parent(ifstmt);
698 ROSE_ASSERT(switchStatement != NULL);
702 switchStatement->setCaseInsensitive(
true);
707 if (switchStatement->
get_body() ==
nullptr)
711 if (item_selector !=
nullptr)
721 ROSE_ASSERT(whileStatement);
725 whileStatement->setCaseInsensitive(
true);
729 if (whileStatement->
get_body() ==
nullptr)
733 if (whileStatement->get_else_body() ==
nullptr)
734 whileStatement->set_else_body(else_body);
737 if (condition) condition->
set_parent(whileStatement);
741 if (else_body !=
nullptr)
743 whileStatement->set_else_body(else_body);
764 ROSE_ASSERT(declaration != NULL);
768 while ( isSgNamespaceDefinitionStatement(tempScope) ==
nullptr && isSgGlobal(tempScope) ==
nullptr )
771 ROSE_ASSERT(tempScope != NULL);
778 return namespaceScope;
792 ASSERT_not_null(defn);
796 ASSERT_not_null(templateDeclaration);
802 if (templateInstatiationClassDefinition !=
nullptr)
806 ASSERT_not_null(parentTemplateInstantiationDefinition);
808 ASSERT_not_null(parentTemplateInstantiationDeclaration);
811 ASSERT_not_null(parentDeclaration);
813 else if (cdefn !=
nullptr)
817 ASSERT_not_null(parentDeclaration);
819 else if (nrscope !=
nullptr)
821 parentDeclaration = isSgDeclarationStatement(nrscope->
get_parent());
822 ASSERT_not_null(parentDeclaration);
829 return parentDeclaration;
838 ASSERT_not_null(var_decl);
839 ASSERT_not_null(base_decl);
853 if (find(stmt_list.begin(), stmt_list.end(), base_decl) != stmt_list.end())
858 var_decl->set_baseTypeDefiningDeclaration(base_decl);
864 t1.traverseMemoryPool();
873 bool foundExistingPrototype =
false;
875 ROSE_ASSERT(scope != NULL);
876 ROSE_ASSERT(functionDeclaration != NULL);
877 ROSE_ASSERT(startingAtDeclaration != NULL);
880 if (isSgDeclarationScope(scope)) {
881 printf(
"TODO: SgDeclarationScope handling in SageInterface::isPrototypeInScope see ROSE-1378\n");
892 SgDeclarationStatementPtrList::iterator startingLocation = find(declarationList.begin(),declarationList.end(),startingAtDeclaration);
894 if (startingLocation != declarationList.end())
897 printf (
"startingLocation = %p = %s = %s \n",*startingLocation,(*startingLocation)->class_name().c_str(),
SageInterface::get_name(*startingLocation).c_str());
900 SgDeclarationStatementPtrList::iterator i = startingLocation;
902 SgName targetName = functionDeclaration->get_name();
904 while (i != declarationList.end())
910 if (templateMemberFunction !=
nullptr)
913 if (targetScope == templateMemberFunction->
get_scope())
915 if (targetName == templateMemberFunction->get_name())
918 if (templateMemberFunction->
isForward() ==
true)
920 foundExistingPrototype =
true;
933 return foundExistingPrototype;
939 ROSE_ASSERT(node1 && node2);
949 }
while( (curnode!=
nullptr) && (curnode!=node1));
966#define DEBUG_HAS_SAME_SCOPE 0
968#if DEBUG_HAS_SAME_SCOPE
969 printf (
"In SageInterface::hasSameGlobalScope(): \n");
970 printf (
" --- statement_1 = %p = %s \n",statement_1,statement_1->
class_name().c_str());
971 printf (
" --- statement_2 = %p = %s \n",statement_2,statement_2->
class_name().c_str());
974 bool includingSelf =
true;
975 SgGlobal* global_scope_1 = getEnclosingNode<SgGlobal>(statement_1,includingSelf);
976 SgGlobal* global_scope_2 = getEnclosingNode<SgGlobal>(statement_2,includingSelf);
978#if DEBUG_HAS_SAME_SCOPE
979 printf (
" --- global_scope_1 = %p = %s \n",global_scope_1,global_scope_1->
class_name().c_str());
981 printf (
" --- --- sourcefile_1 = %p filename = %s \n",sourcefile_1,sourcefile_1->
getFileName().c_str());
983 printf (
" --- global_scope_2 = %p = %s \n",global_scope_2,global_scope_2->
class_name().c_str());
985 printf (
" --- --- sourcefile_2 = %p filename = %s \n",sourcefile_2,sourcefile_2->
getFileName().c_str());
988 bool returnResult = (global_scope_1 == global_scope_2);
990#if DEBUG_HAS_SAME_SCOPE
991 printf (
"Leaving SageInterface::hasSameGlobalScope(): returning: %s \n",returnResult ?
"true" :
"false");
1001 std::vector<SgNode*> intersectionSet;
1004 std::vector<SgNode*> AST_original = NodeQuery::querySubTree (original,V_SgNode);
1005 std::vector<SgNode*> AST_copy = NodeQuery::querySubTree (copy,V_SgNode);
1007 int AST_original_size = AST_original.size();
1008 int AST_copy_size = AST_copy.size();
1012 printf (
"Original AST size = %d \n",AST_original_size);
1013 printf (
"Copy of original AST size = %d \n",AST_copy_size);
1016 int differenceInSizes = AST_original_size - AST_copy_size;
1017 if (differenceInSizes == 0)
1020 printf (
"Copied AST is the SAME size as the original (size = %d) \n",AST_original_size);
1024 printf (
"Warning: Copied AST and the original are DIFFERENT sizes (original size = %d copyied size = %d) \n",AST_original_size,AST_copy_size);
1029 std::set<SgNode*> AST_set_original;
1030 for (
int i = 0; i < AST_original_size; i++)
1032 AST_set_original.insert(AST_original[i]);
1035 std::set<SgNode*> AST_set_copy;
1036 for (
int i = 0; i < AST_copy_size; i++)
1038 AST_set_copy.insert(AST_copy[i]);
1041 int size = AST_original_size;
1042 std::vector<SgNode*> intersectionList(size);
1045 std::vector<SgNode*>::iterator end = set_intersection(AST_set_original.begin(),AST_set_original.end(),AST_set_copy.begin(),AST_set_copy.end(),intersectionList.begin());
1048 std::vector<SgNode*> meaningIntersectionList = std::vector<SgNode*>(intersectionList.begin(),end);
1049 std::vector<SgNode*> deleteList;
1050 for (
int i = 0; i < (int)meaningIntersectionList.size(); i++)
1052 if (meaningIntersectionList[i] !=
nullptr && isSgType(meaningIntersectionList[i]) !=
nullptr)
1054 deleteList.push_back(meaningIntersectionList[i]);
1060 printf (
"Remove the types that are allowed to be shared: deleteList.size() = %ld \n",(
long)deleteList.size());
1062 for (std::vector<SgNode*>::iterator i = deleteList.begin(); i != deleteList.end(); i++)
1064 meaningIntersectionList.erase(find(meaningIntersectionList.begin(),meaningIntersectionList.end(),*i));
1068 printf (
"After removing the types there are meaningIntersectionList.size() = %ld \n",(
long)meaningIntersectionList.size());
1070 for (
int i = 0; i < (int)meaningIntersectionList.size(); i++)
1072 printf (
" meaningIntersectionList[%d] = %p = %s = %s \n",i,meaningIntersectionList[i],meaningIntersectionList[i]->class_name().c_str(),
get_name(meaningIntersectionList[i]).c_str());
1075 int unmatchedIRnodes = 0;
1076 if (help !=
nullptr)
1078 std::vector<SgNode*> tmp_AST_original;
1079 std::vector<SgNode*> tmp_AST_copy;
1081 int AST_original_size = AST_original.size();
1082 for (
int j = 0; j < AST_original_size; j++)
1084 if (AST_original[j] != NULL && isSgType(AST_original[j]) == NULL)
1086 tmp_AST_original.push_back(AST_original[j]);
1090 int AST_copy_size = AST_copy.size();
1091 for (
int j = 0; j < AST_copy_size; j++)
1093 if (AST_copy[j] != NULL && isSgType(AST_copy[j]) == NULL)
1095 tmp_AST_copy.push_back(AST_copy[j]);
1099 std::vector<SgNode*> deleteList_original;
1100 std::vector<SgNode*> deleteList_copy;
1101 for (
int j = 0; j < (int)tmp_AST_original.size(); j++)
1104 SgCopyHelp::copiedNodeMapTypeIterator i = help->get_copiedNodeMap().find(tmp_AST_original[j]);
1106 if (i != help->get_copiedNodeMap().end())
1109 SgNode* associated_node_copy = i->second;
1110 ROSE_ASSERT(associated_node_copy != NULL);
1111 deleteList_original.push_back(tmp_AST_original[j]);
1112 deleteList_copy.push_back(associated_node_copy);
1117 if (templateMemberFunction != NULL)
1119 printf (
"In SageInterface::astIntersection(): Found a SgTemplateInstantiationMemberFunctionDecl = %p copy = %p \n",templateMemberFunction,associated_node_copy);
1127 int deleteList_original_size = deleteList_original.size();
1128 for (
int j = 0; j < deleteList_original_size; j++)
1131 std::vector<SgNode*>::iterator k = find(tmp_AST_original.begin(),tmp_AST_original.end(),deleteList_original[j]);
1132 if (k != tmp_AST_original.end())
1134 tmp_AST_original.erase(k);
1139 printf (
"IR nodes different between the original AST and the copy of the AST = %" PRIuPTR
" \n",tmp_AST_original.size());
1141 for (
int j = 0; j < (int)tmp_AST_original.size(); j++)
1143 printf (
"non matched IR node = %p = %s = %s \n",tmp_AST_original[j],tmp_AST_original[j]->class_name().c_str(),
get_name(tmp_AST_original[j]).c_str());
1147 unmatchedIRnodes = (int)tmp_AST_original.size();
1151 if (differenceInSizes != 0)
1153 SgProject* originalProject = isSgProject(original);
1154 if (originalProject != NULL)
1156 printf (
"In %s Copied AST and the original are DIFFERENT sizes (original size = %d copyied size = %d) IR nodes different = %d \n",
1157 (*originalProject)[0]->get_sourceFileNameWithoutPath().c_str(),AST_original_size,AST_copy_size,unmatchedIRnodes);
1160 if (unmatchedIRnodes > 0)
1162 printf (
"Make this an error under stricter testing \n");
1167 return intersectionSet;
1177 ROSE_ASSERT(initializedNameNode != NULL);
1179#define DEBUG_SET_NAME 0
1183 printf (
"In SageInterface::set_name(): initializedNameNode = %p name = %s new_name = %s \n",initializedNameNode,initializedNameNode->get_name().str(),new_name.str());
1190 while((node!=NULL) && ( isSgScopeStatement(node)==NULL))
1193 ROSE_ASSERT(node!=NULL);
1201 if (isSgEnumDeclaration(initializedNameNode->
get_parent()) != NULL)
1203 ROSE_ASSERT(scope_stmt != NULL);
1204 printf (
"scope_stmt = %p = %s \n",scope_stmt,scope_stmt->
class_name().c_str());
1206 printf (
"Detected isSgEnumDeclaration as parent: exiting as a test in SageInterface::set_name() \n");
1211 ROSE_ASSERT(scope_stmt != NULL);
1217 ROSE_ASSERT(parent_declaration != NULL);
1220 std::pair<SgSymbolTable::hash_iterator,SgSymbolTable::hash_iterator> pair_it = scope_stmt->
get_symbol_table()->get_table()->equal_range(initializedNameNode->get_name());
1222 SgSymbolTable::hash_iterator found_it = scope_stmt->
get_symbol_table()->get_table()->end();
1224 for (SgSymbolTable::hash_iterator it = pair_it.first; it != pair_it.second; ++it)
1227 printf (
"Looking for symbol in scope = %p = %s \n",scope_stmt,scope_stmt->
class_name().c_str());
1228 printf (
" --- *it = %p = %s \n",(*it).second,(*it).second->class_name().c_str());
1230 switch(parent_declaration->
variantT())
1232 case V_SgFunctionParameterList:
1233 case V_SgVariableDeclaration:
1235 if (isSgVariableSymbol((*it).second) != NULL)
1240 case V_SgClassDeclaration:
1242 if (isSgClassSymbol((*it).second) != NULL)
1247 case V_SgFunctionDeclaration:
1249 if (isSgFunctionSymbol((*it).second) != NULL)
1255 case V_SgEnumDeclaration:
1257 if (isSgEnumFieldSymbol((*it).second) != NULL)
1264 printf (
"Default reached in switch in SageInterface::set_name() \n");
1272 printf (
"Warning: There is no Variable, Class, Function, or EnumValue symbol associated with p_name \n");
1279 printf (
"WARNING: SageInterface::set_name(): This statement can not be transformed because it is part of a header file specific more then once with different include file syntax \n");
1285 printf (
"In SageInterface::set_name(): This statement can be transformed! parent_declaration = %p = %s \n",parent_declaration,
get_name(parent_declaration).c_str());
1290 printf (
"Exiting as a test! \n");
1295 SgSymbol * associated_symbol = (*found_it).second;
1310 found_it = scope_stmt->
get_symbol_table()->get_table()->insert(pair<SgName,SgSymbol*> ( new_name,associated_symbol));
1312 found_it = scope_stmt->
get_symbol_table()->get_table()->insert(pair<SgName,SgSymbol*> ( new_name,associated_symbol));
1317 printf (
"Warning: insertion of new symbol failed \n");
1323 printf (
"Reset initializedNameNode->get_name() = %s to new_name = %s \n",initializedNameNode->get_name().str(),new_name.str());
1327 initializedNameNode->set_name(new_name);
1332 ROSE_ASSERT(enclosingStatement != NULL);
1348 void visit (
SgNode* node)
1353 ROSE_ASSERT(varRefExp != NULL);
1354 ROSE_ASSERT(variableSymbol != NULL);
1356 if (varRefExp->get_symbol() == variableSymbol)
1359 printf (
"In SageInterface::set_name(): Found associated SgVarRefExp varRefExp = %p to symbol associated_symbol = %p \n",varRefExp,variableSymbol);
1362 printf (
"Exiting as a test! \n");
1373 printf (
"In SageInterface::set_name(): When unparsing header files, we need to set the physical file id to the correct file \n");
1378 ROSE_ASSERT(associatedStatement != NULL);
1384 ROSE_ASSERT(associatedStatement != NULL);
1392 RoseVisitor(
SgSymbol* symbol_parmeter) : counter(0), symbol(symbol_parmeter)
1395 printf (
"roseVisitor::visit: counter %4d node = %s \n",counter,symbol_parmeter->
class_name().c_str());
1403 RoseVisitor t1(associated_symbol);
1408 printf (
"Leaving SageInterface::set_name(): initializedNameNode = %p name = %s new_name = %s (return 1) \n",initializedNameNode,initializedNameNode->get_name().str(),new_name.str());
1420 printf (
"In SageInterface::listHeaderFiles(): includeFile filename = %s \n",includeFile->get_filename().str());
1426 void visit (
SgNode* node)
1428 printf (
"In listHeaderFiles visit(): node = %p = %s \n",node,node->
class_name().c_str());
1430 if (includeFile != NULL)
1432 printf (
"include file: filename = %s \n",includeFile->get_filename().str());
1438 PrefixTraversal traversal;
1439 traversal.traverse(includeFile, preorder);
1458 ROSE_ASSERT(scope != NULL);
1459 int scope_file_id = scope->
get_file_info()->get_physical_file_id();
1461 bool return_value =
false;
1465 SgDeclarationStatementPtrList & declarationStatementList = scope->
getDeclarationList();
1467 printf (
"In scopeHasStatementsFromSameFile(): DeclarationStatementList not implemented \n");
1470 printf (
"declarationStatementList.size() = %zu \n",declarationStatementList.size());
1472 SgDeclarationStatementPtrList::iterator i = declarationStatementList.begin();
1474 while (i != declarationStatementList.end() && return_value ==
false)
1477 int statement_file_id = statement->
get_file_info()->get_physical_file_id();
1479 if (statement_file_id == scope_file_id)
1481 return_value =
true;
1487 printf (
"Exiting as a test! \n");
1495 printf (
"In scopeHasStatementsFromSameFile(): StatementList not implemented \n");
1497 SgStatementPtrList::iterator i = statementList.begin();
1499 while (i != statementList.end() && return_value ==
false)
1502 int statement_file_id = statement->
get_file_info()->get_physical_file_id();
1504 if (statement_file_id == scope_file_id)
1506 return_value =
true;
1513 return return_value;
1519 template <
class SageDecl>
1520 std::string genericGetName(SageDecl* dcl)
1523 return dcl->get_name();
1533 string name =
"undefined_name";
1535 ROSE_ASSERT(directive != NULL);
1544 case V_SgIncludeDirectiveStatement:
1545 case V_SgDefineDirectiveStatement:
1546 case V_SgUndefDirectiveStatement:
1547 case V_SgIfdefDirectiveStatement:
1548 case V_SgIfndefDirectiveStatement:
1549 case V_SgDeadIfDirectiveStatement:
1550 case V_SgIfDirectiveStatement:
1551 case V_SgElseDirectiveStatement:
1552 case V_SgElseifDirectiveStatement:
1553 case V_SgLineDirectiveStatement:
1554 case V_SgWarningDirectiveStatement:
1555 case V_SgErrorDirectiveStatement:
1556 case V_SgEmptyDirectiveStatement:
1563 case V_SgClinkageStartStatement:
1564 case V_SgClinkageEndStatement:
1570 case V_SgFortranIncludeLine:
1578 printf (
"Warning: default case reached in SageInterface::get_name ( const SgC_PreprocessorDirectiveStatement* directive ), directive = %p = %s \n",
1582 name =
"directive_default_name_case_reached_not_handled";
1594 string name =
"undefined_name";
1596 ROSE_ASSERT(declaration != NULL);
1600 if (directive != NULL)
1607 case V_SgTemplateMemberFunctionDeclaration:
1608 name = isSgTemplateMemberFunctionDeclaration(declaration)->get_name().str();
1611 case V_SgTemplateFunctionDeclaration:
1612 name = isSgTemplateFunctionDeclaration(declaration)->get_name().str();
1615 case V_SgTemplateClassDeclaration:
1616 name = isSgTemplateClassDeclaration(declaration)->get_name().str();
1619 case V_SgTemplateDeclaration:
1620 name = isSgTemplateDeclaration(declaration)->
get_name().str();
1623 case V_SgTemplateInstantiationDecl:
1624 name = isSgTemplateInstantiationDecl(declaration)->
get_templateName().str();
1627 case V_SgClassDeclaration:
1628 case V_SgDerivedTypeStatement:
1629 case V_SgJovialTableStatement:
1630 name = isSgClassDeclaration(declaration)->get_name().str();
1635 case V_SgJovialDefineDeclaration:
1636 case V_SgJovialDirectiveStatement:
1637 case V_SgJovialCompoolStatement:
1638 name =
"__" + declaration->
class_name() +
"_";
1642 case V_SgJovialLabelDeclaration:
1643 name = isSgJovialLabelDeclaration(declaration)->get_label();
1646 case V_SgEnumDeclaration:
1647 name = isSgEnumDeclaration(declaration)->
get_name().str();
1651 case V_SgTemplateInstantiationTypedefDeclaration:
1653 case V_SgTemplateTypedefDeclaration:
1654 case V_SgTypedefDeclaration:
1655 name = isSgTypedefDeclaration(declaration)->get_name().str();
1658 case V_SgFunctionDeclaration:
1659 case V_SgProgramHeaderStatement:
1660 case V_SgProcedureHeaderStatement:
1661 case V_SgMemberFunctionDeclaration:
1662 case V_SgTemplateInstantiationFunctionDecl:
1663 case V_SgTemplateInstantiationMemberFunctionDecl:
1664 case V_SgAdaFunctionRenamingDecl:
1665 case V_SgAdaEntryDecl:
1666 name = isSgFunctionDeclaration(declaration)->get_name().str();
1669 case V_SgNamespaceDeclarationStatement:
1670 name = isSgNamespaceDeclarationStatement(declaration)->
get_name().str();
1674 case V_SgFunctionParameterList:
1677 ROSE_ASSERT(declaration->
get_parent() != NULL);
1681 name =
get_name(functionDeclaration);
1689 name +=
"_parameter_list_";
1694 case V_SgTemplateVariableDeclaration:
1697 case V_SgVariableDeclaration:
1701 name =
"_variable_declaration_";
1703 ROSE_ASSERT(variableDeclaration != NULL);
1704 SgInitializedNamePtrList::const_iterator i = variableDeclaration->
get_variables().begin();
1707 ROSE_ASSERT(i != variableDeclaration->
get_variables().end());
1710 name += string((*i)->get_name().str());
1719 case V_SgVariableDefinition:
1723 name =
"_variable_definition_";
1725 ROSE_ASSERT(variableDefinition != NULL);
1728 ROSE_ASSERT(variableDefinition->
get_vardefn() != NULL);
1734 case V_SgPragmaDeclaration:
1736 name =
"_pragma_declaration_";
1738 ROSE_ASSERT(pragmaDeclaration != NULL);
1739 ROSE_ASSERT(pragmaDeclaration->get_pragma() != NULL);
1740 name +=
get_name(pragmaDeclaration->get_pragma());
1745 case V_SgUsingDirectiveStatement:
1747 name =
"_using_directive_statement_";
1749 ROSE_ASSERT(usingDeclaration != NULL);
1756 case V_SgNamespaceAliasDeclarationStatement:
1758 name =
"_namespace_alias_directive_statement_";
1760 ROSE_ASSERT(namespaceAliasDeclaration != NULL);
1761 ROSE_ASSERT(namespaceAliasDeclaration->
get_name().is_null() ==
false);
1762 name += namespaceAliasDeclaration->
get_name();
1767 case V_SgUsingDeclarationStatement:
1769 name =
"_using_declaration_statement_";
1771 ROSE_ASSERT(usingDeclaration != NULL);
1785 case V_SgTemplateInstantiationDirectiveStatement:
1787 name =
"_template_instantiation_directive_statement_";
1788 ROSE_ASSERT(declaration != NULL);
1790 ROSE_ASSERT(templateInstantiationDirective != NULL);
1791 ROSE_ASSERT(templateInstantiationDirective->
get_declaration() != NULL);
1799 case V_SgCtorInitializerList:
1801 name =
"_ctor_list_";
1803 ROSE_ASSERT(ctorDeclaration != NULL);
1804 ROSE_ASSERT(ctorDeclaration->
get_parent() != NULL);
1812 name =
"_asm_stmt_";
1813 const SgAsmStmt* asmStatement = isSgAsmStmt(declaration);
1814 ROSE_ASSERT(asmStatement != NULL);
1815 ROSE_ASSERT(asmStatement->
get_parent() != NULL);
1821 case V_SgImplicitStatement:
1823 name =
"_fortran_implicit_";
1825 ROSE_ASSERT(implicitStatement != NULL);
1826 ROSE_ASSERT(implicitStatement->
get_parent() != NULL);
1832 case V_SgNamelistStatement:
1834 name =
"_fortran_namelist_";
1836 ROSE_ASSERT(namelistStatement != NULL);
1837 ROSE_ASSERT(namelistStatement->
get_parent() != NULL);
1843 case V_SgEquivalenceStatement:
1845 name =
"_fortran_equivalence_";
1847 ROSE_ASSERT(equivalenceStatement != NULL);
1848 ROSE_ASSERT(equivalenceStatement->
get_parent() != NULL);
1855 case V_SgCommonBlock:
1857 name =
"_fortran_common_block_";
1858 const SgCommonBlock* commonBlockStatement = isSgCommonBlock(declaration);
1859 ROSE_ASSERT(commonBlockStatement != NULL);
1860 ROSE_ASSERT(commonBlockStatement->
get_parent() != NULL);
1866 case V_SgImportStatement:
1868 name =
"_fortran_import_stmt_";
1870 ROSE_ASSERT(importStatement != NULL);
1871 ROSE_ASSERT(importStatement->
get_parent() != NULL);
1877 case V_SgFormatStatement:
1879 name =
"_fortran_format_stmt_";
1881 ROSE_ASSERT(formatStatement != NULL);
1882 ROSE_ASSERT(formatStatement->
get_parent() != NULL);
1888 case V_SgModuleStatement:
1890 name =
"_fortran_module_stmt_";
1892 ROSE_ASSERT(moduleStatement != NULL);
1893 ROSE_ASSERT(moduleStatement->
get_parent() != NULL);
1899 case V_SgUseStatement:
1901 name =
"_fortran_use_stmt_";
1902 const SgUseStatement* useStatement = isSgUseStatement(declaration);
1903 ROSE_ASSERT(useStatement != NULL);
1904 ROSE_ASSERT(useStatement->
get_parent() != NULL);
1910 case V_SgContainsStatement:
1912 name =
"_fortran_contains_stmt_";
1914 ROSE_ASSERT(containsStatement != NULL);
1915 ROSE_ASSERT(containsStatement->
get_parent() != NULL);
1921 case V_SgEntryStatement:
1923 name =
"_fortran_entry_stmt_";
1925 ROSE_ASSERT(entryStatement != NULL);
1926 ROSE_ASSERT(entryStatement->
get_parent() != NULL);
1932 case V_SgAttributeSpecificationStatement:
1934 name =
"_fortran_attribute_specification_stmt_";
1936 ROSE_ASSERT(statement != NULL);
1937 ROSE_ASSERT(statement->
get_parent() != NULL);
1942 case V_SgInterfaceStatement:
1944 name =
"_fortran_interface_stmt_";
1946 ROSE_ASSERT(statement != NULL);
1947 ROSE_ASSERT(statement->
get_parent() != NULL);
1952 case V_SgFortranIncludeLine:
1954 name =
"_fortran_include_line_stmt_";
1956 ROSE_ASSERT(statement != NULL);
1957 ROSE_ASSERT(statement->
get_parent() != NULL);
1963 case V_SgJavaImportStatement:
1965 name =
"_java_import_stmt_";
1967 ROSE_ASSERT(statement != NULL);
1968 ROSE_ASSERT(statement->
get_parent() != NULL);
1973 case V_SgJavaPackageDeclaration:
1975 name =
"_java_package_declaration_";
1977 ROSE_ASSERT(package_declaration != NULL);
1978 ROSE_ASSERT(package_declaration->
get_parent() != NULL);
1983 case V_SgJavaPackageStatement:
1985 name =
"_java_package_stmt_";
1987 ROSE_ASSERT(statement != NULL);
1988 ROSE_ASSERT(statement->
get_parent() != NULL);
1994 case V_SgStaticAssertionDeclaration:
1996 name =
"_static_assertion_declaration_stmt_";
1998 ROSE_ASSERT(statement != NULL);
1999 ROSE_ASSERT(statement->
get_parent() != NULL);
2004 case V_SgNonrealDecl:
2006 const SgNonrealDecl * nrdecl = isSgNonrealDecl(declaration);
2007 ROSE_ASSERT(nrdecl != NULL);
2008 name = nrdecl->get_name();
2013 case V_SgEmptyDeclaration:
2016 ROSE_ASSERT(emptyDeclaration != NULL);
2021 case V_SgAdaPackageSpecDecl:
2023 name = genericGetName(isSgAdaPackageSpecDecl(declaration));
2027 case V_SgAdaPackageBodyDecl:
2029 name = genericGetName(isSgAdaPackageBodyDecl(declaration));
2033 case V_SgAdaFormalTypeDecl:
2035 name = genericGetName(isSgAdaFormalTypeDecl(declaration));
2039 case V_SgAdaGenericDecl:
2043 name =
get_name(gendcl->get_declaration());
2046 if (isSgFunctionDeclaration(dcl->get_declaration())) {
2047 name =
"_ada_generic_decl_" + genericGetName(isSgFunctionDeclaration(dcl->get_declaration()));
2050 if (isSgAdaPackageSpecDecl(dcl->get_declaration())) {
2051 name =
"_ada_generic_decl_" + genericGetName(isSgAdaPackageSpecDecl(dcl->get_declaration()));
2061 case V_SgAdaDiscriminatedTypeDecl:
2072 name =
"_incomplete_Ada_discriminated_type_";
2078 case V_SgAdaVariantDecl:
2080 name =
"_ada_variant_decl_";
2084 case V_SgAdaAttributeClause:
2086 name =
"_ada_attribute_clause_";
2090 case V_SgAdaRepresentationClause:
2092 name =
"_ada_representation_clause_";
2096 case V_SgAdaEnumRepresentationClause:
2098 name =
"_ada_enum_representation_clause_";
2102 case V_SgAdaComponentClause:
2104 name =
"_ada_component_clause_";
2108 case V_SgAdaTaskTypeDecl:
2110 name = genericGetName(isSgAdaTaskTypeDecl(declaration));
2114 case V_SgAdaProtectedTypeDecl:
2116 name = genericGetName(isSgAdaProtectedTypeDecl(declaration));
2120 case V_SgAdaTaskBodyDecl:
2122 name = genericGetName(isSgAdaTaskBodyDecl(declaration));
2126 case V_SgAdaProtectedBodyDecl:
2128 name = genericGetName(isSgAdaProtectedBodyDecl(declaration));
2132 case V_SgAdaRenamingDecl:
2134 name = genericGetName(isSgAdaRenamingDecl(declaration));
2138 case V_SgAdaTaskSpecDecl:
2140 name = genericGetName(isSgAdaTaskSpecDecl(declaration));
2144 case V_SgAdaProtectedSpecDecl:
2146 name = genericGetName(isSgAdaProtectedSpecDecl(declaration));
2150 case V_SgAdaGenericInstanceDecl:
2152 name = genericGetName(isSgAdaGenericInstanceDecl(declaration));
2156 case V_SgAdaFormalPackageDecl:
2158 name = genericGetName(isSgAdaFormalPackageDecl(declaration));
2162 case V_SgAdaParameterList:
2167 name = std::accumulate( plst->get_parameters().begin(), plst->get_parameters().end(),
2168 std::string{
"_ada_parameter_list_"},
2171 n += SageInterface::get_name(rhs);
2180 printf (
"Warning: default case reached in SageInterface::get_name ( const SgDeclarationStatement* declaration ), declaration = %p = %s \n",
2181 declaration,declaration->
class_name().c_str());
2191 string name =
"undefined_name";
2193 ROSE_ASSERT(scope != NULL);
2198 case V_SgTemplateClassDefinition:
2199 name =
get_name(isSgTemplateClassDefinition(scope)->get_declaration());
2202 case V_SgClassDefinition:
2203 case V_SgTemplateInstantiationDefn:
2204 name =
get_name(isSgClassDefinition(scope)->get_declaration());
2208 case V_SgTemplateFunctionDefinition:
2209 case V_SgFunctionDefinition:
2210 name =
get_name(isSgFunctionDefinition(scope)->get_declaration());
2213 case V_SgNamespaceDefinitionStatement:
2214 name =
get_name(isSgNamespaceDefinitionStatement(scope)->get_namespaceDeclaration());
2216 case V_SgJavaLabelStatement:
2217 name = (isSgJavaLabelStatement(scope)->get_label()).getString();
2221 case V_SgDeclarationScope:
2224 case V_SgAssociateStatement:
2225 case V_SgJavaForEachStatement:
2227 case V_SgFunctionParameterScope:
2228 case V_SgAdaPackageSpec:
2229 case V_SgAdaPackageBody:
2230 case V_SgAdaTaskSpec:
2231 case V_SgAdaTaskBody:
2232 case V_SgAdaProtectedSpec:
2233 case V_SgAdaProtectedBody:
2234 case V_SgAdaGenericDefn:
2235 case V_SgAdaAcceptStmt:
2236 case V_SgJovialForThenStatement:
2237 case V_SgMatlabForStatement:
2238 case V_SgBasicBlock:
2239 case V_SgCatchOptionStmt:
2240 case V_SgDoWhileStmt:
2241 case V_SgForStatement:
2244 case V_SgSwitchStatement:
2247 case V_SgForAllStatement:
2248 case V_SgRangeBasedForStatement:
2253 printf (
"Error: undefined case (SgScopeStatement) in SageInterface::get_name(): node = %s \n",scope->
class_name().c_str());
2263 string name =
"undefined_name";
2265 ROSE_ASSERT(stmt != NULL);
2268 if (declaration != NULL)
2286 case V_SgCaseOptionStmt:
2287 case V_SgCatchStatementSeq:
2288 case V_SgClinkageStartStatement:
2289 case V_SgContinueStmt:
2290 case V_SgDefaultOptionStmt:
2292 case V_SgForInitStmt:
2293 case V_SgFunctionTypeTable:
2294 case V_SgGotoStatement:
2295 case V_SgReturnStmt:
2301 case V_SgLabelStatement:
2304 name = labelStatement->
get_label().str();
2327 ROSE_ASSERT(node != NULL);
2329 string name =
"undefined_name";
2331 ROSE_ASSERT(node != NULL);
2335 case V_SgInitializedName:
2338 if (initializedName != NULL)
2340 name = initializedName->get_name().str();
2348 name =
"_pragma_string_";
2349 const SgPragma* pragma = isSgPragma(node);
2350 ROSE_ASSERT(pragma != NULL);
2351 name += pragma->get_pragma();
2365 case V_SgSourceFile:
2366#ifdef ROSE_ENABLE_BINARY_ANALYSIS
2367 case V_SgBinaryComposite:
2373 const SgFile* file = isSgFile(node);
2374 ROSE_ASSERT(file != NULL);
2381 case V_SgSymbolTable:
2383 name =
"_symbol_table_";
2388 case V_SgStorageModifier:
2390 name =
"_storage_modifier_";
2396 case V_Sg_File_Info:
2398 name =
"_file_info_";
2403 case V_SgTemplateArgument:
2405 name =
"_template_argument_";
2407 ROSE_ASSERT(templateArgument != NULL);
2413 ROSE_ASSERT(t != NULL);
2427 ROSE_ASSERT(templateArgument->get_initializedName() == NULL);
2432 ROSE_ASSERT(t == NULL);
2434 ROSE_ASSERT(initializedName != NULL);
2445 ROSE_ASSERT(t != NULL);
2452 printf (
"Error: default case reached in switch on templateArgument->get_argumentType() \n");
2461 case V_SgTypeModifier:
2464 ROSE_ASSERT(typeModifier != NULL);
2465 name =
"_type_modifier_" + typeModifier->displayString();
2472 const SgNameGroup* nameGroup = isSgNameGroup(node);
2473 ROSE_ASSERT(nameGroup != NULL);
2474 name =
"_name_group_" + nameGroup->get_group_name();
2479 case V_SgDataStatementGroup:
2482 ROSE_ASSERT(dataGroup != NULL);
2483 name =
"_data_statement_group_";
2488 case V_SgDataStatementObject:
2491 ROSE_ASSERT(dataObject != NULL);
2492 name =
"_data_statement_object_";
2497 case V_SgDataStatementValue:
2500 ROSE_ASSERT(dataValue != NULL);
2501 name =
"_data_statement_value_";
2506 case V_SgCommonBlockObject:
2509 ROSE_ASSERT(commonBlockObject != NULL);
2510 name =
"_common_block_object_" + commonBlockObject->get_block_name();
2515 case V_SgFormatItem:
2518 ROSE_ASSERT(formatItem != NULL);
2519 name =
"_format_item_";
2524 case V_SgFormatItemList:
2527 ROSE_ASSERT(formatItemList != NULL);
2528 name =
"_format_item_list_";
2533 case V_SgRenamePair:
2536 ROSE_ASSERT(renamePair != NULL);
2537 name = renamePair->get_local_name() +
"__" + renamePair->get_use_name() +
"_rename_pair_";
2544 const SgName* name_node = isSgName(node);
2545 ROSE_ASSERT(name_node != NULL);
2546 name =
"_name_" + name_node->getString();
2551 case V_SgTemplateParameter:
2554 ROSE_ASSERT(template_parameter_node != NULL);
2555 name =
"_template_parameter_";
2557 switch(template_parameter_node->get_parameterType())
2561 name +=
"type_parameter_";
2567 name +=
"nontype_parameter_";
2571 if (template_parameter_node->get_expression() != NULL)
2577 ROSE_ASSERT(template_parameter_node->get_initializedName() != NULL);
2583 name += template_parameter_node->get_initializedName()->
unparseToString();
2591 name +=
"template_parameter_";
2597 printf (
"Error: default reached \n");
2607 const SgBaseClass* base_class_node = isSgBaseClass(node);
2608 ROSE_ASSERT(base_class_node != NULL);
2609 ROSE_ASSERT(base_class_node->get_base_class() != NULL);
2614 ROSE_ASSERT(baseClassModifier != NULL);
2615 access = baseClassModifier->displayString();
2617 name =
"_base_class_" + access +
"_" +
get_name(base_class_node->get_base_class());
2623 printf (
"Default reached in switch for SgSupport IR node = %s \n",node->
class_name().c_str());
2624 name =
"default name";
2639 ROSE_ASSERT(symbol != NULL);
2641 string aliasSymbolPrefix =
"";
2642 if (isSgAliasSymbol(symbol) != NULL)
2644 aliasSymbolPrefix =
"_ALIAS";
2651 return symbol->
get_name() + aliasSymbolPrefix +
"_symbol_";
2659 ROSE_ASSERT(type != NULL);
2663 const SgNamedType* namedType = isSgNamedType(type);
2664 if (namedType != NULL)
2666 returnName =
"named_type_";
2667 returnName = namedType->
get_name().getString();
2673 case V_SgPointerType:
2676 returnName =
"pointer_to_";
2677 returnName +=
get_name(pointerType->get_base_type());
2681 case V_SgReferenceType:
2684 returnName =
"reference_to_";
2685 returnName +=
get_name(referenceType->get_base_type());
2691 const SgArrayType* arrayType = isSgArrayType(type);
2692 returnName =
"array_of_";
2693 returnName +=
get_name(arrayType->get_base_type());
2697 case V_SgModifierType:
2701 returnName +=
get_name(modifierType->get_base_type());
2706 case V_SgTemplateType:
2709 returnName =
"templateType_";
2710 returnName += templateType->get_name();
2727 string name =
"undefined_name";
2735 name =
"var_ref_of_";
2736 ROSE_ASSERT(varRef != NULL);
2737 ROSE_ASSERT(varRef->get_symbol() != NULL);
2738 name += varRef->get_symbol()->
get_name();
2743 case V_SgLabelRefExp:
2746 name =
"label_ref_of_";
2747 ROSE_ASSERT(labelRef != NULL);
2748 ROSE_ASSERT(labelRef->get_symbol() != NULL);
2749 name += labelRef->get_symbol()->
get_name();
2753 case V_SgPntrArrRefExp:
2756 name =
"array_ref_of_";
2763 case V_SgFunctionCallExp:
2766 name =
"function_call_";
2767 name +=
get_name(functionCall->get_function());
2771 case V_SgFunctionRefExp:
2774 name =
"function_ref_";
2775 name += functionRefExp->get_symbol()->
get_name();
2780 case V_SgMemberFunctionRefExp:
2783 name =
"member_function_ref_";
2784 name += memberFunctionRefExp->get_symbol()->
get_name();
2790 const SgIntVal* valueExp = isSgIntVal(expr);
2791 name =
"integer_value_exp_";
2798 const SgStringVal* valueExp = isSgStringVal(expr);
2799 name =
"string_value_exp_";
2800 name += valueExp->get_value();
2804 case V_SgSubscriptExpression:
2807 name =
"subscript_exp_";
2809 name +=
get_name(subscriptExpression->get_lowerBound());
2812 name +=
get_name(subscriptExpression->get_upperBound());
2815 name +=
get_name(subscriptExpression->get_stride());
2819 case V_SgNullExpression:
2821 name =
"null_expression";
2826 case V_SgExprListExp:
2829 name =
"expr_list_exp_";
2830 for (
size_t i = 0; i < exprListExp->get_expressions().size(); i++)
2832 name +=
get_name(exprListExp->get_expressions()[i]);
2838 case V_SgActualArgumentExpression:
2841 name =
"actual_arg_exp_name_";
2842 name += actualArgExp->get_argument_name();
2844 name +=
get_name(actualArgExp->get_expression());
2849 case V_SgTemplateParameterVal:
2852 name =
"template_parameter_value_expression_number_";
2862 const SgDotExp* dotExp = isSgDotExp(expr);
2863 ROSE_ASSERT(dotExp != NULL);
2865 name =
"_dot_exp_lhs_";
2867 name +=
"_dot_exp_rhs_";
2876 const SgLambdaExp* lambdaExp = isSgLambdaExp(expr);
2877 ROSE_ASSERT (lambdaExp != NULL);
2878 name =
"lambda_expression_";
2885 const SgThisExp* thisExp = isSgThisExp(expr);
2886 ROSE_ASSERT(thisExp != NULL);
2888 name =
"_this_exp_for_";
2891 ROSE_ASSERT(classSymbol != NULL);
2904 printf (
"Note: default reached in get_name() expr = %p = %s \n",expr,expr->
class_name().c_str());
2923 ROSE_ASSERT(node != NULL);
2929 case V_SgRenamePair:
2932 returnName =
"rename_pair_";
2933 returnName += n->get_local_name().str();
2934 returnName +=
"_from_";
2935 returnName += n->get_use_name().str();
2939 case V_SgInitializedName:
2942 ROSE_ASSERT (n != NULL);
2943 returnName =
"initialized_name_";
2944 returnName += n->get_name().str();
2949 case V_SgLambdaCapture:
2952 ROSE_ASSERT (n != NULL);
2953 returnName =
"lambda_capture_";
2959 case V_SgInterfaceBody:
2962 returnName =
"interface_body";
2982 string name =
"undefined_name";
2984 ROSE_ASSERT(node != NULL);
2987 if (locatedNode != NULL)
2989 const SgStatement* statement = isSgStatement(node);
2990 if (statement != NULL)
2997 if (expression != NULL)
3004 if (locatedNodeSupport != NULL)
3006 name =
get_name(locatedNodeSupport);
3010 const SgToken* token = isSgToken(node);
3017 printf (
"Unknown SgLocatedNode = %p = %s \n",node,node->
class_name().c_str());
3026 const SgSupport* supportNode = isSgSupport(node);
3027 if (supportNode != NULL)
3034 const SgSymbol* symbol = isSgSymbol(node);
3042 const SgType* type = isSgType(node);
3063 string name =
"undefined_name";
3065 ROSE_ASSERT(token != NULL);
3066 name = token->get_lexeme_string();
3071 else if (name ==
"\n")
3073 else if (name ==
"\t")
3115 case V_SgClassDeclaration:
3116 case V_SgTemplateClassDeclaration:
3120 ROSE_ASSERT(classDeclaration != NULL);
3122 string type_name = classDeclaration->get_name();
3124 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier_support(): case class or template type: type_name = %s \n",type_name.c_str());
3126 string className = string(
"scope_") + scope +
"_type_name_" + type_name;
3128 printf (
"classDeclaration->get_scope() = %p = %s scope = %s \n",classDeclaration->
get_scope(),classDeclaration->
get_scope()->
class_name().c_str(),scope.c_str());
3135 case V_SgTemplateInstantiationDecl:
3138 ROSE_ASSERT(templateInstantiationDeclaration != NULL);
3144 string type_name = templateInstantiationDeclaration->get_name();
3146 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier_support(): case SgTemplateInstantiationDecl: type_name = %s \n",type_name.c_str());
3148 string className = string(
"scope_") + scope +
"_type_name_" + type_name;
3163 printf (
"className = %s compressedClassName = %s \n",className.c_str(),compressedClassName.c_str());
3166 printf (
"templateInstantiationDeclaration->get_scope() = %p = %s scope = %s \n",
3170 s = compressedClassName;
3172 printf (
"Exiting as a test! \n");
3178 case V_SgFunctionDeclaration:
3179 case V_SgTemplateFunctionDeclaration:
3180 case V_SgTemplateInstantiationFunctionDecl:
3183 ROSE_ASSERT(functionDeclaration != NULL);
3185 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier_support(): case SgFunctionDeclaration: not implemented \n");
3188 string original_name = functionDeclaration->get_name();
3190 string function_name_part = mangleFunctionName(original_name,
"return_type");
3191 string function_name = string(
"scope_") + scope +
"_function_name_" + function_name_part;
3205 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): Collision count = %d \n",count);
3212 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): case SgFunctionDeclaration: Exiting as a test! \n");
3218 case V_SgMemberFunctionDeclaration:
3219 case V_SgTemplateMemberFunctionDeclaration:
3220 case V_SgTemplateInstantiationMemberFunctionDecl:
3223 ROSE_ASSERT(memberFunctionDeclaration != NULL);
3225 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier_support(): case SgMemberFunctionDeclaration: not implemented \n");
3228 string original_name = memberFunctionDeclaration->get_name();
3234 string member_function_name_part = mangleFunctionName(original_name,
"return_type");
3236 string member_function_name = string(
"scope_") + scope +
"_member_function_name_" + member_function_name_part;
3250 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): Collision count = %d \n",count);
3255 s = member_function_name;
3257 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): case SgMemberFunctionDeclaration: Exiting as a test! \n");
3265 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): Unsupported declaration = %p = %s \n",declaration,declaration->
class_name().c_str());
3271 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): s = %s \n",s.c_str());
3276 printf (
"In SageInterface::generateUniqueNameForUseAsIdentifier(): s = %s \n",s.c_str());
3281 printf (
"Exiting as a test! \n");
3300 printf (
"In generateUniqueNameForUseAsIdentifier(): evaluating declaration = %p = %s \n",declaration,declaration->
class_name().c_str());
3313 if (definingDeclaration != NULL)
3316 printf (
"In generateUniqueName(): Using the defining declaration = %p since %p was not in the map \n",definingDeclaration,declaration);
3324 printf (
"Warning: defining declaration not in SageInterface::local_node_to_name_map: declaration = %p = %s using name = %s \n",
3331 ROSE_ASSERT(nondefiningDeclaration != NULL);
3337 printf (
"Exiting as a test! \n");
3348 ROSE_ASSERT(astNode != NULL);
3358 void visit (
SgNode* node)
3365 if (classDeclaration != NULL || functionDeclaration != NULL)
3376 UniqueNameTraversal traversal;
3377 traversal.traverse(astNode, preorder);
3387 ROSE_ASSERT(classDeclaration != NULL);
3389 ROSE_ASSERT(definingDeclaration != NULL);
3390 SgClassDeclaration* definingClassDeclaration = isSgClassDeclaration(definingDeclaration);
3394 if (definingClassDeclaration != NULL)
3396 SgClassDefinition* classDefinition = definingClassDeclaration->get_definition();
3397 ROSE_ASSERT(classDefinition != NULL);
3399 SgDeclarationStatementPtrList::iterator i = classDefinition->
get_members().begin();
3400 while ( i != classDefinition->
get_members().end() )
3403 ROSE_ASSERT( (*i)->get_parent() != NULL);
3404 ROSE_ASSERT( (*i)->get_parent() == classDefinition);
3407 if (memberFunction != NULL)
3410 if ( memberFunction->get_specialFunctionModifier().isConstructor() ==
true )
3411 defaultConstructor = memberFunction;
3422 return defaultConstructor;
3430 ROSE_ASSERT(classDeclaration != NULL);
3432 if (definingDeclaration != NULL)
3434 ROSE_ASSERT(definingDeclaration != NULL);
3435 SgClassDeclaration* definingClassDeclaration = isSgClassDeclaration(definingDeclaration);
3439 if (definingClassDeclaration != NULL)
3441 SgClassDefinition* classDefinition = definingClassDeclaration->get_definition();
3442 ROSE_ASSERT(classDefinition != NULL);
3444 SgDeclarationStatementPtrList::iterator i = classDefinition->
get_members().begin();
3445 while ( i != classDefinition->
get_members().end() )
3449 ROSE_ASSERT(i_parent != NULL);
3454 if ( i_parent != classDefinition )
3456 printf (
"Error: (*i)->get_parent() = %p = %s \n",i_parent,i_parent->
class_name().c_str());
3457 printf (
"(*i) = %p = %s = %s \n",*i,(*i)->class_name().c_str(),(*i)->unparseToString().c_str());
3458 (*i)->get_file_info()->display(
"Called from SageInterface::getDefaultDestructor: debug");
3460 ROSE_ASSERT( i_parent == classDefinition);
3463 if (memberFunction != NULL)
3465 if ( memberFunction->get_specialFunctionModifier().isDestructor() ==
true )
3466 defaultDestructor = memberFunction;
3475 return defaultDestructor;
3487#define DEBUG_ADD_DEFAULT_CONSTRUCTOR 0
3491 ASSERT_not_null(classType);
3493 bool returnValue =
false;
3496 SgClassDeclaration* classDeclaration = isSgClassDeclaration(classType->get_declaration());
3497 ROSE_ASSERT(classDeclaration != NULL);
3499 ROSE_ASSERT(definingClassDeclaration != NULL);
3500 SgClassDefinition* classDefinition = definingClassDeclaration->get_definition();
3501 ROSE_ASSERT(classDefinition != NULL);
3503 SgDeclarationStatementPtrList & declarationList = classDefinition->
get_members();
3505 bool foundConstructor =
false;
3506 bool foundDefaultConstructor =
false;
3508#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3509 printf (
"In addDefaultConstructorIfRequired(): class name = %s \n",classDeclaration->get_name().str());
3512 SgDeclarationStatementPtrList::iterator i = declarationList.begin();
3513 while (i != declarationList.end())
3516 if (memberFunctionDeclaration != NULL)
3518 bool isConstructor = memberFunctionDeclaration->get_specialFunctionModifier().isConstructor();
3519 if (isConstructor ==
true)
3521 foundConstructor =
true;
3523#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3524 printf (
"Found a constructor! \n");
3527 ROSE_ASSERT(functionParameterList != NULL);
3531 foundDefaultConstructor = ((foundDefaultConstructor ==
true) || (functionParameterList->
get_args().size() == 0));
3533#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3534 if (foundDefaultConstructor ==
true)
3536 printf (
"Found a default constructor! \n");
3540 printf (
"This is not a default constructor: functionParameterList->get_args().size() = %zu \n",functionParameterList->
get_args().size());
3546#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3547 printf (
"This is not a constructor \n");
3555#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3556 printf (
"foundConstructor = %s \n",foundConstructor ?
"true" :
"false");
3557 printf (
"foundDefaultConstructor = %s \n",foundDefaultConstructor ?
"true" :
"false");
3560 if (foundConstructor ==
true)
3563#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3564 printf (
"Since there is at least one constructor, we can't rely on compiler generated constructors \n");
3566 if (foundDefaultConstructor ==
true)
3569#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3570 printf (
"We can use the existing default constructor (no need to build one) \n");
3577#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3578 printf (
"########################################################### \n");
3579 printf (
"Need to build a default constructor in the associated class \n");
3582 ROSE_ASSERT(constructorDeclaration != NULL);
3584#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3585 printf (
" --- constructorDeclaration = %p = %s name = %s \n",constructorDeclaration,constructorDeclaration->
class_name().c_str(),constructorDeclaration->get_name().str());
3587 ROSE_ASSERT (constructorDeclaration->get_declarationModifier().get_accessModifier().isPublic() ==
true);
3589 classDefinition->prepend_statement(constructorDeclaration);
3592 ROSE_ASSERT(constructorDeclaration->
get_parent() != NULL);
3600 constructorDeclaration->
get_endOfConstruct ()->set_physical_file_id(physical_file_id);
3604 ROSE_ASSERT(constructorDeclaration->get_definition() != NULL);
3607 constructorDeclaration->get_definition()->
get_startOfConstruct()->set_physical_file_id(physical_file_id);
3608 constructorDeclaration->get_definition()->
get_endOfConstruct ()->set_physical_file_id(physical_file_id);
3611#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3612 printf (
"DONE: Need to build a default constructor in the associated class \n");
3613 printf (
"################################################################# \n");
3616 printf (
"Exiting as a test! \n");
3625#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3626 printf (
"No constructors found, so we don't need to add an explicit default constructor \n");
3630#if DEBUG_ADD_DEFAULT_CONSTRUCTOR
3631 printf (
"Leaving addDefaultConstructorIfRequired(): returnValue = %s \n",returnValue ?
"true" :
"false");
3663 astTraversal.
traverse(node,preorder);
3673 printf (
"Exiting as a test! \n");
3683 printf (
"Symbol Table from %p = %s at: \n",scope,scope->
sage_class_name());
3684 scope->
get_file_info()->display(
"Symbol Table Location (Called from SageInterface::OutputLocalSymbolTables::visit())");
3686 scope->print_symboltable(
"Called from SageInterface::OutputLocalSymbolTables::visit()");
3701 bool result =
false;
3716 bool result =
false;
3720 if (isTemplateMemberFunction(memberFunctionDeclaration) ==
true)
3723 printf (
"templateDeclaration = %p parent of templateDeclaration = %p \n",templateDeclaration,templateDeclaration->
get_parent());
3726 SgClassDeclaration* classDeclaration = memberFunctionDeclaration->get_class_scope()->get_declaration();
3727 ROSE_ASSERT(classDeclaration != NULL);
3730 if (classTemplateInstantiation != NULL)
3733 if (classTemplateDeclaration != NULL && classTemplateDeclaration != templateDeclaration)
3747 if (templateDeclaration != NULL && templateDeclaration->
get_parent() != NULL)
3750 if (isSgClassDefinition(parentScope) != NULL)
3763 printf (
"Error: This is no longer used. \n");
3776 if (firstNondefiningDeclaration != NULL)
3777 keyDeclaration = firstNondefiningDeclaration;
3779 keyDeclaration = definingDeclaration;
3780 ROSE_ASSERT(keyDeclaration != NULL);
3782 return keyDeclaration;
3788 string pragmaString = pragmaDeclaration->get_pragma()->get_pragma();
3789 istringstream istr(pragmaString);
3799 ROSE_ASSERT (n != NULL);
3800 bool result =
false;
3801 if (isSgOmpBarrierStatement(n)||
3802 isSgOmpBodyStatement(n)||
3803 isSgOmpDeclareSimdStatement(n) ||
3804 isSgOmpFlushStatement(n)||
3805 isSgOmpThreadprivateStatement(n)||
3806 isSgOmpTaskwaitStatement(n) )
3834 if (memberFunctionDeclaration != NULL)
3844 ROSE_ASSERT(scope != NULL);
3847 if (isSgDeclarationScope(scope)) {
3848 printf(
"TODO SageInterface::isOverloaded case when scope is SgDeclarationScope. See ROSE-1378.\n");
3854 isSgClassDefinition(memberFunctionDeclaration->
get_scope());
3855 ROSE_ASSERT(classDefinition != NULL);
3859 ROSE_ASSERT(classDeclaration != NULL);
3862 SgDeclarationStatementPtrList & memberList = classDefinition->
get_members();
3865 printf (
" memberList.size() = %" PRIuPTR
" \n",memberList.size());
3867 for (SgDeclarationStatementPtrList::iterator i = memberList.begin(); i != memberList.end(); i++)
3870 printf (
" counter = %d declaration = %p = %s \n",counter,*i,(*i)->class_name().c_str());
3876 if (tempMemberFunction != NULL)
3881 if ( keyDeclaration == generateUniqueDeclaration(tempMemberFunction) )
3884 printf (
"Skipping the case of keyDeclaration == generateUniqueDeclaration(tempMemberFunction) = %p \n",keyDeclaration);
3889 ROSE_ASSERT(tempMemberFunction->get_name() !=
"");
3891 printf (
" tempMemberFunction = (name) %s = (qualified) %s \n",
3892 tempMemberFunction->get_name().str(),
3893 tempMemberFunction->get_qualified_name().str());
3895 if (tempMemberFunction->get_name() == memberFunctionDeclaration->get_name())
3898 printf (
" Found a matching overloaded member function! \n");
3907 if (tempTemplateDeclaration != NULL)
3913 printf (
"tempTemplateDeclaration->get_name() = %s \n",tempTemplateDeclaration->
get_name().str());
3915 if (memberFunctionDeclaration->get_name() == tempTemplateDeclaration->
get_name())
3918 printf (
" Found a matching overloaded member function! \n");
3927 if (functionDeclaration->
variantT() == V_SgFunctionDeclaration)
3929 printf (
"In SageInterface::isOverloaded(): could friend functions be overloaded in a class? \n");
3942 printf (
"In SageInterface::isOverloaded(): case of non-member function not yet implemented! \n");
3949 return (counter > 1);
3964 ROSE_ASSERT(memberFunctionInstantiation != NULL);
3967 printf (
"buildForwardFunctionDeclaration: Member function = %p = %s = definition = %p \n",
3968 memberFunctionInstantiation,
3969 memberFunctionInstantiation->get_name().str(),
3970 memberFunctionInstantiation->get_definition());
3971 memberFunctionInstantiation->
get_file_info()->display(
"memberFunctionInstantiation: debug");
3977 class NondefiningFunctionDeclarationCopyType :
public SgCopyHelp
3987 SgNode* returnValue = NULL;
3995 case V_SgFunctionDeclaration:
3996 case V_SgMemberFunctionDeclaration:
3997 case V_SgTemplateInstantiationFunctionDecl:
3998 case V_SgTemplateInstantiationMemberFunctionDecl:
4002 ROSE_ASSERT(functionDeclaration != NULL);
4008 returnValue =
const_cast<SgNode *
>(n);
4020 case V_SgFunctionDefinition:
4022 printf (
"Skip copying the function definition if it is present \n");
4024 returnValue =
const_cast<SgNode *
>(n);
4038 if (returnValue == NULL)
4039 returnValue = n->copy(*
this);
4041 ROSE_ASSERT(returnValue != NULL);
4044 } nondefiningFunctionDeclarationCopy;
4049 if (memberFunctionInstantiation->get_definition() != NULL)
4051 printf (
"\n\nNEED TO REMOVE POINTERS IN THE NON-DEFINING DECLARATION TO THE SgClassDefinition objects. \n");
4056 memberFunctionInstantiation->set_definition(NULL);
4058 SgNode* copyOfMemberFunctionNode = memberFunctionInstantiation->copy(nondefiningFunctionDeclarationCopy);
4077 printf (
"copyOfMemberFunction->isForward() = %s \n",copyOfMemberFunction->
isForward() ?
"true" :
"false");
4078 printf (
"memberFunctionInstantiation->isForward() = %s \n",memberFunctionInstantiation->
isForward() ?
"true" :
"false");
4081 printf (
"memberFunctionInstantiation->isSpecialization() = %s \n",memberFunctionInstantiation->isSpecialization() ?
"true" :
"false");
4082 printf (
"copyOfMemberFunctionNode = %p = %s = %s memberFunctionInstantiation->isSpecialization() = %s \n",
4083 copyOfMemberFunction,copyOfMemberFunction->
class_name().c_str(),
SageInterface::get_name(copyOfMemberFunction).c_str(),copyOfMemberFunction->isSpecialization() ?
"true" :
"false");
4084 copyOfMemberFunction->
get_file_info()->display(
"copyOfMemberFunction: debug");
4088 ROSE_ASSERT(memberFunctionInstantiation->get_args().size() == copyOfMemberFunction->get_args().size());
4094 ROSE_ASSERT(copyOfMemberFunction != NULL);
4095 return copyOfMemberFunction;
4104 ROSE_ASSERT(declarationForType != NULL);
4107 switch(declarationForType->
variantT())
4110 case V_SgTemplateInstantiationDecl:
4111 case V_SgTemplateClassDeclaration:
4113 case V_SgClassDeclaration:
4118 if (isSgTemplateClassDeclaration(declarationForType) != NULL)
4127 ROSE_ASSERT(symbol != NULL);
4128 SgName name = classDeclaration->get_name();
4129 symbolTable->insert(name,symbol);
4133 case V_SgEnumDeclaration:
4137 ROSE_ASSERT(symbol != NULL);
4139 symbolTable->insert(name,symbol);
4143 case V_SgFunctionDeclaration:
4147 ROSE_ASSERT(symbol != NULL);
4148 SgName name = functionDeclaration->get_name();
4149 symbolTable->insert(name,symbol);
4153 case V_SgMemberFunctionDeclaration:
4157 ROSE_ASSERT(symbol != NULL);
4161 SgName name = functionDeclaration->get_name();
4162 symbolTable->insert(name,symbol);
4168 printf (
"Default reached in evaluation of typedef inner definition = %p = %s and building a symbol for it for the symbol table \n",declarationForType,declarationForType->
class_name().c_str());
4179 SgInitializedNamePtrList::iterator i = variableList.begin();
4180 while (i != variableList.end())
4184 if (
variable->get_scope() == scope)
4192 printf (
"WARNING: Scopes do NOT match! variable = %p = %s (could this be a static variable, or has the symbol table been setup before the scopes have been set?) \n",
variable,
variable->get_name().str());
4197 ROSE_ASSERT(symbol != NULL);
4199 symbolTable->insert(name,symbol);
4207SageInterface::supportForInitializedNameLists (
SgScopeStatement* scope, SgInitializedNamePtrList & variableList )
4210 ROSE_ASSERT(symbolTable != NULL);
4212 supportForVariableLists(scope,symbolTable,variableList);
4220 SgInitializedNamePtrList & variableList = variableDeclaration->
get_variables();
4221 supportForVariableLists(scope,symbolTable,variableList);
4229 ROSE_ASSERT(symbolTable != NULL);
4240 std::vector<SgNode*> labelList = NodeQuery::querySubTree (scope,V_SgLabelStatement);
4242 int numberOfLabels = labelList.size();
4243 for (
int i=0; i < numberOfLabels; i++)
4247 ROSE_ASSERT(labelStatement != NULL);
4248 ROSE_ASSERT(labelStatement->
get_scope() == scope);
4251 ROSE_ASSERT(symbol != NULL);
4255 SgName name = labelStatement->get_name();
4256 symbolTable->insert(name,symbol);
4266 ROSE_ASSERT(scope != NULL);
4268 printf (
"In SageInterface::rebuildSymbolTable(): Symbol Table from %p = %s \n",scope,scope->
class_name().c_str());
4271 printf (
"Exiting as a test \n");
4277 if (symbolTable != NULL)
4280 if (symbolTable->
size() != 0)
4282 printf (
"symbolTable->size() = %d \n",symbolTable->
size());
4284 ROSE_ASSERT(symbolTable->
size() == 0);
4286 printf (
"Symbol Table from %p = %s of size = %" PRIuPTR
" \n",scope,scope->
class_name().c_str(),symbolTable->
size());
4287 symbolTable->
print(
"Called from SageInterface::rebuildSymbolTable()");
4293 printf (
"In SageInterface::rebuildSymbolTable(): No symbol table found \n");
4295 ROSE_ASSERT(symbolTable == NULL);
4300 ROSE_ASSERT(symbolTable != NULL);
4301 ROSE_ASSERT(symbolTable->get_table() != NULL);
4305 ROSE_ASSERT(symbolTable->
get_parent() != NULL);
4318 case V_SgForStatement:
4325 SgStatementPtrList::iterator i = forStatement->get_init_stmt().begin();
4329 while (i != forStatement->get_init_stmt().end())
4333 if (variableDeclarationInitializer != NULL)
4338 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationInitializer );
4344 SgVariableDeclaration* variableDeclarationCondition = isSgVariableDeclaration(forStatement->get_test());
4345 if (variableDeclarationCondition != NULL)
4350 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationCondition );
4357 case V_SgJovialForThenStatement:
4358 case V_SgMatlabForStatement:
4366 case V_SgTemplateFunctionDefinition:
4368 case V_SgFunctionDefinition:
4375 if (functionDefinition != NULL)
4381 if (functionDeclaration != NULL)
4384 if (functionDeclaration->
isForward() ==
true)
4386 printf (
"ERROR: functionDeclaration = %p = %s = %s \n",functionDeclaration,functionDeclaration->
class_name().c_str(),functionDeclaration->get_name().str());
4387 printf (
" --- functionDeclaration (get_name()) = %s \n",
get_name(functionDeclaration).c_str());
4388 printf (
" --- functionDeclaration (mangled name) = %s \n",functionDeclaration->get_mangled_name().str());
4390 if (memberFunctionDeclaration != NULL)
4392 printf (
"memberFunctionDeclaration != NULL \n");
4395 ROSE_ASSERT(functionDeclaration->
isForward() ==
false);
4396 SgInitializedNamePtrList & argumentList = functionDeclaration->get_args();
4397 supportForVariableLists(scope,symbolTable,argumentList);
4410 supportForLabelStatements(scope,symbolTable);
4421 SgIfStmt* ifStatement = isSgIfStmt(scope);
4423 if (variableDeclarationCondition != NULL)
4428 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationCondition );
4434 case V_SgSwitchStatement:
4441 if (variableDeclarationSelector != NULL)
4446 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationSelector );
4458 SgWhileStmt* whileStatement = isSgWhileStmt(scope);
4460 if (variableDeclarationCondition != NULL)
4466 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationCondition );
4472 case V_SgCatchOptionStmt:
4473 case V_SgDoWhileStmt:
4482 case V_SgTemplateClassDefinition:
4484 case V_SgBasicBlock:
4485 case V_SgClassDefinition:
4486 case V_SgTemplateInstantiationDefn:
4488 case V_SgNamespaceDefinitionStatement:
4496 case V_SgJavaForEachStatement:
4499 SgVariableDeclaration* variableDeclarationCondition = isSgVariableDeclaration(javaForEachStatement->get_element());
4500 if (variableDeclarationCondition != NULL)
4506 supportForVariableDeclarations ( scope, symbolTable, variableDeclarationCondition );
4514 printf (
"Default reached in SageInterface::rebuildSymbolTable() scope = %p = %s \n",scope,scope->
class_name().c_str());
4520 printf (
"In SageInterface::rebuildSymbolTable(): fixup declarations in Symbol Table from %p = %s \n",scope,scope->
class_name().c_str());
4528 for (SgStatementPtrList::iterator i = statementList.begin(); i != statementList.end(); i++)
4535 if (declaration != NULL)
4541 list<SgSymbol*> symbolList;
4544 case V_SgTemplateInstantiationMemberFunctionDecl:
4548 if (scope == derivedDeclaration->
get_scope())
4551 ROSE_ASSERT(symbol != NULL);
4557 SgName name = derivedDeclaration->get_name();
4558 symbolTable->insert(name,symbol);
4569 ROSE_ASSERT(derivedDeclarationScope != NULL);
4576 ROSE_ASSERT(templateDeclaration != NULL);
4584 SgType* functionType = templateDeclaration->get_type();
4585 SgTemplateParameterPtrList & templateParameterList = templateDeclaration->get_templateParameters();
4588 if (templateSymbol != NULL)
4592 printf (
"Building a symbol for derivedDeclaration = %p = %s to an alternative symbol table in derivedDeclarationScope = %p \n",
4593 derivedDeclaration,
get_name(derivedDeclaration).c_str(),derivedDeclarationScope);
4596 ROSE_ASSERT(symbol != NULL);
4597 SgName name = derivedDeclaration->get_name();
4609 case V_SgTemplateMemberFunctionDeclaration:
4611 case V_SgMemberFunctionDeclaration:
4616 if (scope == derivedDeclaration->
get_scope())
4620 if (isSgTemplateFunctionDeclaration(declaration) != NULL)
4625 ROSE_ASSERT(symbol != NULL);
4629 SgName name = derivedDeclaration->get_name();
4630 symbolTable->insert(name,symbol);
4641 case V_SgTemplateInstantiationFunctionDecl:
4645 if (scope == derivedDeclaration->
get_scope())
4648 ROSE_ASSERT(symbol != NULL);
4649 SgName name = derivedDeclaration->get_name();
4650 symbolTable->insert(name,symbol);
4654 if (derivedDeclaration->get_declarationModifier().
isFriend() ==
false)
4656#if PRINT_DEVELOPER_WARNINGS
4657 printf (
"Shouldn't this be a friend declaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4666 case V_SgTemplateFunctionDeclaration:
4668 case V_SgFunctionDeclaration:
4674 if (useThisDeclaration ==
true)
4676 if (scope == derivedDeclaration->
get_scope())
4681 if (isSgTemplateFunctionDeclaration(declaration) != NULL)
4686 ROSE_ASSERT(symbol != NULL);
4687 SgName name = derivedDeclaration->get_name();
4688 symbolTable->insert(name,symbol);
4692 if (derivedDeclaration->get_declarationModifier().
isFriend() ==
false)
4694#if PRINT_DEVELOPER_WARNINGS
4695 printf (
"Shouldn't this be a friend declaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4704 case V_SgTemplateVariableDeclaration:
4706 case V_SgVariableDeclaration:
4709 SgInitializedNamePtrList & variableList = derivedDeclaration->
get_variables();
4710 SgInitializedNamePtrList::iterator i = variableList.begin();
4711 while ( i != variableList.end() )
4717 if (
variable->get_scope() == scope)
4720 ROSE_ASSERT(symbol != NULL);
4725 symbolTable->insert(name,symbol);
4742 ROSE_ASSERT(symbolTable != NULL);
4751 case V_SgTemplateInstantiationDecl:
4758 if (scope == derivedDeclaration->
get_scope())
4762 ROSE_ASSERT(symbol != NULL);
4763 SgName name = derivedDeclaration->get_name();
4766 if (scope != derivedDeclaration->
get_scope())
4768 printf (
"Error: scopes don't match for derivedDeclaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4770 ROSE_ASSERT(scope == derivedDeclaration->
get_scope());
4772 symbolTable->insert(name,symbol);
4778 if (derivedDeclaration->get_declarationModifier().
isFriend() ==
false)
4780#if PRINT_DEVELOPER_WARNINGS
4781 printf (
"Shouldn't this be a friend declaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4787 ROSE_ASSERT(symbol != NULL);
4788 SgName name = derivedDeclaration->get_name();
4789 symbolTable->insert(name,symbol);
4796 case V_SgTemplateClassDeclaration:
4798 case V_SgClassDeclaration:
4802 if (scope == derivedDeclaration->
get_scope())
4805 if (isSgTemplateClassDeclaration(declaration) != NULL)
4810 ROSE_ASSERT(symbol != NULL);
4811 SgName name = derivedDeclaration->get_name();
4812 symbolTable->insert(name,symbol);
4816 if (derivedDeclaration->get_declarationModifier().
isFriend() ==
false)
4818#if PRINT_DEVELOPER_WARNINGS
4819 printf (
"Shouldn't this be a friend declaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4825 ROSE_ASSERT(symbol != NULL);
4826 SgName name = derivedDeclaration->get_name();
4827 symbolTable->insert(name,symbol);
4832 case V_SgEnumDeclaration:
4835 ROSE_ASSERT(derivedDeclaration != NULL);
4837 ROSE_ASSERT(symbol != NULL);
4839 symbolTable->insert(name,symbol);
4842 SgInitializedNamePtrList & enumFieldList = derivedDeclaration->
get_enumerators();
4843 SgInitializedNamePtrList::iterator i = enumFieldList.begin();
4846 while (i != enumFieldList.end())
4849 ROSE_ASSERT(enum_field_symbol != NULL);
4850 SgName enum_field_name = (*i)->get_name();
4851 symbolTable->insert(enum_field_name,enum_field_symbol);
4861 case V_SgTemplateTypedefDeclaration:
4863 case V_SgTypedefDeclaration:
4867 ROSE_ASSERT(symbol != NULL);
4868 SgName name = derivedDeclaration->get_name();
4869 symbolTable->insert(name,symbol);
4871 printf (
"In SageInterface::rebuildSymbolTable(): case of SgTypedefDeclaration \n");
4876 if (derivedDeclaration->get_typedefBaseTypeContainsDefiningDeclaration() ==
true)
4879 ROSE_ASSERT(symbolTable != NULL);
4882 printf (
"In SageInterface::rebuildSymbolTable(): case of SgTypedefDeclaration: typedefBaseTypeContainsDefiningDeclaration == true calling supportForBaseTypeDefiningDeclaration() \n");
4890 if (declaration != NULL)
4893 printf (
"In SageInterface::rebuildSymbolTable(): case of SgTypedefDeclaration: typedefBaseTypeContainsDefiningDeclaration == false calling supportForBaseTypeDefiningDeclaration() \n");
4898 printf (
"In SageInterface::rebuildSymbolTable(): case of SgTypedefDeclaration: typedefBaseTypeContainsDefiningDeclaration == false: skipping call to supportForBaseTypeDefiningDeclaration() \n");
4902 printf (
"In SageInterface::rebuildSymbolTable(): Leaving case of SgTypedefDeclaration \n");
4907 case V_SgTemplateDeclaration:
4913 printf (
"case V_SgTemplateDeclaration: derivedDeclaration = %p \n",derivedDeclaration);
4914 printf (
"case V_SgTemplateDeclaration: derivedDeclaration->get_declarationModifier().isFriend() = %s \n",derivedDeclaration->get_declarationModifier().
isFriend() ?
"true" :
"false");
4915 printf (
"case V_SgTemplateDeclaration: derivedDeclaration->get_name() = %s \n",derivedDeclaration->
get_name().str());
4916 printf (
"case V_SgTemplateDeclaration: derivedDeclaration->get_string() = %s \n",derivedDeclaration->
get_string().str());
4918 if (scope == derivedDeclaration->
get_scope())
4921 ROSE_ASSERT(symbol != NULL);
4923 symbolTable->insert(name,symbol);
4927 if (derivedDeclaration->get_declarationModifier().
isFriend() ==
false)
4929#if PRINT_DEVELOPER_WARNINGS
4930 printf (
"Shouldn't this be a friend declaration = %p = %s \n",derivedDeclaration,derivedDeclaration->
class_name().c_str());
4937 ROSE_ASSERT(symbol != NULL);
4939 symbolTable->insert(name,symbol);
4946 case V_SgNamespaceAliasDeclarationStatement:
4949 ROSE_ASSERT(aliasDeclaration != NULL);
4953 ROSE_ASSERT(derivedDeclaration != NULL);
4957 ROSE_ASSERT(symbol != NULL);
4959 symbolTable->insert(name,symbol);
4967 case V_SgNamespaceDeclarationStatement:
4970 ROSE_ASSERT(derivedDeclaration != NULL);
4974 ROSE_ASSERT(symbol != NULL);
4976 symbolTable->insert(name,symbol);
4982 case V_SgUsingDirectiveStatement:
4983 case V_SgPragmaDeclaration:
4984 case V_SgTemplateInstantiationDirectiveStatement:
4985 case V_SgUsingDeclarationStatement:
4989 printf (
"This declaration is ignored in rebuilding symbol table %p = %s = %s \n",*i,(*i)->class_name().c_str(),
get_name(*i).c_str());
4998 printf (
"An ASM statement (SgAsmStmt) declaration is not really a declaration %p = %s = %s \n",*i,(*i)->class_name().c_str(),
get_name(*i).c_str());
5004 case V_SgVariableDefinition:
5005 case V_SgFunctionParameterList:
5006 case V_SgCtorInitializerList:
5009 printf (
"Special cases not handled %p = %s = %s \n",*i,(*i)->class_name().c_str(),
get_name(*i).c_str());
5013 case V_SgStaticAssertionDeclaration:
5017 printf (
"A static assertion statement (SgStaticAssertionDeclaration) declaration is not really a declaration %p = %s = %s \n",*i,(*i)->class_name().c_str(),
get_name(*i).c_str());
5024 printf (
"Error: Default reached in rebuildSymbolTable declaration = %p = %s \n",declaration,declaration->
class_name().c_str());
5029 ROSE_ASSERT(symbolTable != NULL);
5030 ROSE_ASSERT(symbolTable->get_table() != NULL);
5036 ROSE_ASSERT(symbolTable != NULL);
5037 ROSE_ASSERT(symbolTable->get_table() != NULL);
5040 printf (
"Leaving SageInterface::rebuildSymbolTable(): fixup declarations in Symbol Table from %p = %s \n",scope,scope->
class_name().c_str());
5044 printf (
"Symbol Table from %p = %s at: \n",scope,scope->
class_name().c_str());
5046 symbolTable->
print(
"Called from SageInterface::rebuildSymbolTable()");
5061#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
5062 ROSE_ASSERT(this_scope != NULL);
5063 ROSE_ASSERT(copy_scope != NULL);
5066 printf (
"In fixupReferencesToSymbols(this_scope = %p = %s = %s, copy_scope = %p = %s = %s) \n",
5074 printf (
"Before fixup: this scope = %p = %s this_symbolTable->get_table()->size() = %" PRIuPTR
" \n",this_scope,this_scope->
class_name().c_str(),this_symbolTable->get_table()->size());
5075 printf (
"Before fixup: copy scope = %p = %s copy_symbolTable->get_table()->size() = %" PRIuPTR
" \n",copy_scope,copy_scope->
class_name().c_str(),copy_symbolTable->get_table()->size());
5081 if (this_symbolTable->get_table()->size() != copy_symbolTable->get_table()->size())
5085 printf (
"Before fixup: this scope = %p = %s this_symbolTable->get_table()->size() = %" PRIuPTR
" \n",this_scope,this_scope->
class_name().c_str(),this_symbolTable->get_table()->size());
5086 printf (
"Before fixup: copy scope = %p = %s copy_symbolTable->get_table()->size() = %" PRIuPTR
" \n",copy_scope,copy_scope->
class_name().c_str(),copy_symbolTable->get_table()->size());
5087 printf (
"Warning the symbols tables in these different scopes are different sizes \n");
5092 SgSymbolTable::hash_iterator i = this_symbolTable->get_table()->begin();
5095 std::map<SgNode*, SgNode*> replacementMap;
5097 while (i != this_symbolTable->get_table()->end())
5099 ROSE_ASSERT ( isSgSymbol( (*i).second ) != NULL );
5101 SgName name = (*i).first;
5104 ROSE_ASSERT ( symbol != NULL );
5106 SgSymbol* associated_symbol = NULL;
5108 printf (
"Symbol number: %d (pair.first (SgName) = %s) pair.second (SgSymbol) = %p sage_class_name() = %s \n",counter,i->first.str(),i->second,i->second->class_name().c_str());
5111 SgSymbolTable::hash_iterator associated_symbol_iterator = copy_symbolTable->get_table()->find(name);
5116 while (associated_symbol_iterator != copy_symbolTable->get_table()->end() && associated_symbol_iterator->first == name)
5118 if ( associated_symbol_iterator->second->variantT() == symbol->
variantT() )
5120 associated_symbol = associated_symbol_iterator->second;
5123 associated_symbol_iterator++;
5126 if (associated_symbol != NULL)
5128 ROSE_ASSERT ( associated_symbol != NULL );
5131 ROSE_ASSERT(copy_scope->symbol_exists(associated_symbol) ==
true);
5136 replacementMap.insert(pair<SgNode*,SgNode*>(symbol,associated_symbol));
5143 help.get_copiedNodeMap().insert(pair<const SgNode*,SgNode*>(symbol,associated_symbol));
5150 printf (
"Warning: Symbol number: %d (pair.first (SgName) = %s) pair.second (SgSymbol) = %p sage_class_name() = %s \n",counter,i->first.str(),i->second,i->second->class_name().c_str());
5151 printf (
"Warning: associated_symbol == NULL, need to investigate this (ignoring for now) \n");
5161 printf (
"\n\n************************************************************\n");
5162 printf (
"fixupReferencesToSymbols(this_scope = %p copy_scope = %p = %s = %s): calling Utils::edgePointerReplacement() \n",this_scope,copy_scope,copy_scope->
class_name().c_str(),
get_name(copy_scope).c_str());
5168 printf (
"fixupReferencesToSymbols(): calling Utils::edgePointerReplacement(): DONE \n");
5169 printf (
"************************************************************\n\n");
5171 printf (
"\n\n After replacementMapTraversal(): intermediateDeleteSet: \n");
5172 displaySet(intermediateDeleteSet,
"After Utils::edgePointerReplacement");
5174 printf (
"After fixup: this_symbolTable->get_table()->size() = %" PRIuPTR
" \n",this_symbolTable->get_table()->size());
5175 printf (
"After fixup: copy_symbolTable->get_table()->size() = %" PRIuPTR
" \n",copy_symbolTable->get_table()->size());
5184 printf (
"Exiting as a test in fixupReferencesToSymbols() \n");
5200 vector<SgFile*> fileList;
5201 void visit (
SgNode* node)
5203 SgFile* file = isSgFile(node);
5204 ROSE_ASSERT(file != NULL);
5207 fileList.push_back(file);
5211 virtual ~FileTraversal() {}
5214 FileTraversal fileTraversal;
5219#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5230 return fileTraversal.fileList;
5248 void visit (
SgNode* node)
5250 project = isSgProject(node);
5251 ROSE_ASSERT(project!= NULL);
5253 virtual ~ProjectTraversal() {}
5256 ProjectTraversal projectTraversal;
5258 return projectTraversal.project;
5260 std::vector<SgProject* > resultlist = getSgNodeListFromMemoryPool<SgProject>();
5261 if (resultlist.empty())
5263 ROSE_ASSERT(resultlist.size()==1);
5264 return resultlist[0];
5269 return getEnclosingNode<SgProject>(node,
true );
5274 if (isSgFunctionRefExp(func))
5276 return isSgFunctionRefExp(func)->get_symbol()->get_declaration();
5278 else if (isSgDotExp(func) || isSgArrowExp(func))
5281 if (isSgMemberFunctionRefExp(func2))
5282 return isSgMemberFunctionRefExp(func2)->get_symbol()->get_declaration();
5285 cerr<<
"Warning in SageInterface::getDeclarationOfNamedFunction(): rhs operand of dot or arrow operations is not a member function, but a "<<func2->
class_name()<<endl;
5294 const SgExpressionPtrList& ls = el->get_expressions();
5295 if (ls.empty())
return 0;
5296 if (isSgAssignOp(ls.back()))
return 0;
5303 ASSERT_not_null(astNode);
5304 Rose_STL_Container<SgNode*> arr_exp_list = NodeQuery::querySubTree(astNode,V_SgPntrArrRefExp);
5305 for (
SgNode* expr : arr_exp_list)
5308 ASSERT_not_null(arr_exp);
5309 Rose_STL_Container<SgNode*> refList = NodeQuery::querySubTree(arr_exp->
get_lhs_operand(),V_SgVarRefExp);
5310 for (
SgNode* ref : refList)
5313 ASSERT_not_null(cur_ref);
5315 ASSERT_not_null(sym);
5317 ASSERT_not_null(iname);
5318 SgArrayType * a_type = isSgArrayType(iname->get_typeptr());
5319 if (a_type && a_type->get_dim_info())
5321 Rose_STL_Container<SgNode*> dim_ref_list = NodeQuery::querySubTree(a_type->get_dim_info(),V_SgVarRefExp);
5322 for (Rose_STL_Container<SgNode*>::iterator iter2 = dim_ref_list.begin(); iter2 != dim_ref_list.end(); iter2++)
5325 NodeList_t.push_back(dim_ref);
5335#if (INLINE_OPTIMIZED_IS_LANGUAGE_KIND_FUNCTIONS == 0)
5339#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5341 return Rose::is_Ada_language;
5343 bool returnValue =
false;
5347 int size = (int)fileList.size();
5348 for (
int i = 0; i < size; i++)
5350 if (fileList[i]->get_Ada_only() ==
true)
5361#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5363 return Rose::is_C_language;
5365 bool returnValue =
false;
5369 int size = (int)fileList.size();
5370 for (
int i = 0; i < size; i++)
5372 if (fileList[i]->get_C_only() ==
true)
5383#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5385 return Rose::is_OpenMP_language;
5387 bool returnValue =
false;
5391 int size = (int)fileList.size();
5392 for (
int i = 0; i < size; i++)
5394 if (fileList[i]->get_openmp() ==
true)
5405#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5407 return Rose::is_UPC_language;
5409 bool returnValue =
false;
5413 int size = (int)fileList.size();
5414 for (
int i = 0; i < size; i++)
5416 if (fileList[i]->get_UPC_only() ==
true)
5428#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5430 return Rose::is_CAF_language;
5432 bool returnValue =
false;
5436 int size = (int)fileList.size();
5437 for (
int i = 0; i < size; i++)
5439 if (fileList[i]->get_CoArrayFortran_only()==
true)
5452#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5454 return Rose::is_UPC_dynamic_threads;
5456 bool returnValue =
false;
5460 int size = (int)fileList.size();
5461 for (
int i = 0; i < size; i++)
5463 if (fileList[i]->get_upc_threads() > 0)
5476#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5478 return Rose::is_C99_language;
5480 bool returnValue =
false;
5484 int size = (int)fileList.size();
5485 for (
int i = 0; i < size; i++)
5487 if (fileList[i]->get_C99_only() ==
true)
5498#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5500 return Rose::is_Cxx_language;
5502 bool returnValue =
false;
5506 int size = (int)fileList.size();
5507 for (
int i = 0; i < size; i++)
5510 if (fileList[i]->get_Cxx_only() ==
true)
5512 ROSE_ASSERT(fileList[i]->get_Fortran_only() ==
false && fileList[i]->get_C99_only() ==
false && fileList[i]->get_C_only() ==
false && fileList[i]->get_binary_only() ==
false);
5525#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5527 return Rose::is_Java_language;
5529 bool returnValue =
false;
5533 int size = (int)fileList.size();
5534 for (
int i = 0; i < size; i++)
5536 if (fileList[i]->get_Java_only() ==
true)
5547#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5549 return Rose::is_Jvm_language;
5551 bool returnValue =
false;
5555 int size = (int)fileList.size();
5556 for (
int i = 0; i < size; i++)
5558 if (fileList[i]->get_Jvm_only() ==
true)
5570#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5572 return Rose::is_Jovial_language;
5574 bool returnValue =
false;
5578 int size = (int)fileList.size();
5579 for (
int i = 0; i < size; i++)
5581 if (fileList[i]->get_Jovial_only() ==
true)
5593#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5595 return Rose::is_Fortran_language;
5597 bool returnValue =
false;
5601 int size = (int)fileList.size();
5602 for (
int i = 0; i < size; i++)
5604 if (fileList[i]->get_Fortran_only() ==
true)
5616#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5618 return Rose::is_binary_executable;
5620 bool returnValue =
false;
5624 int size = (int)fileList.size();
5625 for (
int i = 0; i < size; i++)
5627 if (fileList[i]->get_binary_only() ==
true)
5638#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5640 return Rose::is_PHP_language;
5642 bool returnValue =
false;
5646 int size = (int)fileList.size();
5647 for (
int i = 0; i < size; i++)
5649 if (fileList[i]->get_PHP_only() ==
true)
5660#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5662 return Rose::is_Python_language;
5664 bool returnValue =
false;
5668 int size = (int)fileList.size();
5669 for (
int i = 0; i < size; i++)
5671 if (fileList[i]->get_Python_only() ==
true)
5682#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5684 return Rose::is_Cuda_language;
5686 bool returnValue =
false;
5690 int size = (int)fileList.size();
5691 for (
int i = 0; i < size; i++)
5693 if (fileList[i]->get_Cuda_only() ==
true)
5704#if OPTIMIZE_IS_LANGUAGE_KIND_FUNCTIONS
5706 return Rose::is_OpenCL_language;
5708 bool returnValue =
false;
5712 int size = (int)fileList.size();
5713 for (
int i = 0; i < size; i++)
5715 if (fileList[i]->get_OpenCL_only() ==
true)
5763 ASSERT_not_null(functionDefinition);
5764 std::map<SgNode*,int> & scopeMap = functionDefinition->get_scope_number_list();
5767 scopeMap.erase(scopeMap.begin(),scopeMap.end());
5769 ASSERT_require(scopeMap.empty() ==
true);
5770 ASSERT_require(functionDefinition->get_scope_number_list().empty() ==
true);
5780 ROSE_ASSERT(functionDefinition != NULL);
5783 ROSE_ASSERT(functionDefinition->get_scope_number_list().empty() ==
true);
5789 ScopeNumberingTraversal() : count (0), storedFunctionDefinition(NULL) {}
5790 void visit (
SgNode* node)
5797 if (testFunctionDefinition != NULL && storedFunctionDefinition == NULL)
5799 ROSE_ASSERT(storedFunctionDefinition == NULL);
5800 storedFunctionDefinition = testFunctionDefinition;
5804 ROSE_ASSERT(storedFunctionDefinition != NULL);
5808 std::map<SgNode*,int> & scopeMap = storedFunctionDefinition->get_scope_number_list();
5809 scopeMap.insert(pair<SgNode*,int>(scope,count));
5811 string functionName = storedFunctionDefinition->get_declaration()->get_name().str();
5812 printf (
"In function = %s insert scope = %p = %s with count = %d into local map (size = %d) \n",
5813 functionName.c_str(),scope,scope->
class_name().c_str(),count,scopeMap.size());
5824 ScopeNumberingTraversal traversal;
5825 traversal.traverse(functionDefinition, preorder);
5839 ROSE_ASSERT(globalScope != NULL);
5840 std::map<SgNode*,std::string> & mangledNameCache = globalScope->get_mangledNameCache();
5843 mangledNameCache.erase(mangledNameCache.begin(),mangledNameCache.end());
5845 ROSE_ASSERT(mangledNameCache.empty() ==
true);
5846 ROSE_ASSERT(globalScope->get_mangledNameCache().empty() ==
true);
5854 ROSE_ASSERT(globalScope != NULL);
5855 ROSE_ASSERT(globalScope->get_mangledNameCache().empty() ==
true);
5861 MangledNameTraversal() : storedGlobalScope(NULL) {}
5862 void visit (
SgNode* node)
5865 if ( (mangleableNode != NULL) || (isSgGlobal(node) != NULL) )
5868 SgGlobal* testGlobalScope = isSgGlobal(mangleableNode);
5869 if (testGlobalScope != NULL && storedGlobalScope == NULL)
5871 ROSE_ASSERT(storedGlobalScope == NULL);
5872 storedGlobalScope = testGlobalScope;
5876 ROSE_ASSERT(storedGlobalScope != NULL);
5878 string mangledName = mangleableNode->get_mangled_name();
5881 std::map<SgNode*,std::string> & mangledNameCache = storedGlobalScope->get_mangledNameCache();
5882 mangledNameCache.insert(pair<SgNode*,std::string>(mangleableNode,mangledName));
5884 string nodeName =
get_name(mangleableNode);
5885 printf (
"At node = %p = %s = %s in local map (size = %d) \n",
5886 mangleableNode,mangleableNode->
class_name().c_str(),nodeName.c_str(),mangledNameCache.size());
5896 MangledNameTraversal traversal;
5897 traversal.traverse(globalScope, preorder);
5909 SgGlobal* globalScope = isSgGlobal(astNode);
5911 if (globalScope == NULL && isSgFile(astNode) != NULL)
5913 globalScope = isSgFile(astNode)->get_globalScope();
5914 ROSE_ASSERT(globalScope != NULL);
5917 if (globalScope == NULL && isSgProject(astNode) != NULL)
5920 ROSE_ASSERT( isSgProject(astNode)->get_fileList()->size() == 1 );
5921 globalScope = isSgProject(astNode)->get_fileList()->operator[](0)->get_globalScope();
5922 ROSE_ASSERT(globalScope != NULL);
5926 while (temp->
get_parent() != NULL && globalScope == NULL)
5929 globalScope = isSgGlobal(temp);
5931 ROSE_ASSERT(globalScope != NULL);
5938 std::map<SgNode*,std::string>::iterator i = mangledNameCache.find(astNode);
5941 if (i != mangledNameCache.end())
5945 mangledName = i->second;
5956#define DEBUG_SAGE_INTERFACE_ADD_MANGLED_TO_CACHE 0
5957#define DEBUG_MANGLED_SHORTNAME 1
5966#if DEBUG_SAGE_INTERFACE_ADD_MANGLED_TO_CACHE
5967 printf (
"In SageInterface::addMangledNameToCache(): TOP: astNode = %p = %s oldMangledName = %s \n",astNode,astNode->
class_name().c_str(),oldMangledName.c_str());
5971#ifdef DEBUG_MANGLED_SHORTNAME
5972 static std::unordered_map<uint64_t, std::string> mangledNameHashCollisionCheckMap;
5977 SgGlobal* globalScope = isSgGlobal(astNode);
5979 if (globalScope == NULL && isSgFile(astNode) != NULL)
5981 globalScope = isSgFile(astNode)->get_globalScope();
5982 ROSE_ASSERT(globalScope != NULL);
5985 if (globalScope == NULL && isSgProject(astNode) != NULL)
5988 ROSE_ASSERT( isSgProject(astNode)->get_fileList()->size() == 1 );
5989 globalScope = isSgProject(astNode)->get_fileList()->operator[](0)->get_globalScope();
5990 ROSE_ASSERT(globalScope != NULL);
5994 while (temp->
get_parent() != NULL && globalScope == NULL)
5997 globalScope = isSgGlobal(temp);
5999 ROSE_ASSERT(globalScope != NULL);
6004 std::string mangledName;
6006 if (SgProject::get_mangled_noshortname() ==
false) {
6009 if (oldMangledName.size() > 40) {
6010 std::map<std::string, uint64_t>::const_iterator shortMNIter = shortMangledNameCache.find(oldMangledName);
6011 uint64_t idNumber = 0;
6012 if (shortMNIter != shortMangledNameCache.end())
6014 idNumber = shortMNIter->second;
6016#ifdef DEBUG_MANGLED_SHORTNAME
6018 auto collisionIt = mangledNameHashCollisionCheckMap.find(idNumber);
6019 if(collisionIt != mangledNameHashCollisionCheckMap.end() &&
6020 oldMangledName != shortMNIter->first)
6022 mlog[Sawyer::Message::Common::ERROR] <<
" Got a short mangled name collision. \n "<<
6023 oldMangledName <<
" and \n " << shortMNIter->first <<
" \n" <<
6027 mangledNameHashCollisionCheckMap[idNumber] = oldMangledName;
6035 hasher.
insert(oldMangledName);
6038 shortMangledNameCache.insert(std::pair<std::string, uint64_t>(oldMangledName, idNumber));
6041 std::ostringstream mn;
6043 mangledName = mn.str();
6045 mangledName = oldMangledName;
6056 static unsigned long counter = 0;
6060 if (counter++ % 500 == 0)
6062 printf (
"WARNING: In SageInterface::addMangledNameToCache(): Using longer forms of mangled names (can cause some function names with embedded special characters to fail; test2004_141.C) \n");
6064 mangledName = oldMangledName;
6071 printf (
"Updating mangled name cache for node = %p = %s with mangledName = %s \n",astNode,astNode->
class_name().c_str(),mangledName.c_str());
6074#ifdef ROSE_DEBUG_NEW_EDG_ROSE_CONNECTION
6080 printf (
"Warning: SageInterface::addMangledNameToCache(): In it might be premature to add this IR node and name to the mangledNameCache: statement = %p = %s oldMangledName = %s \n",
6081 statement,statement->
class_name().c_str(),oldMangledName.c_str());
6086 mangledNameCache.insert(pair<SgNode*,string>(astNode,mangledName));
6088#if DEBUG_SAGE_INTERFACE_ADD_MANGLED_TO_CACHE
6089 printf (
"In SageInterface::addMangledNameToCache(): returning mangledName = %s \n",mangledName.c_str());
6113 : storedNondefiningDeclaration(nonDefiningDeclaration),
6114 storedDefiningDeclaration(definingDeclaration)
6116 storedDeclarationFound =
false;
6117 nonDefiningDeclarationPreceedsDefiningDeclaration =
false;
6120 void visit (
SgNode* node)
6122 ROSE_ASSERT(storedNondefiningDeclaration != NULL);
6123 ROSE_ASSERT(storedDefiningDeclaration != NULL);
6124 ROSE_ASSERT(storedNondefiningDeclaration != storedDefiningDeclaration);
6132 if ( declaration != NULL )
6134 if (storedDeclarationFound ==
false)
6136 if (declaration == storedDefiningDeclaration)
6138 storedDeclarationFound =
true;
6139 nonDefiningDeclarationPreceedsDefiningDeclaration =
false;
6141 if (declaration == storedNondefiningDeclaration)
6143 storedDeclarationFound =
true;
6144 nonDefiningDeclarationPreceedsDefiningDeclaration =
true;
6151 bool storedDeclarationFound;
6152 bool nonDefiningDeclarationPreceedsDefiningDeclaration;
6159 ROSE_ASSERT(nonDefiningDeclaration != NULL);
6161 printf (
"In SageInterface::declarationPreceedsDefinition(): \n");
6162 printf (
" nondefiningDeclaration = %p = %s \n",nonDefiningDeclaration,nonDefiningDeclaration->
class_name().c_str());
6163 nonDefiningDeclaration->
get_file_info()->display(
"nonDefiningDeclaration");
6164 printf (
" nondefiningDeclaration->get_definingDeclaration() = %p \n",nonDefiningDeclaration->
get_definingDeclaration());
6165 printf (
" definingDeclaration = %p = %s \n",definingDeclaration,definingDeclaration->