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->
class_name().c_str());
6166 definingDeclaration->
get_file_info()->display(
"definingDeclaration");
6167 printf (
"************************************************************* \n");
6174 printf (
"In SageInterface::declarationPreceedsDefinition() (warning): \n");
6175 printf (
" nondefiningDeclaration = %p \n",nonDefiningDeclaration);
6176 printf (
" nondefiningDeclaration->get_definingDeclaration() = %p \n",nonDefiningDeclaration->
get_definingDeclaration());
6177 printf (
" definingDeclaration = %p \n",definingDeclaration);
6182 bool returnResult =
false;
6183 if (nonDefiningDeclaration != definingDeclaration)
6186 SgGlobal* globalScope = TransformationSupport::getGlobalScope(definingDeclaration);
6187 ROSE_ASSERT(globalScope != NULL);
6190 DeclarationOrderTraversal traversal (nonDefiningDeclaration,definingDeclaration);
6193 traversal.traverse(globalScope, preorder);
6196 printf (
"Skipping traversal within SageInterface::declarationPreceedsDefinition() \n");
6197 traversal.storedDeclarationFound =
true;
6198 traversal.nonDefiningDeclarationPreceedsDefiningDeclaration =
false;
6205 if (traversal.storedDeclarationFound ==
false)
6208 printf (
"In SageInterface::declarationPreceedsDefinition(): warning, nonDefiningDeclaration not found in the AST \n");
6209 nonDefiningDeclaration->
get_file_info()->display(
"nonDefiningDeclaration");
6210 definingDeclaration->
get_file_info()->display(
"definingDeclaration");
6211 printf (
"---------------------------------------------------- \n\n");
6215 returnResult =
true;
6219 returnResult = traversal.nonDefiningDeclarationPreceedsDefiningDeclaration;
6225 printf (
"returnResult = %s \n",returnResult ?
"true" :
"false");
6226 printf (
"************************************************************* \n\n");
6228 return returnResult;
6245 : storedFunctionCall(functionCall)
6247 ROSE_ASSERT(functionCall != NULL);
6248 ROSE_ASSERT(functionCall->get_function() != NULL);
6249 SgExpression* functionExpression = functionCall->get_function();
6251 switch (functionExpression->
variantT())
6257 case V_SgArrowStarOp:
6258 case V_SgPointerDerefExp:
6261 printf (
"These are the acceptable cases, but not handled yet... \n");
6265 case V_SgFunctionRefExp:
6268 ROSE_ASSERT(functionRefExp != NULL);
6270 ROSE_ASSERT(functionSymbol != NULL);
6273 ROSE_ASSERT(functionSymbol->get_declaration() != NULL);
6274 storedFunctionDeclaration = functionSymbol->get_declaration();
6278 case V_SgMemberFunctionRefExp:
6281 ROSE_ASSERT(memberFunctionRefExp != NULL);
6283 ROSE_ASSERT(memberFunctionSymbol != NULL);
6285 storedFunctionDeclaration = memberFunctionSymbol->get_declaration();
6287 printf (
"V_SgMemberFunctionRefExp case not handled yet... \n");
6293 printf (
"default reached in SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope() functionExpression = %s \n",
6301 ROSE_ASSERT(storedFunctionDeclaration != NULL);
6303 storedFunctionCallFound =
false;
6307 void visit (
SgNode* node)
6309 ROSE_ASSERT(storedFunctionCall != NULL);
6310 ROSE_ASSERT(storedFunctionDeclaration != NULL);
6313 if (storedFunctionCallFound ==
false)
6316 if ( functionCall != NULL )
6318 if (functionCall == storedFunctionCall)
6320 storedFunctionCallFound =
true;
6330 ROSE_ASSERT(storedFunctionDeclaration != NULL);
6343 storedFunctionCallFound =
true;
6349 printf (
"Found a declaration which preceeds the function \n");
6350 declaration->
get_file_info()->display(
"Found a declaration which preceeds the function: declaration");
6351 storedFunctionCall->get_file_info()->display(
"Found a declaration which preceeds the function: storedFunctionCall");
6352 storedFunctionDeclaration->get_file_info()->display(
"Found a declaration which preceeds the function: storedFunctionDeclaration");
6358 if (parentScopeOfDeclaration == NULL)
6361 printf (
"Strange case of parentScopeOfDeclaration == NULL in SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope() \n");
6363 if (parent != NULL) {
6364 printf (
"declaration->get_parent() = %s \n",parent->
class_name().c_str());
6367 printf (
"declaration->get_parent() = NULL \n");
6369 declaration->
get_file_info()->display(
"case of parentScopeOfDeclaration == NULL");
6378 bool storedFunctionCallFound;
6386 ROSE_ASSERT(functionCall != NULL);
6388 printf (
"In SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope(): \n");
6389 printf (
" storedFunctionCall = %p = %s \n",functionCall,functionCall->
class_name().c_str());
6390 functionCall->
get_file_info()->display(
"storedFunctionCall");
6391 printf (
" storedFunctionCall->get_function() = %p = %s \n",functionCall->get_function(),functionCall->get_function()->
class_name().c_str());
6392 printf (
"************************************************************* \n");
6396 bool returnResult =
false;
6399 SgGlobal* globalScope = TransformationSupport::getGlobalScope(functionCall);
6400 ROSE_ASSERT(globalScope != NULL);
6403 DeclarationOrderTraversal traversal (functionCall);
6406 traversal.traverse(globalScope, preorder);
6409 printf (
"Skipping traversal within SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope() \n");
6410 traversal.storedFunctionCallFound =
true;
6411 traversal.functionCallExpressionPreceedsDeclarationWhichAssociatesScope =
false;
6418 if (traversal.storedFunctionCallFound ==
false)
6421 printf (
"In SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope(): warning, storedFunctionCall not found in the AST \n");
6423 printf (
"---------------------------------------------------- \n\n");
6428 returnResult =
true;
6432 returnResult = traversal.functionCallExpressionPreceedsDeclarationWhichAssociatesScope;
6436 ROSE_ASSERT(traversal.storedFunctionCallFound ==
true);
6438 printf (
"returnResult = %s \n",returnResult ?
"true" :
"false");
6439 printf (
"************************************************************* \n\n");
6441 return returnResult;
6462 ROSE_ASSERT(project != NULL);
6469 Rose_STL_Container<string>::iterator i = fileList.begin();
6472 if ( fileList.empty() ==
true )
6474 return "empty_file_list";
6478 string filename = *i;
6484 if (i != fileList.begin())
6485 projectName +=
"--";
6489 string filenameWithoutSuffix;
6490 if ( i != fileList.end() || supressSuffix ==
true )
6493 filenameWithoutSuffix = filename;
6500 filename = filenameWithoutPathOrSuffix;
6502 unsigned long int n = 0;
6503 while (n < filename.size())
6505 if (filename[n] ==
'/')
6512 projectName += filename;
6516 while (i != fileList.end());
6535 if (currentScope == NULL)
6537 ROSE_ASSERT(currentScope != NULL);
6540 while ((functionSymbol == NULL) && (tempScope != NULL))
6542 functionSymbol = tempScope->lookup_function_symbol(functionName);
6544 printf (
"In lookupFunctionSymbolInParentScopes(): Searching scope = %p = %s functionName = %s functionSymbol = %p \n",tempScope,tempScope->
class_name().c_str(),functionName.str(),functionSymbol);
6547 tempScope = isSgGlobal(tempScope) ? NULL : tempScope->
get_scope();
6551 return functionSymbol;
6562 if (currentScope == NULL)
6564 ROSE_ASSERT(currentScope != NULL);
6567 while ((functionSymbol == NULL) && (tempScope != NULL))
6569 functionSymbol = tempScope->lookup_template_function_symbol(functionName, ftype, tplparams);
6571 printf (
"In lookupTemplateFunctionSymbolInParentScopes(): Searching scope = %p = %s functionName = %s functionSymbol = %p \n",tempScope,tempScope->
class_name().c_str(),functionName.str(),functionSymbol);
6574 tempScope = isSgGlobal(tempScope) ? NULL : tempScope->
get_scope();
6578 return functionSymbol;
6589 if (currentScope == NULL)
6591 ROSE_ASSERT(currentScope != NULL);
6594 while ((functionSymbol == NULL) && (tempScope != NULL))
6596 functionSymbol = tempScope->lookup_template_member_function_symbol(functionName, ftype, tplparams);
6598 printf (
"In lookupTemplateMemberFunctionSymbolInParentScopes(): Searching scope = %p = %s functionName = %s functionSymbol = %p \n",tempScope,tempScope->
class_name().c_str(),functionName.str(),functionSymbol);
6601 tempScope = isSgGlobal(tempScope) ? NULL : tempScope->
get_scope();
6605 return functionSymbol;
6613 if (isSgType(astNode) != NULL)
6615 printf (
"Error: the mechanism to add text to be unparsed at IR nodes is not intended to operate on SgType IR nodes (since they are shared) \n");
6619 if (astNode->
attributeExists(AstUnparseAttribute::markerName) ==
true)
6621 AstUnparseAttribute* code =
dynamic_cast<AstUnparseAttribute*
>(astNode->
getAttribute(AstUnparseAttribute::markerName));
6622 ROSE_ASSERT(code != NULL);
6626 code->addString(s,inputlocation);
6635 AstUnparseAttribute* code =
new AstUnparseAttribute(s,inputlocation);
6636 ROSE_ASSERT(code != NULL);
6653 ROSE_ASSERT(cscope != NULL);
6655 while ((cscope != NULL) && (symbol == NULL))
6658 symbol = cscope->lookup_class_symbol(name,NULL);
6661 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6692 if (currentScope == NULL)
6694 ROSE_ASSERT(currentScope != NULL);
6696 while (functionSymbol == NULL && tempScope != NULL)
6698 functionSymbol = tempScope->lookup_function_symbol(functionName,t);
6700 tempScope = isSgGlobal(tempScope) ? NULL : tempScope->
get_scope();
6701 else tempScope = NULL;
6703 return functionSymbol;
6710 if (cscope ==
nullptr) {
6713 ASSERT_not_null(cscope);
6715 while ((cscope !=
nullptr) && (symbol ==
nullptr))
6717 symbol = cscope->lookup_symbol(name,templateParameterList,templateArgumentList);
6719 cscope = isSgGlobal(cscope) ? nullptr : cscope->
get_scope();
6738 if (currentScope == NULL)
6743 ROSE_ASSERT(currentScope != NULL);
6745#define DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS 0
6747#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS
6748 printf (
"In SageInterface:: lookupSymbolInParentScopesIgnoringAliasSymbols(): currentScope = %p = %s (templateParameterList = %p templateArgumentList = %p) \n",
6749 currentScope,currentScope->
class_name().c_str(),templateParameterList,templateArgumentList);
6752 while ((currentScope != NULL) && (symbol == NULL))
6754#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS
6755 printf(
" --- In SageInterface:: lookupSymbolInParentScopesIgnoringAliasSymbols(): name = %s currentScope = %p = %s \n",
6756 name.str(),currentScope,currentScope->
class_name().c_str());
6761 symbol = currentScope->lookup_symbol(name,templateParameterList,templateArgumentList);
6763 if (isSgAliasSymbol(symbol) != NULL)
6765#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS
6766 printf (
"Found a SgAliasSymbol: reset to NULL: symbol = %p = %s \n",symbol,symbol->
class_name().c_str());
6771#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS && 1
6773 printf(
" --- In SageInterface:: lookupSymbolInParentScopesIgnoringAliasSymbols(): symbol = %p \n",symbol);
6774 currentScope->print_symboltable(
"In SageInterface:: lookupSymbolInParentScopesIgnoringAliasSymbols(): debug");
6777 currentScope = isSgGlobal(currentScope) ? NULL : currentScope->
get_scope();
6779 currentScope = NULL;
6781#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS
6782 printf (
" --- In SageInterface:: (base of loop) lookupSymbolInParentScopesIgnoringAliasSymbols(): cscope = %p symbol = %p \n\n",currentScope,symbol);
6788#if DEBUG_SYMBOL_LOOKUP_IN_PARENT_SCOPES_IGNORING_ALIAS_SYMBOLS
6789 printf (
"Warning: In SageInterface:: lookupSymbolInParentScopesIgnoringAliasSymbols(): could not locate the specified name %s in any outer symbol table (templateParameterList = %p templateArgumentList = %p) \n",
6790 name.str(),templateParameterList,templateArgumentList);
6796 printf (
"Support for lookupSymbolInParentScopesIgnoringAliasSymbols() is not yet implemented \n");
6818 ROSE_ASSERT(cscope);
6820 while ((cscope!=NULL)&&(symbol==NULL))
6822 symbol = cscope->lookup_symbol(name);
6826 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6852 printf (
"WARNING: SageInterface::lookupVariableSymbolInParentScopes() should be implemented similar to SageInterface::lookupClassSymbolInParentScopes() \n");
6858 if (isSgAliasSymbol(symbol) != NULL)
6860 printf (
"Error: This SageInterface::lookupVariableSymbolInParentScopes() function does not handle SgAliasSymbols \n");
6863 result = isSgVariableSymbol(symbol);
6871 ROSE_ASSERT(cscope != NULL);
6873 while ((cscope != NULL) && (symbol == NULL))
6876 symbol = cscope->lookup_variable_symbol(name);
6879 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6888#define DEBUG_LOOKUP_TEMPLATE_VARIABLE 0
6893#if DEBUG_LOOKUP_TEMPLATE_VARIABLE
6894 printf (
"In SageInterface::lookupTemplateVariableSymbolInParentScopes():\n");
6895 printf (
" -- name = %s\n", name.str());
6896 printf (
" -- tplparams = %p [%zd]\n", tplparams, tplparams ? tplparams->size() : 0);
6897 printf (
" -- tplargs = %p [%zd]\n", tplargs, tplargs ? tplargs->size() : 0);
6898 printf (
" -- cscope = %p (%s)\n", cscope, cscope ? cscope->
class_name().c_str() :
"");
6904 ROSE_ASSERT(cscope != NULL);
6906 while ((cscope != NULL) && (symbol == NULL))
6909 symbol = cscope->lookup_template_variable_symbol(name, tplparams, tplargs);
6912 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6928 ROSE_ASSERT(cscope != NULL);
6930 while ((cscope != NULL) && (symbol == NULL))
6934 symbol = cscope->lookup_class_symbol(name,templateArgumentList);
6937 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6951 ROSE_ASSERT(cscope != NULL);
6953 while ((cscope != NULL) && (symbol == NULL))
6955 symbol = cscope->lookup_nonreal_symbol(name,templateParameterList,templateArgumentList);
6958 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6973 ROSE_ASSERT(cscope != NULL);
6976 printf (
"In lookupTypedefSymbolInParentScopes(): name = %s starting with cscope = %p = %s \n",name.str(),cscope,cscope->
class_name().c_str());
6980 while ((cscope != NULL) && (symbol == NULL))
6983 symbol = cscope->lookup_typedef_symbol(name);
6986 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
6991 printf (
"In lookupTypedefSymbolInParentScopes(): symbol = %p next cscope = %p = %s \n",symbol,cscope,(cscope != NULL) ? cscope->
class_name().c_str() :
"null");
6996 printf (
"Leaving lookupTypedefSymbolInParentScopes(): symbol = %p \n",symbol);
7014 ROSE_ASSERT(cscope != NULL);
7016 while ((cscope != NULL) && (symbol == NULL))
7022 symbol = cscope->lookup_template_symbol(name,NULL,NULL);
7024 printf (
"In lookupTemplateSymbolInParentScopes(): Searching scope = %p = %s name = %s symbol = %p \n",cscope,cscope->
class_name().c_str(),name.str(),symbol);
7027 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
7044 ROSE_ASSERT(cscope != NULL);
7046 while ((cscope != NULL) && (symbol == NULL))
7052 symbol = cscope->lookup_template_class_symbol(name,templateParameterList,templateArgumentList);
7054 printf (
"In lookupTemplateSymbolInParentScopes(): Searching scope = %p = %s name = %s symbol = %p \n",cscope,cscope->
class_name().c_str(),name.str(),symbol);
7057 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
7074 ROSE_ASSERT(cscope != NULL);
7076 while ((cscope != NULL) && (symbol == NULL))
7079 symbol = cscope->lookup_enum_symbol(name);
7082 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
7097 ROSE_ASSERT(cscope != NULL);
7099 while ((cscope != NULL) && (symbol == NULL))
7102 symbol = cscope->lookup_namespace_symbol(name);
7105 cscope = isSgGlobal(cscope) ? NULL : cscope->
get_scope();
7115SageInterface::setSourcePositionToDefault( T* node )
7133 ROSE_ASSERT(node != NULL);
7136 if (node->get_endOfConstruct() == NULL && node->get_startOfConstruct() == NULL)
7139 printf (
"Both startOfConstruct and endOfConstruct are NOT yet initialized with pointers to Sg_File_Info objects (node = %p = %s) \n",node,node->class_name().c_str());
7142 ROSE_ASSERT(node->get_endOfConstruct() == NULL);
7143 ROSE_ASSERT(node->get_startOfConstruct() == NULL);
7150 printf (
"In SageInterface::setSourcePositionToDefault(): Calling setSourcePositionUnavailableInFrontend() \n");
7152 start_fileInfo->setSourcePositionUnavailableInFrontend();
7153 end_fileInfo->setSourcePositionUnavailableInFrontend();
7157 printf (
"In SageInterface::setSourcePositionToDefault(): Calling setOutputInCodeGeneration() \n");
7163 node->set_startOfConstruct(start_fileInfo);
7164 node->set_endOfConstruct (end_fileInfo);
7166 node->get_startOfConstruct()->set_parent(node);
7167 node->get_endOfConstruct ()->set_parent(node);
7174 printf (
"Both startOfConstruct and endOfConstruct are ALREADY initialized with pointers to Sg_File_Info objects (node = %p = %s) \n",node,node->class_name().c_str());
7176 if (node->get_startOfConstruct() == NULL)
7178 printf (
"ERROR: startOfConstruct not set for locatedNode = %p = %s \n",node,node->class_name().c_str());
7180 if (node->get_endOfConstruct() == NULL)
7182 printf (
"ERROR: endOfConstruct not set for locatedNode = %p = %s \n",node,node->class_name().c_str());
7185 ROSE_ASSERT(node->get_startOfConstruct() != NULL);
7186 ROSE_ASSERT(node->get_endOfConstruct() != NULL);
7187 ROSE_ASSERT(node->get_endOfConstruct() != NULL && node->get_startOfConstruct() != NULL);
7208 if (expression != NULL)
7211 SgBinaryOp* binaryOp = isSgBinaryOp(expression);
7212 if (binaryOp != NULL)
7214 if (binaryOp->get_operatorPosition() == NULL)
7217 operator_fileInfo->setSourcePositionUnavailableInFrontend();
7219 binaryOp->set_operatorPosition(operator_fileInfo);
7222 binaryOp->get_operatorPosition()->
set_parent(binaryOp);
7227 if (expression->get_operatorPosition() == NULL)
7230 operator_fileInfo->setSourcePositionUnavailableInFrontend();
7232 expression->set_operatorPosition(operator_fileInfo);
7237 ROSE_ASSERT(expression->get_operatorPosition()->
get_parent() == expression);
7248#ifdef ROSE_DEBUG_NEW_EDG_ROSE_CONNECTION
7249 printf (
"+++++ Depricated function (use setSourcePositionAsTransformation() instead) (no using internal source position mode) \n");
7268 ROSE_ASSERT(node != NULL);
7277 SgPragma* pragma = isSgPragma(node);
7278 SgGlobal* global = isSgGlobal(node);
7283 printf (
"Debug, Found a variable definition: %p\n", v_d);
7286 if (locatedNode != NULL)
7298 if (expression!=NULL)
7301 expression->get_operatorPosition()->
set_parent(expression);
7320 printf (
"+++++ Depricated name setOneSourcePositionNull() (use setSourcePositionPointersToNull() instead) (no using internal source position mode) \n");
7338 ROSE_ASSERT(node != NULL);
7342 SgPragma* pragma = isSgPragma(node);
7343 SgGlobal* global = isSgGlobal(node);
7349 if (locatedNode != NULL)
7352 printf (
"WARNING: In SageInterface::setSourcePositionPointersToNull(): Memory leak of startOfConstruct Sg_File_Info object (setting Sg_File_Info pointers to NULL) \n");
7360 printf (
"WARNING: In SageInterface::setSourcePositionPointersToNull(): Memory leak of endOfConstruct Sg_File_Info object (setting Sg_File_Info pointers to NULL) \n");
7366 if (expression != NULL)
7368 if (expression->get_operatorPosition() != NULL)
7369 printf (
"WARNING: In SageInterface::setSourcePositionPointersToNull(): Memory leak of operatorPosition Sg_File_Info object (setting Sg_File_Info pointers to NULL) \n");
7371 expression->set_operatorPosition(NULL);
7378 printf (
"WARNING: In SageInterface::setSourcePositionPointersToNull(): Memory leak of Sg_File_Info object (setting Sg_File_Info pointers to NULL) \n");
7380 pragma->set_startOfConstruct(NULL);
7391 printf (
"+++++ Depricated name setSourcePositionForTransformation() (use setSourcePositionAtRootAndAllChildrenAsTransformation() instead) \n");
7404 Rose_STL_Container <SgNode*> nodeList = NodeQuery::querySubTree(root,V_SgNode);
7405 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i!=nodeList.end(); i++ )
7416SageInterface::setSourcePositionAtRootAndAllChildrenAsTransformation(
SgNode *root)
7418 Rose_STL_Container <SgNode*> nodeList= NodeQuery::querySubTree(root,V_SgNode);
7419 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i!=nodeList.end(); i++ )
7428SageInterface::setSourcePositionAtRootAndAllChildrenAsDefault(
SgNode *root)
7430 Rose_STL_Container <SgNode*> nodeList= NodeQuery::querySubTree(root,V_SgNode);
7431 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i!=nodeList.end(); i++ )
7433 setSourcePositionAsDefault(*i);
7443 Rose_STL_Container <SgNode*> nodeList = NodeQuery::querySubTree(root,V_SgNode);
7446 printf (
"In setSourcePositionAtRootAndAllChildren(): nodeList.size() = %" PRIuPTR
" \n",nodeList.size());
7449 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
7452 printf (
"In setSourcePositionAtRootAndAllChildren(): *i = %p = %s \n",*i,(*i)->class_name().c_str());
7471 printf (
"In SageInterface::setSourcePosition(): SourcePositionClassification scp = %s \n",
display(scp).c_str());
7476 case e_sourcePositionError:
7478 printf (
"Error: error value e_sourcePositionError in SageInterface::setSourcePosition() \n");
7485 printf (
"e_sourcePositionDefault in SageInterface::setSourcePosition() \n");
7488 if (locatedNode != NULL)
7490 setSourcePositionToDefault(locatedNode);
7495 printf (
"Error: can't call setSourcePosition() in mode e_sourcePositionDefault with non SgLocatedNode (node = %p = %s) \n",node,node->
class_name().c_str());
7504 printf (
"e_sourcePositionTransformation in SageInterface::setSourcePosition() \n");
7513 printf (
"e_sourcePositionCompilerGenerated in SageInterface::setSourcePosition() \n");
7515 printf (
"Sorry, not implemented \n");
7524 printf (
"e_sourcePositionNullPointers in SageInterface::setSourcePosition() \n");
7541 printf (
"e_sourcePositionFrontendConstruction in SageInterface::setSourcePosition() \n");
7544 if (locatedNode != NULL)
7547 setSourcePositionToDefault(locatedNode);
7552 SgPragma* pragma = isSgPragma(node);
7555 setSourcePositionToDefault(pragma);
7561 SgType* type = isSgType(node);
7569 if (functionParameterTypeList != NULL)
7575 printf (
"Error: can't call setSourcePosition() in mode e_sourcePositionFrontendConstruction with non SgLocatedNode (node = %p = %s) \n",node,node->
class_name().c_str());
7588 printf (
"Error: error value e_sourcePositionError in SageInterface::setSourcePosition() \n");
7594 printf (
"Error: default reached in SageInterface::setSourcePosition() \n");
7602 node->
get_file_info()->display(
"Leaving SageInterface::setSourcePosition()");
7609SageInterface::setSourcePositionForTransformation_memoryPool()
7614 printf (
"ERROR: In setSourcePositionForTransformation_memoryPool(): This seems like a very dangerous function to have, is it required? \n");
7617 VariantVector vv(V_SgNode);
7618 Rose_STL_Container<SgNode*> nodeList = NodeQuery::queryMemoryPool(vv);
7619 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++ )
7630 ROSE_ASSERT(project != NULL);
7633 ROSE_ASSERT(project->get_fileList().empty() ==
false);
7636 SgSourceFile* file = isSgSourceFile(project->get_fileList()[0]);
7637 SgGlobal* global = file->get_globalScope();
7640 SgFilePtrListPtr fileList = project->get_fileList();
7641 SgFilePtrList::const_iterator i= fileList->begin();
7643 SgGlobal* global = (*i)->get_globalScope();
7645 ROSE_ASSERT(global != NULL);
7666 if (declList.empty() ==
false)
7668 stmt = isSgStatement(declList.back());
7677 if (stmtList.empty() ==
false)
7679 stmt = stmtList.back();
7701 if (includingCompilerGenerated)
7705 if (declList.empty() ==
false)
7707 stmt = isSgStatement(declList.front());
7713 SgDeclarationStatementPtrList::iterator i=declList.begin();
7714 while (i != declList.end())
7741 if (includingCompilerGenerated)
7745 if (stmtList.empty() ==
false)
7747 stmt = stmtList.front();
7753 SgStatementPtrList::iterator i = stmtList.begin();
7754 while (i!=stmtList.end())
7789 SgDeclarationStatementPtrList::iterator i=declList.begin();
7790 while (i!=declList.end())
7814 SgStatementPtrList::iterator i=stmtList.begin();
7815 while (i!=stmtList.end())
7842 bool result =
false;
7845 if (isSgProgramHeaderStatement(n)) {
7850 if (isSgFunctionDeclaration(n) !=
nullptr) {
7851 bool either =
false;
7857 ROSE_ASSERT(stmnt !=
nullptr);
7864 ROSE_ASSERT(funcDefn !=
nullptr);
7865 if (funcDefn->get_name() ==
"main") {
7889 return isSgFunctionDeclaration(n);
7892 for (vector<SgNode*>::const_iterator i = children.begin();
7893 i != children.end(); ++i) {
7911 ROSE_ASSERT (scope != NULL);
7915 for (
size_t i = 0; i<stmt_list.size(); i++)
7919 if (isSgDeclarationStatement(cur_stmt))
7921 if (isSgPragmaDeclaration (cur_stmt))
7941 rt = n->copy (g_treeCopy);
7951 bool isC = TransformationSupport::getSourceFile(n)->get_outputLanguage() ==
SgFile::e_C_language;
7963#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
7965 for (std::vector<SgContinueStmt*>::iterator i = continues.begin(); i != continues.end(); ++i)
7970 LowLevelRewrite::replace(*i, make_unit_list( gotoStatement ) );
7976 printf (
"Not supported in mode: ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT (LowLevelRewrite::replace() is unavailable)");
7981#define DEBUG_TEMPLATE_ARG_EQUIVALENCE 0
7987#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
7988 printf (
"In templateArgumentEquivalence(): same pointer to template argument: returning true \n");
7995#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
7996 printf (
"In templateArgumentEquivalence(): different argumentType(): returning false \n");
8005 ROSE_ASSERT(arg1->
get_type() != NULL);
8006 ROSE_ASSERT(arg2->
get_type() != NULL);
8008#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8009 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::type_argument: checking for the same type: arg1->get_type() = %p = %s arg2->get_type() = %p = %s \n",
8017#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8018 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::type_argument: checking for the same type: returning true \n");
8031#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8032 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::type_argument: checking for the same type: pointers are different: returning typesAreEqual = %s \n",typesAreEqual ?
"true" :
"false");
8034 return typesAreEqual;
8042 if (expr1 == expr2) {
8043#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8044 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::nontype_argument: checking for the same expression: returning true \n");
8048#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8049 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::nontype_argument: same variant of expression: %s\n", expr1->
class_name().c_str());
8052 case V_SgLongIntVal: {
8056 case V_SgUnsignedLongVal:
8061 printf (
"FATAL: In templateArgumentEquivalence(): case SgTemplateArgument::nontype_argument: expression have the same variant %s but comparison is not NIY!\n", expr1->
class_name().c_str());
8066#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8067 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::nontype_argument: different variant of expression: returning false \n");
8075 if (arg1->get_templateDeclaration() == arg2->get_templateDeclaration())
8077#if DEBUG_TEMPLATE_ARG_EQUIVALENCE
8078 printf (
"In templateArgumentEquivalence(): case SgTemplateArgument::template_template_argument: checking for the same templateDeclaration: returning true \n");
8084 ROSE_ASSERT(!
"NIY: template template argument comparaison.");
8090 ROSE_ASSERT(!
"Try to compare template arguments of unknown type...");
8099 ROSE_ASSERT(!
"Try to compare template arguments of unknown type start_of_pack_expansion_argument");
8105 printf (
"Error: default case not handled! \n");
8113#define DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE 0
8117 if (list1.size() != list2.size())
8119#if DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE
8120 printf (
"In templateArgumentListEquivalence(): different list sizes: returning false \n");
8121 printf (
" --- list1.size() = %zu \n",list1.size());
8122 printf (
" --- list2.size() = %zu \n",list2.size());
8129#if DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE
8130 printf (
"In templateArgumentListEquivalence(): same list using STL equality operator: returning true \n");
8136 for (
size_t i = 0; i < list1.size(); i++)
8138#if DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE
8139 printf (
"In templateArgumentListEquivalence(): calling templateArgumentEquivalence() for i = %zu \n",i);
8144#if DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE
8145 printf (
"In templateArgumentListEquivalence(): calling templateArgumentEquivalence() for i = %zu --- returned false: returning false \n",i);
8151#if DEBUG_TEMPLATE_ARG_LIST_EQUIVALENCE
8152 printf (
"In templateArgumentListEquivalence(): reached base of function: returning true \n");
8172 SgName labelname =
"rose_label__";
8185 if (isSgNullExpression(f->get_increment()))
return;
8190 f->set_increment(ne);
8200 ROSE_ASSERT(condstmt);
8202 if (isSgNullStatement(condstmt))
return true;
8206 return isSgNullExpression(exprStmt->get_expression());
8215 bbStmts = initStmts;
8216 for (
size_t i = 0; i < bbStmts.size(); ++i) {
8217 bbStmts[i]->set_parent(bb);
8220 const bool testIsNull = hasEmptyCondition(f);
8230 Rose_STL_Container<SgNode*> fors = NodeQuery::querySubTree(top,
8232 for (
size_t i = 0; i < fors.size(); ++i) {
8240 Rose_STL_Container<SgNode*> allGotos = NodeQuery::querySubTree(scope, V_SgGotoStatement);
8242 vector<SgGotoStatement*> result;
8243 for (Rose_STL_Container<SgNode*>::const_iterator i = allGotos.begin(); i != allGotos.end(); ++i) {
8244 if (isSgGotoStatement(*i)->
get_label() == l) {
8245 result.push_back(isSgGotoStatement(*i));
8253 vector<SgReturnStmt*> SageInterface::findReturnStmts(
SgStatement* scope) {
8256 Rose_STL_Container<SgNode*> returns = NodeQuery::querySubTree(scope, V_SgReturnStmt);
8258 vector<SgReturnStmt*> result;
8259 for (Rose_STL_Container<SgNode*>::const_iterator i = returns.begin(); i != returns.end(); ++i) {
8260 result.push_back(isSgReturnStmt(*i));
8266static void getSwitchCasesHelper(
SgStatement* top, vector<SgStatement*>& result) {
8268 if (isSgSwitchStatement(top))
return;
8269 if (isSgCaseOptionStmt(top) || isSgDefaultOptionStmt(top)) {
8270 result.push_back(top);
8273 for (
unsigned int i = 0; i < children.size(); ++i) {
8274 if (isSgStatement(children[i])) {
8275 getSwitchCasesHelper(isSgStatement(children[i]), result);
8281 vector<SgStatement*> result;
8282 getSwitchCasesHelper(sw->
get_body(), result);
8312 if (
const SgSymbol* symbol = isSgSymbol(astNode))
8313 return symbol->get_scope();
8318 else if (
const SgQualifiedName* qualifiedName = isSgQualifiedName(astNode))
8322 const SgNode* parentNode = astNode;
8323 while (!isSgScopeStatement(parentNode))
8328 if (isSgFunctionParameterList(parentNode) || isSgCtorInitializerList(parentNode))
8331 ROSE_ASSERT(funcDeclaration != NULL);
8333 if (funcDeclaration != NULL)
8335 return funcDeclaration->get_definition();
8340 if (parentNode == NULL)
8348 if ( isSgScopeStatement(parentNode) == NULL &&
8349 dynamic_cast<const SgType*
>(parentNode) == NULL &&
8350 dynamic_cast<const SgSymbol*
>(parentNode) == NULL )
8352 printf (
"Error: In SageInterface::getScope(): could not trace back to SgScopeStatement node \n");
8357 if (
dynamic_cast<const SgType*
>(parentNode) != NULL ||
dynamic_cast<const SgSymbol*
>(parentNode) != NULL )
8359 printf (
"Error: can't locate an associated SgStatement from astNode = %p = %s parentNode = %p = %s \n",astNode,astNode->
class_name().c_str(),parentNode,parentNode->
class_name().c_str());
8367 ROSE_ASSERT (scopeStatement != NULL);
8370 if (isSgScopeStatement(astNode))
8371 if (isSgScopeStatement(parentNode))
8373 ROSE_ASSERT (astNode == parentNode);
8400 printf (
"In getVarSymFromName(): name->get_name() = %s \n",name->get_name().str());
8403 ROSE_ASSERT (scope != NULL);
8405 printf (
"In getVarSymFromName(): name->get_name() = %s scope = %p = %s \n",name->get_name().str(),scope,scope->
class_name().c_str());
8407 v_sym = scope->lookup_var_symbol (name->get_name());
8416 if (decl_scope != NULL)
8417 v_sym = decl_scope->lookup_var_symbol (name->get_name());
8420 cerr <<
"\t\t*** WARNING: Can't seem to find a symbol for '"
8421 << name->get_name ().str ()
8451getVarSym_const (
const SgNode* n)
8457 v_sym = isSgVarRefExp (n)->get_symbol ();
8459 case V_SgInitializedName:
8460 v_sym = getVarSymFromName_const (isSgInitializedName (n));
8486 if (!decl)
return 0;
8487 const SgInitializedNamePtrList& names = decl->
get_variables ();
8488 if (names.begin () != names.end ())
8491 return getVarSym_const (name);
8510 if (names.begin () != names.end ())
8511 return *(names.begin ());
8517static void findBreakStmtsHelper(
SgStatement* code,
const std::string& fortranLabel,
bool inOutermostBody, vector<SgBreakStmt*>& breakStmts) {
8518 if (isSgWhileStmt(code) || isSgDoWhileStmt(code) || isSgForStatement(code) || isSgSwitchStatement(code)) {
8519 if (fortranLabel ==
"") {
8524 inOutermostBody =
false;
8527 if (isSgBreakStmt(code)) {
8529 bool breakMatchesThisConstruct =
false;
8530 if (bs->get_do_string_label() ==
"") {
8532 breakMatchesThisConstruct = inOutermostBody;
8534 breakMatchesThisConstruct = (fortranLabel == bs->get_do_string_label());
8536 if (breakMatchesThisConstruct) {
8537 breakStmts.push_back(bs);
8542 for (
unsigned int i = 0; i < children.size(); ++i) {
8543 if (isSgStatement(children[i])) {
8544 findBreakStmtsHelper(isSgStatement(children[i]), fortranLabel, inOutermostBody, breakStmts);
8552 vector<SgBreakStmt*> result;
8553 findBreakStmtsHelper(code, fortranLabel,
true, result);
8558static void findContinueStmtsHelper(
SgStatement* code,
const std::string& fortranLabel,
bool inOutermostBody, vector<SgContinueStmt*>& continueStmts) {
8559 if (isSgWhileStmt(code) || isSgDoWhileStmt(code) || isSgForStatement(code)) {
8560 if (fortranLabel ==
"") {
8565 inOutermostBody =
false;
8568 if (isSgContinueStmt(code)) {
8570 bool continueMatchesThisConstruct =
false;
8571 if (cs->get_do_string_label() ==
"") {
8573 continueMatchesThisConstruct = inOutermostBody;
8575 continueMatchesThisConstruct = (fortranLabel == cs->get_do_string_label());
8577 if (continueMatchesThisConstruct) {
8578 continueStmts.push_back(cs);
8583 for (
unsigned int i = 0; i < children.size(); ++i) {
8585 if (stmnt != NULL) {
8586 findContinueStmtsHelper(stmnt, fortranLabel, inOutermostBody, continueStmts);
8594 vector<SgContinueStmt*> result;
8595 findContinueStmtsHelper(code, fortranLabel,
true, result);
8606 std::cout <<
"Starting getInitializerOfExpression on 0x" << std::hex << (int)n <<
", which has type " << n->
sage_class_name() << std::endl;
8608 while (!isSgInitializer(n)) {
8611 std::cout <<
"Continuing getInitializerOfExpression on 0x" << std::hex << (int)n;
8613 std::cout << std::endl;
8617 return isSgInitializer(n);
8625 std::vector<SgVariableSymbol*> symbols;
8627 virtual void visit(
SgNode* n) {
8628 if (isSgVarRefExp(n))
8629 symbols.push_back(isSgVarRefExp(n)->get_symbol());
8633 GetSymbolsUsedInExpressionVisitor vis;
8634 vis.traverse(expr, preorder);
8641 return getEnclosingNode<SgSourceFile>(n, includingSelf);
8647 return findDeclarationStatement<SgFunctionDeclaration> (root, name, scope, isDefining);
8658 return getEnclosingNode<SgFunctionDefinition>(n, includingSelf);
8664 return getEnclosingNode<SgFunctionDeclaration>(astNode, includingSelf);
8674 return getEnclosingNode<SgGlobal>(astNode,
true );
8679 return getEnclosingNode<SgClassDefinition>(astNode, includingSelf);
8687 return getEnclosingNode<SgClassDeclaration>(astNode,
true);
8692 return getEnclosingNode<SgExprListExp>(astNode, includingSelf);
8698 bool returnValue =
false;
8704 virtual void visit(
SgNode* n)
8706 if (n == expression_target)
8712 Visitor(
SgExpression* expr) : expression_target(expr), in_subtree(
false) {}
8715 Visitor traversal(exp);
8717 traversal.traverse(subtree, preorder);
8719 returnValue = traversal.in_subtree;
8733 ROSE_ASSERT (functionCallExp != NULL);
8735 SgExpression* expression = functionCallExp->get_function();
8736 ROSE_ASSERT (expression != NULL);
8740 SgDotExp* dotExp = isSgDotExp(expression);
8743 ROSE_ASSERT (dotExp != NULL);
8746 ROSE_ASSERT (rhsOperand != NULL);
8751 if (memberFunctionRefExp != NULL)
8758 if (functionReferenceExp != NULL)
8763 SgArrowExp* arrowExp = isSgArrowExp(expression);
8764 if ( arrowExp != NULL)
8766 ROSE_ASSERT (arrowExp != NULL);
8769 ROSE_ASSERT (rhsOperand != NULL);
8774 if (memberFunctionRefExp != NULL)
8780 return returnDeclaration;
8785std::list<SgClassType*>
8790#define DEBUG_DATA_MEMBER_TYPE_CHAIN 0
8796 ROSE_ASSERT(varRefExp != NULL || memberFunctionRefExp != NULL);
8798 std::list<SgClassType*> returnTypeChain;
8801 std::list<SgClassType*> classChain;
8806 if (varRefExp != NULL)
8812 ROSE_ASSERT(memberFunctionRefExp != NULL);
8817 ROSE_ASSERT(parent != NULL);
8819#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8820 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): parent = %p = %s \n",parent,parent->
class_name().c_str());
8824 SgDotExp* dotExp = isSgDotExp(parent);
8828 if (arrowExp != NULL)
8830#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8831 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): Found an arrow expression \n");
8833 binaryOperator = arrowExp;
8838#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8839 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): Found an dot expression \n");
8841 binaryOperator = dotExp;
8845 if (binaryOperator != NULL)
8848 ROSE_ASSERT(lhs != NULL);
8850#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8851 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs = %p = %s \n",lhs,lhs->
class_name().c_str());
8857 while (isSgCastExp(temp_lhs) != NULL)
8859 cast = isSgCastExp(temp_lhs);
8860 ROSE_ASSERT(cast != NULL);
8863#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8864 printf (
"Top of loop: processing cast = %p temp_lhs = %p = %s \n",cast,temp_lhs,temp_lhs->
class_name().c_str());
8866 ROSE_ASSERT(cast->
get_type() != NULL);
8868 if (classType == NULL)
8870#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8871 printf (
" --- looking for base type: In SageInterface::getClassTypeChainForDataMemberReference(): classType == NULL: cast->get_type() = %p = %s \n",
8874 SgType* baseType = cast->
get_type()->
stripType(SgType::STRIP_POINTER_TYPE | SgType::STRIP_MODIFIER_TYPE | SgType::STRIP_REFERENCE_TYPE | SgType::STRIP_RVALUE_REFERENCE_TYPE | SgType::STRIP_TYPEDEF_TYPE);
8875 ROSE_ASSERT(baseType != NULL);
8877#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8878 printf (
" --- baseType = %p = %s name = %s \n",baseType,baseType->
class_name().c_str(),
get_name(baseType).c_str());
8880 classType = isSgClassType(baseType);
8884 ROSE_ASSERT(temp_lhs != NULL);
8886#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8887 printf (
" --- temp_lhs = %p = %s name = %s \n",temp_lhs,temp_lhs->
class_name().c_str(),
get_name(temp_lhs).c_str());
8893 if (classType != NULL)
8895 classChain.push_front(classType);
8899 if (classType != NULL)
8910 ROSE_ASSERT(target_type != NULL);
8911 SgClassType* target_classType = isSgClassType(target_type);
8913 if (target_classType != NULL)
8916 ROSE_ASSERT(target_declaration != NULL);
8917 SgClassDeclaration* target_classDeclaration = isSgClassDeclaration(target_declaration);
8918 ROSE_ASSERT(target_classDeclaration != NULL);
8920 ROSE_ASSERT(target_definingClassDeclaration != NULL);
8921 SgScopeStatement* target_scope = target_definingClassDeclaration->get_definition();
8922 ROSE_ASSERT(target_scope != NULL);
8924#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8925 printf (
"target_classDeclaration = %p = %s name = %s target_scope = %p = %s \n",
8926 target_classDeclaration,target_classDeclaration->
class_name().c_str(),target_classDeclaration->get_name().str(),target_scope,target_scope->
class_name().c_str());
8929 ROSE_ASSERT(source_classType != NULL);
8931 ROSE_ASSERT(source_declaration != NULL);
8932 SgClassDeclaration* source_classDeclaration = isSgClassDeclaration(source_declaration);
8933 ROSE_ASSERT(source_classDeclaration != NULL);
8935 ROSE_ASSERT(source_definingClassDeclaration != NULL);
8936 SgScopeStatement* source_scope = source_definingClassDeclaration->get_definition();
8937 ROSE_ASSERT(source_scope != NULL);
8939#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8940 printf (
"source_classDeclaration = %p = %s name = %s source_scope = %p = %s \n",
8941 source_classDeclaration,source_classDeclaration->
class_name().c_str(),source_classDeclaration->get_name().str(),source_scope,source_scope->
class_name().c_str());
8944 while (tmp_scope != NULL && tmp_scope != target_scope)
8946#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8947 printf (
"tmp_scope = %p = %s \n",tmp_scope,tmp_scope->
class_name().c_str());
8950 ROSE_ASSERT(tmp_classDefinition != NULL);
8952 ROSE_ASSERT(tmp_classDeclaration != NULL);
8954#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8955 SgName scope_name = tmp_classDeclaration->get_name();
8956 printf (
"scope_name = %s \n",scope_name.str());
8958 SgClassType* tmp_classType = tmp_classDeclaration->get_type();
8959 ROSE_ASSERT(tmp_classType != NULL);
8962 classChain.push_front(tmp_classType);
8966 if (isSgGlobal(tmp_scope) != NULL)
8975 printf (
"In loop processing cast: target_type = %p = %s \n",target_type,target_type->
class_name().c_str());
8981#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8982 printf (
"Bottom of loop: processing cast = %p temp_lhs = %p = %s \n",cast,temp_lhs,temp_lhs->
class_name().c_str());
8988 ROSE_ASSERT(temp_lhs != NULL);
8990#if DEBUG_DATA_MEMBER_TYPE_CHAIN
8991 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): temp_lhs = %p = %s \n",temp_lhs,temp_lhs->
class_name().c_str());
8994 SgVarRefExp* derivedClassVarRefExp = isSgVarRefExp(temp_lhs);
8995 if (derivedClassVarRefExp != NULL)
8997 SgVariableSymbol* derivedClassVariableSymbol = derivedClassVarRefExp->get_symbol();
8998 ROSE_ASSERT(derivedClassVariableSymbol != NULL);
9000 SgName derivedClassVariableName = derivedClassVariableSymbol->
get_name();
9002#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9003 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): derivedClassVariableName = %s \n",derivedClassVariableName.str());
9007 ROSE_ASSERT(type != NULL);
9009#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9010 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs type = %p = %s \n",type,type->
class_name().c_str());
9014 SgType* stripped_type = type->
stripType(SgType::STRIP_POINTER_TYPE|SgType::STRIP_ARRAY_TYPE|SgType::STRIP_REFERENCE_TYPE|SgType::STRIP_RVALUE_REFERENCE_TYPE|SgType::STRIP_MODIFIER_TYPE);
9016#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9017 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs stripped_type = %p = %s \n",stripped_type,stripped_type->
class_name().c_str());
9021 SgClassType* classType = isSgClassType(stripped_type);
9024 if (classType != NULL)
9026#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9027 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs classType = %p = %s \n",classType,classType->
class_name().c_str());
9028 SgClassDeclaration* classDeclaration = isSgClassDeclaration(classType->get_declaration());
9029 ROSE_ASSERT(classDeclaration != NULL);
9030 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs classDeclaration = %p = %s name = %s \n",
9031 classDeclaration,classDeclaration->
class_name().c_str(),classDeclaration->get_name().str());
9036 classChain.push_front(classType);
9040#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9041 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs stripped_type is not a SgClassType \n");
9047#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9048 printf (
"Need to support alternative to SgVarRefExp: temp_lhs = %p = %s \n",temp_lhs,temp_lhs->
class_name().c_str());
9051 ROSE_ASSERT(type != NULL);
9053#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9054 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): lhs type = %p = %s name = %s \n",type,type->
class_name().c_str(),
get_name(type).c_str());
9058 SgType* stripped_type = type->
stripType(SgType::STRIP_POINTER_TYPE|SgType::STRIP_ARRAY_TYPE|SgType::STRIP_REFERENCE_TYPE|SgType::STRIP_RVALUE_REFERENCE_TYPE|SgType::STRIP_MODIFIER_TYPE);
9060#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9061 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): stripped_type = %p = %s name = %s \n",stripped_type,stripped_type->
class_name().c_str(),
get_name(stripped_type).c_str());
9064 SgClassType* classType = isSgClassType(stripped_type);
9066 if (classType != NULL)
9068 classChain.push_front(classType);
9072#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9073 printf (
"classChain.size() = %zu \n",classChain.size());
9074 std::list<SgClassType*>::iterator iter = classChain.begin();
9075 while(iter != classChain.end())
9077 printf (
" --- *iter = %p = %s name = %s \n",*iter,(*iter)->class_name().c_str(),(*iter)->get_name().str());
9090 if (varRefExp != NULL)
9092 ROSE_ASSERT(varRefExp != NULL);
9093 ROSE_ASSERT(memberFunctionRefExp == NULL);
9095 referenceSymbol = varRefExp->get_symbol();
9099 ROSE_ASSERT(varRefExp == NULL);
9100 ROSE_ASSERT(memberFunctionRefExp != NULL);
9102 referenceSymbol = memberFunctionRefExp->get_symbol();
9104 ROSE_ASSERT(referenceSymbol != NULL);
9107#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9108 printf (
"referenceSymbol = %p = %s \n",referenceSymbol,referenceSymbol->
class_name().c_str());
9109 printf (
"symbolName = %s \n",symbolName.str());
9114 if (functionSymbol != NULL)
9119 if (templateInstantiationMemberFunctionDeclaration != NULL)
9121#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9122 printf (
"This is a template name, we want the name without template arguments \n");
9123 printf (
"templateInstantiationMemberFunctionDeclaration = %p \n",templateInstantiationMemberFunctionDeclaration);
9124 printf (
"templateInstantiationMemberFunctionDeclaration->get_name() = %s \n",templateInstantiationMemberFunctionDeclaration->get_name().str());
9131 isSgTemplateMemberFunctionDeclaration(templateInstantiationMemberFunctionDeclaration->
get_templateDeclaration());
9132 if (templateMemberFunctionDeclaration != NULL)
9134#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9135 printf (
"templateMemberFunctionDeclaration = %p \n",templateMemberFunctionDeclaration);
9136 printf (
"templateMemberFunctionDeclaration->get_name() = %s \n",templateMemberFunctionDeclaration->get_name().str());
9139 symbolName = templateMemberFunctionDeclaration->get_name();
9143#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9144 printf (
"templateMemberFunctionDeclaration == NULL: template declaration not available from template instantiation (rare, I think) \n");
9148 printf (
"Exiting as a test! \n");
9156 ROSE_ASSERT(declarationStatement != NULL);
9157#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9158 printf (
"functionSymbol != NULL: but declaration is not a member function: declarationStatement = %p = %s \n",declarationStatement,declarationStatement->
class_name().c_str());
9165 if (variableSymbol != NULL)
9171#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9172 printf (
"In SageInterface::getClassTypeChainForDataMemberReference(): NOTE: referenceSymbol is not a SgFunctionSymbol or SgVariableSymbol \n");
9175 printf (
"Exiting as a test! \n");
9182#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9183 printf (
"symbolName = %s \n",symbolName.str());
9192 std::list<SgClassType*> saveList;
9194#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9195 printf (
"classChain.size() = %zu \n",classChain.size());
9198 std::list<SgClassType*>::iterator i = classChain.begin();
9199 std::list<SgClassType*>::iterator save_iter = i;
9205 bool ambiguityDetectedSoSaveWholeChain =
false;
9207 while(i != classChain.end())
9209#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9210 printf (
"******** TOP OF WHILE LOOP ******** \n");
9211 printf (
" --- *i = %p = %s name = %s \n",*i,(*i)->class_name().c_str(),(*i)->get_name().str());
9212 printf (
" --- --- referenceSymbol = %p = %s \n",referenceSymbol,referenceSymbol->
class_name().c_str());
9214 bool ambiguityDetected =
false;
9217 ROSE_ASSERT(declarationStatement != NULL);
9219 if (definingDeclarationStatement != NULL)
9221 SgClassDeclaration* classDeclaration = isSgClassDeclaration(definingDeclarationStatement);
9222 ROSE_ASSERT(classDeclaration != NULL);
9225#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9226 printf (
" --- classDeclaration = %p = %s name = %s \n",classDeclaration,classDeclaration->
class_name().c_str(),classDeclaration->get_name().str());
9227 printf (
" --- classDefinition = %p = %s \n",classDefinition,classDefinition->
class_name().c_str());
9230 ambiguityDetected = classDefinition->hasAmbiguity(symbolName,referenceSymbol);
9232#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9233 printf (
" --- ambiguityDetected = %s \n",ambiguityDetected ?
"true" :
"false");
9238 if (ambiguityDetected ==
true || ambiguityDetectedSoSaveWholeChain ==
true)
9240 ambiguityDetectedSoSaveWholeChain =
true;
9242 if (save_iter != classChain.end())
9244#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9245 printf (
" --- add to saveList: *save_iter = %p \n",*save_iter);
9247 saveList.push_back(*save_iter);
9251#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9252 printf (
" --- save_iter == classChain.end() \n");
9257#if DEBUG_DATA_MEMBER_TYPE_CHAIN || 0
9258 printf (
"******** BOTTOM OF WHILE LOOP ******** \n");
9268#if DEBUG_DATA_MEMBER_TYPE_CHAIN
9269 printf (
"saveList.size() = %zu \n",saveList.size());
9270 std::list<SgClassType*>::iterator saveList_iterator = saveList.begin();
9271 while (saveList_iterator != saveList.end())
9273 printf (
" --- *saveList_iterator = %p = %s name = %s \n",*saveList_iterator,(*saveList_iterator)->class_name().c_str(),(*saveList_iterator)->get_name().str());
9275 saveList_iterator++;
9279 returnTypeChain = saveList;
9284 return returnTypeChain;
9294#define DEBUG_IS_MEMBER_FUNCTION_MEMBER_REFERENCE 0
9296 ROSE_ASSERT(memberFunctionRefExp != NULL);
9298 bool returnValue =
false;
9304 SgDotExp* dotExp = isSgDotExp(parent);
9311 if (arrowExp != NULL || dotExp != NULL || addressOfOp != NULL)
9315 ROSE_ASSERT(symbol != NULL);
9318 ROSE_ASSERT(functionDeclaration != NULL);
9321 if (functionDeclaration != NULL)
9323 bool isStatic = functionDeclaration->get_declarationModifier().get_storageModifier().
isStatic();
9324#if DEBUG_IS_MEMBER_FUNCTION_MEMBER_REFERENCE
9325 printf (
"isStatic = %s \n",
isStatic ?
"true" :
"false");
9330 ROSE_ASSERT(scope != NULL);
9333 if (classDefinition != NULL)
9341#if DEBUG_IS_MEMBER_FUNCTION_MEMBER_REFERENCE
9342 printf (
"In SageInterface::isMemberFunctionMemberReference(): memberFunctionRefExp is not associated with variableDeclaration (could not compute if it is static data member) \n");
9348#if DEBUG_IS_MEMBER_FUNCTION_MEMBER_REFERENCE
9349 printf (
"In SageInterface::isMemberFunctionMemberReference(): memberFunctionRefExp parent is not a is not SgArrowExp or SgDotExp expression \n");
9353#if DEBUG_IS_MEMBER_FUNCTION_MEMBER_REFERENCE
9354 printf (
"Leaving SageInterface::isMemberFunctionMemberReference(): returnValue = %s \n",returnValue ?
"true" :
"false");
9373#define DEBUG_IS_DATA_MEMBER_REFERENCE 0
9375 ROSE_ASSERT(varRefExp != NULL);
9377 bool returnValue =
false;
9383 SgDotExp* dotExp = isSgDotExp(parent);
9387 if (arrowExp != NULL || dotExp != NULL || addressOfOp != NULL)
9389 if (arrowExp != NULL)
9393 ROSE_ASSERT(parentOfArrowExp != NULL);
9394 SgSizeOfOp* sizeOfOp = isSgSizeOfOp(parentOfArrowExp);
9395 if (sizeOfOp != NULL && sizeOfOp->get_is_objectless_nonstatic_data_member_reference() ==
true)
9398#if DEBUG_IS_DATA_MEMBER_REFERENCE
9399 printf (
"In SageInterface::isDataMemberReference(): Found case of expression used in sizeof with objectless_nonstatic_data_member_reference \n");
9406 ROSE_ASSERT(symbol != NULL);
9409 ROSE_ASSERT(initializedName != NULL);
9413 if (variableDeclaration != NULL)
9415 bool isStatic = variableDeclaration->get_declarationModifier().get_storageModifier().
isStatic();
9419 ROSE_ASSERT(scope != NULL);
9422 if (classDefinition != NULL)
9430#if DEBUG_IS_DATA_MEMBER_REFERENCE
9431 printf (
"In SageInterface::isDataMemberReference(): varRefExp is not associated with variableDeclaration (could not compute if it is static data member) \n");
9437#if DEBUG_IS_DATA_MEMBER_REFERENCE
9438 printf (
"In SageInterface::isDataMemberReference(): varRefExp parent is not a is not SgArrowExp or SgDotExp expression \n");
9442#if DEBUG_IS_DATA_MEMBER_REFERENCE
9443 printf (
"Leaving SageInterface::isDataMemberReference(): returnValue = %s \n",returnValue ?
"true" :
"false");
9455 ROSE_ASSERT(varRefExp != NULL);
9457 bool returnValue =
false;
9461 if (addressOfOp != NULL)
9479 ROSE_ASSERT(varRefExp != NULL || memberFunctionRefExp != NULL);
9483 ROSE_ASSERT(refExp != NULL);
9485 bool returnValue =
false;
9490 if (addressOfOp != NULL)
9508 ROSE_ASSERT (astNode != NULL);
9512 ROSE_ASSERT (isSgProject(astNode) == NULL);
9514 SgNode* previous_parent = NULL;
9515 SgNode* previous_previous_parent = NULL;
9517 SgNode* parent = astNode;
9519 while ( (parent != NULL) && (isSgFile(parent) == NULL) && isSgJavaPackageDeclaration(parent) == NULL)
9522 printf (
"In getEnclosingFileNode(): parent = %p = %s \n",parent,parent->
class_name().c_str());
9524 previous_previous_parent = previous_parent;
9525 previous_parent = parent;
9530 if (previous_previous_parent != NULL && previous_parent != NULL && isSgJavaPackageDeclaration(parent) != NULL)
9534 printf (
"parent = %p = %s \n",parent,parent->
class_name().c_str());
9535 printf (
"previous_parent = %p = %s \n",previous_parent,previous_parent->
class_name().c_str());
9536 printf (
"previous_previous_parent = %p = %s \n",previous_previous_parent,previous_previous_parent->
class_name().c_str());
9538 SgClassDeclaration* classDeclaration = isSgClassDeclaration(previous_previous_parent);
9539 if (classDeclaration != NULL)
9542 printf (
"Class name = %p = %s = %s \n",classDeclaration,classDeclaration->
class_name().c_str(),classDeclaration->get_name().str());
9547 SgProject* project = TransformationSupport::getProject(parent);
9548 ROSE_ASSERT(project != NULL);
9549 SgFileList* fileList = project->get_fileList_ptr();
9550 ROSE_ASSERT(fileList != NULL);
9551 SgFilePtrList & vectorFile = fileList->get_listOfFiles();
9553 printf (
"Output list of files: \n");
9555 SgFilePtrList::iterator i = vectorFile.begin();
9556 while (i != vectorFile.end())
9559 ROSE_ASSERT(file != NULL);
9561 printf (
" --- filename = %s \n",file->
getFileName().c_str());
9564 string filenameWithoutPath = file->get_sourceFileNameWithoutPath();
9565 string classname = classDeclaration->get_name();
9566 string matchingfilename = classname +
".java";
9568 printf (
" --- --- filename = %s \n",filename.c_str());
9569 printf (
" --- --- filenameWithoutPath = %s \n",filenameWithoutPath.c_str());
9570 printf (
" --- --- classname = %s \n",classname.c_str());
9571 printf (
" --- --- matchingfilename = %s \n",matchingfilename.c_str());
9573 if (filenameWithoutPath == matchingfilename)
9576 printf (
" return file = %p \n",file);
9592 SgSourceFile *sourcefile = isSgSourceFile(attribute->getNode());
9593 ROSE_ASSERT(sourcefile != NULL);
9602 if (previous_parent == NULL && isSgJavaPackageDeclaration(parent) != NULL)
9605 ROSE_ASSERT(isSgJavaPackageDeclaration(astNode) != NULL);
9610 if (previous_previous_parent == NULL && isSgJavaPackageDeclaration(parent) != NULL)
9613 ROSE_ASSERT(isSgClassDefinition(astNode) != NULL);
9624 if (parent ==
nullptr)
9630 return isSgFile(parent);
9636 std::set<SgNode*> specific;
9637 std::set<SgNode*> non_specific;
9639 static void recursive_collect(
SgNode* node , std::set<SgNode *> & collection ) {
9641 if (node == NULL || !collection.insert(node).second)
return;
9644 for (std::vector<std::pair<SgNode*, std::string> >::iterator i = data_members.begin(); i != data_members.end(); ++i) {
9645 recursive_collect(i->first, collection);
9652 if (fileInfo != NULL) {
9653 if (fileInfo->isFrontendSpecific()) {
9655 recursive_collect(n, specific);
9657 non_specific.insert(n);
9658 recursive_collect(n, non_specific);
9661 fileInfo = isSg_File_Info(n);
9662 if (fileInfo != NULL) {
9663 if (fileInfo->isFrontendSpecific()) {
9666 non_specific.insert(n);
9672 std::set<SgNode*> apply() {
9673 traverseMemoryPool();
9675 std::set<SgNode*> result;
9677 std::set_difference(
9678 specific.begin(), specific.end(),
9679 non_specific.begin(), non_specific.end(),
9680 std::insert_iterator<set<SgNode*> >(result, result.begin())
9687 FrontendSpecificTraversal fst;
9700 void visit(
SgNode *astNode)
9702 ROSE_ASSERT(astNode != NULL);
9704 if (file_info != NULL)
9708 printf (
"Found shared node: astNode = %p = %s \n",astNode,astNode->
class_name().c_str());
9714 OutputSharedNodesTraversal tt;
9715 tt.traverse(node,preorder);
9723 while (n && !isSgStatement(n)) n = n->
get_parent();
9724 return isSgStatement(n);
9733SageInterface::DeferredTransformation::DeferredTransformation()
9734 : deferredTransformationKind(e_default),
9735 statementToRemove(NULL),
9736 statementToAdd(NULL),
9737 class_definition(NULL),
9738 target_class_member(NULL),
9739 new_function_prototype(NULL),
9741 locationToOverwriteWithTransformation(NULL),
9742 transformationToOverwriteFirstStatementInInterval(NULL),
9743 blockOfStatementsToOutline(NULL)
9747 printf (
"In SageInterface::DeferredTransformation default constructor called \n");
9755SageInterface::DeferredTransformation::DeferredTransformation(
9759 : deferredTransformationKind(e_outliner),
9760 statementToRemove(NULL),
9761 statementToAdd(NULL),
9762 class_definition(input_class_definition),
9763 target_class_member(input_target_class_member),
9764 new_function_prototype(input_new_function_prototype),
9766 locationToOverwriteWithTransformation(NULL),
9767 transformationToOverwriteFirstStatementInInterval(NULL),
9768 blockOfStatementsToOutline(NULL)
9772 printf (
"In SageInterface::DeferredTransformation constructor for outliner called \n");
9780 printf (
"In SageInterface::DeferredTransformation constructor for replaceDefiningFunctionDeclarationWithFunctionPrototype called \n");
9786 X.deferredTransformationKind = e_replaceDefiningFunctionDeclarationWithFunctionPrototype;
9787 X.statementToRemove = functionDeclaration;
9788 X.statementToAdd = NULL;
9789 X.class_definition = NULL;
9790 X.target_class_member = NULL;
9791 X.new_function_prototype = NULL;
9794 X.locationToOverwriteWithTransformation = NULL;
9795 X.transformationToOverwriteFirstStatementInInterval = NULL;
9796 X.blockOfStatementsToOutline = NULL;
9802SageInterface::DeferredTransformation::replaceStatement(
SgStatement* oldStmt,
SgStatement* newStmt,
bool )
9805 printf (
"In SageInterface::DeferredTransformation constructor for replaceStatement called \n");
9811 X.deferredTransformationKind = e_replaceStatement;
9812 X.statementToRemove = oldStmt;
9813 X.statementToAdd = newStmt;
9814 X.class_definition = NULL;
9815 X.target_class_member = NULL;
9816 X.new_function_prototype = NULL;
9819 X.locationToOverwriteWithTransformation = NULL;
9820 X.transformationToOverwriteFirstStatementInInterval = NULL;
9821 X.blockOfStatementsToOutline = NULL;
9826SageInterface::DeferredTransformation::DeferredTransformation (
const DeferredTransformation& X)
9828 : deferredTransformationKind(X.deferredTransformationKind),
9829 statementToRemove(X.statementToRemove),
9830 statementToAdd(X.StatementToAdd),
9831 class_definition(X.class_definition),
9832 target_class_member(X.target_class_member),
9833 new_function_prototype(X.new_function_prototype),
9834 targetClasses(X.targetClasses),
9835 targetFriends(X.targetFriends)
9841 printf (
"In SageInterface::DeferredTransformation copy constructor called \n");
9851 printf (
"Inside of SageInterface::DeferredTransformation::operator= (const DeferredTransformation& X) \n");
9856 targetFriends = X.targetFriends;
9857 targetClasses = X.targetClasses;
9863 transformationLabel = X.transformationLabel;
9866 deferredTransformationKind = X.deferredTransformationKind;
9867 statementToRemove = X.statementToRemove;
9868 statementToAdd = X.statementToAdd;
9870 class_definition = X.class_definition;
9871 target_class_member = X.target_class_member;
9872 new_function_prototype = X.new_function_prototype;
9873 targetClasses = X.targetClasses;
9874 targetFriends = X.targetFriends;
9877 statementInterval = X.statementInterval;
9878 locationToOverwriteWithTransformation = X.locationToOverwriteWithTransformation;
9879 transformationToOverwriteFirstStatementInInterval = X.transformationToOverwriteFirstStatementInInterval;
9882 blockOfStatementsToOutline = X.blockOfStatementsToOutline;
9893std::string SageInterface::DeferredTransformation::outputDeferredTransformationKind(
const TransformationKind & kind)
9895 string returnValue =
"uninitialized";
9898 case e_error: returnValue =
"e_error";
break;
9899 case e_default: returnValue =
"e_default";
break;
9900 case e_outliner: returnValue =
"e_outliner";
break;
9901 case e_replaceStatement: returnValue =
"e_replaceStatement";
break;
9902 case e_removeStatement: returnValue =
"e_removeStatement";
break;
9903 case e_replaceDefiningFunctionDeclarationWithFunctionPrototype: returnValue =
"e_replaceDefiningFunctionDeclarationWithFunctionPrototype";
break;
9904 case e_last: returnValue =
"e_last";
break;
9907 printf (
"Error: SageInterface::DeferredTransformation::get_deferredTransformationKind_string(): default reached \n");
9915void SageInterface::DeferredTransformation::display ( std::string label )
const
9917 printf (
"SageInterface::DeferredTransformation::display(): label = %s \n",label.c_str());
9922 printf (
" --- transformationLabel = %s \n",transformationLabel.c_str());
9924 printf (
" --- deferredTransformationKind = %s \n",outputDeferredTransformationKind(deferredTransformationKind).c_str());
9925 if (statementToRemove != NULL)
9927 printf (
" --- statementToRemove = %p = %s name = %s \n",statementToRemove,statementToRemove->class_name().c_str(),
get_name(statementToRemove).c_str());
9931 printf (
" --- statementToRemove == NULL \n");
9934 if (statementToAdd != NULL)
9936 printf (
" --- statementToAdd = %p = %s name = %s \n",statementToAdd,statementToAdd->class_name().c_str(),
get_name(statementToAdd).c_str());
9940 printf (
" --- statementToAdd == NULL \n");
9943 if (class_definition != NULL)
9946 printf (
" --- class_definition = %p \n",class_definition);
9949 if (target_class_member != NULL)
9951 printf (
" --- target_class_member = %p = %s name = %s \n",target_class_member,target_class_member->class_name().c_str(),
get_name(target_class_member).c_str());
9954 if (new_function_prototype != NULL)
9956 printf (
" --- new_function_prototype = %p = %s name = %s \n",new_function_prototype,new_function_prototype->class_name().c_str(),
get_name(new_function_prototype).c_str());
9960 if (locationToOverwriteWithTransformation != NULL)
9964 printf (
" --- locationToOverwriteWithTransformation = %p \n",locationToOverwriteWithTransformation);
9968 if (transformationToOverwriteFirstStatementInInterval != NULL)
9972 printf (
" --- transformationToOverwriteFirstStatementInInterval = %p \n",transformationToOverwriteFirstStatementInInterval);
9976 if (blockOfStatementsToOutline != NULL)
9978 printf (
" --- blockOfStatementsToOutline = %p \n",blockOfStatementsToOutline);
9981 printf (
"targetClasses.size() = %zu \n",targetClasses.size());
9982 printf (
"targetFriends.size() = %zu \n",targetFriends.size());
9985 printf (
"statementInterval.size() = %zu \n",statementInterval.size());
9995#define REMOVE_STATEMENT_DEBUG 0
10000#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
10011 ASSERT_not_null(targetStmt);
10019 bool isRemovable = (parentStatement != NULL) ? LowLevelRewrite::isRemovableStatement(targetStmt) :
false;
10021#if REMOVE_STATEMENT_DEBUG || 0
10022 printf (
"In SageInterface::removeStatement(): parentStatement = %p = %s remove targetStatement = %p = %s (isRemovable = %s) \n",
10023 parentStatement,parentStatement->
class_name().c_str(),targetStmt,targetStmt->
class_name().c_str(),isRemovable ?
"true" :
"false");
10026 if (isRemovable ==
true)
10033 if (autoRelocatePreprocessingInfo ==
true)
10043 if (comments !=
nullptr && isSgBasicBlock(targetStmt) ==
nullptr )
10045 vector<int> captureList;
10046#if REMOVE_STATEMENT_DEBUG
10047 printf (
"Found attached comments (removing %p = %s): comments->size() = %" PRIuPTR
" \n",targetStmt,targetStmt->
class_name().c_str(),comments->size());
10053 int commentIndex = 0;
10054 AttachedPreprocessingInfoType::iterator i;
10055 for (i = comments->begin(); i != comments->end(); i++)
10057 ROSE_ASSERT ( (*i) != NULL );
10058#if REMOVE_STATEMENT_DEBUG
10059 printf (
" Attached Comment (relativePosition=%s): %s\n",
10060 ((*i)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
10061 (*i)->getString().c_str());
10062 printf (
"Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
10063 (*i)->get_file_info()->display(
"comment/directive location debug");
10065 captureList.push_back(commentIndex);
10069#if REMOVE_STATEMENT_DEBUG
10070 printf (
"captureList.size() = %" PRIuPTR
" \n",captureList.size());
10073 if (captureList.empty() ==
false)
10078 bool surroundingStatementPreceedsTargetStatement =
false;
10081 if (surroundingStatement !=
nullptr)
10084#if REMOVE_STATEMENT_DEBUG
10085 printf (
"In removeStatement(): surroundingStatementPreceedsTargetStatement = %s \n",surroundingStatementPreceedsTargetStatement ?
"true" :
"false");
10086 printf (
" --- moving comments from targetStmt = %p = %s name = %s \n",targetStmt,targetStmt->
class_name().c_str(),
get_name(targetStmt).c_str());
10087 printf (
" --- moving comments to surroundingStatement = %p = %s name = %s \n",surroundingStatement,surroundingStatement->
class_name().c_str(),
get_name(surroundingStatement).c_str());
10102 printf (
"Error: This is not supported within Microsoft Windows (I forget why). \n");
10124 printf (
"In SageInterface::resetInternalMapsForTargetStatement(SgStatement*): sourceStatement = %p = %s \n",sourceStatement,sourceStatement->
class_name().c_str());
10133 printf (
"In SageInterface::resetInternalMapsForTargetStatement(SgStatement*): sourceFile = %p \n",sourceFile);
10136 if (sourceFile != NULL)
10138 std::map<SgStatement*,MacroExpansion*> & macroExpansionMap = sourceFile->get_macroExpansionMap();
10140 if (macroExpansionMap.find(sourceStatement) != macroExpansionMap.end())
10142 MacroExpansion* macroExpansion = macroExpansionMap[sourceStatement];
10143 ROSE_ASSERT(macroExpansion != NULL);
10145 printf (
"In resetInternalMapsForTargetStatement(): macroExpansion = %p = %s \n",macroExpansion,macroExpansion->macro_name.c_str());
10147 if (macroExpansion->isTransformed ==
false)
10150 std::vector<SgStatement*> & associatedStatementVector = macroExpansion->associatedStatementVector;
10152 for (
size_t i = 0; i < associatedStatementVector.size(); i++)
10155 SgStatement* statement = associatedStatementVector[i];
10157 printf (
"Mark as transformation to be output: statement = %p = %s \n",statement,statement->
class_name().c_str());
10181 macroExpansion->isTransformed =
true;
10198#if REMOVE_STATEMENT_DEBUG || 0
10199 printf (
"In moveCommentsToNewStatement(): destinationStatementProceedsSourceStatement = %s \n",destinationStatementProceedsSourceStatement ?
"true" :
"false");
10200 printf (
" --- sourceStatement = %p = %s name = %s \n",sourceStatement,sourceStatement->
class_name().c_str(),
get_name(sourceStatement).c_str());
10201 printf (
" --- destinationStatement = %p = %s name = %s \n",destinationStatement,destinationStatement->
class_name().c_str(),
get_name(destinationStatement).c_str());
10209#if REMOVE_STATEMENT_DEBUG
10210 printf (
"Output the comments attached to sourceStatement: \n");
10212 printf (
"Output the comments attached to destinationStatement: \n");
10217 vector<int>::const_iterator j = indexList.begin();
10219 while (j != indexList.end())
10222 ROSE_ASSERT(destinationStatement->
get_file_info() != NULL);
10223#if REMOVE_STATEMENT_DEBUG || 0
10224 printf (
"Attaching comments to destinationStatement = %p = %s on file = %s line %d \n",
10225 destinationStatement,destinationStatement->
class_name().c_str(),
10226 destinationStatement->
get_file_info()->get_filenameString().c_str(),
10229 printf (
"(*comments)[*j]->getRelativePosition() = %s \n",PreprocessingInfo::relativePositionName((*comments)[*j]->getRelativePosition()).c_str());
10241 if (destinationStatementProceedsSourceStatement ==
true || isSgGlobal(destinationStatement) != NULL )
10247 auto commentPosition = (*comments)[*j]->getRelativePosition();
10248 if (commentPosition == PreprocessingInfo::before)
10251 (*comments)[*j]->setRelativePosition(PreprocessingInfo::after);
10253 else if (commentPosition == PreprocessingInfo::after ||
10254 commentPosition == PreprocessingInfo::end_of)
10260 ROSE_ASSERT(
false &&
"Comment relative position neither, before, after, nor end_of");
10272 (*comments)[*j]->setRelativePosition(PreprocessingInfo::inside);
10283 if ((*comments)[*j]->getRelativePosition() == PreprocessingInfo::before)
10291 ASSERT_require((*comments)[*j]->getRelativePosition() == PreprocessingInfo::after);
10292 (*comments)[*j]->setRelativePosition(PreprocessingInfo::before);
10301 if (targetInfoList==NULL)
10310 if( prevTargetAnchorComment==NULL)
10323 prevTargetAnchorComment = (*comments)[*j];
10328#if REMOVE_STATEMENT_DEBUG
10329 printf (
"Marking entry from comments list as NULL on sourceStatement = %p = %s \n",sourceStatement,sourceStatement->
class_name().c_str());
10331 (*comments)[*j] =
nullptr;
10338 for (
size_t n = 0; n < indexList.size(); n++)
10340#if REMOVE_STATEMENT_DEBUG || 0
10341 printf (
"Erase entry from comments list on comments->size() %" PRIuPTR
" \n",comments->size());
10343 bool modifiedList =
false;
10344 AttachedPreprocessingInfoType::iterator k = comments->begin();
10345 while (k != comments->end() && modifiedList ==
false)
10350 k = comments->erase(k);
10351 modifiedList =
true;
10370 ROSE_ASSERT(targetStmt != NULL);
10375#if REMOVE_STATEMENT_DEBUG || 0
10376 printf (
"TOP of findSurroundingStatementFromSameFile(): surroundingStatementPreceedsTargetStatement = %s \n",surroundingStatementPreceedsTargetStatement ?
"true" :
"false");
10379 std::set<SgStatement*> previousVisitedStatementSet;
10384 surroundingStatementPreceedsTargetStatement =
true;
10386#if REMOVE_STATEMENT_DEBUG
10387 printf (
" targetStmt->get_file_info()->get_file_id() = %d \n",targetStmt->
get_file_info()->get_file_id());
10389#if REMOVE_STATEMENT_DEBUG
10390 printf (
"Before loop: surroundingStatement = %p = %s name = %s surroundingStatement_fileId = %d \n",surroundingStatement,
10393 bool returningNullSurroundingStatement =
false;
10395 while ((returningNullSurroundingStatement ==
false) && (surroundingStatement != NULL) && surroundingStatement_fileId != targetStmt->
get_file_info()->get_file_id())
10403#if REMOVE_STATEMENT_DEBUG
10404 printf (
"In loop: after getPreviousStatement(): surroundingStatement = %p = %s name = %s \n",surroundingStatement,
10408 if (surroundingStatement == NULL)
10411#if REMOVE_STATEMENT_DEBUG
10412 printf (
" surroundingStatement_fileId set to Sg_File_Info::BAD_FILE_ID \n");
10417 surroundingStatement_fileId = surroundingStatement->
get_file_info()->get_file_id();
10418#if REMOVE_STATEMENT_DEBUG
10419 printf (
" surroundingStatement = %p = %s surroundingStatement->get_file_info()->get_file_id() = %d \n",
10420 surroundingStatement,surroundingStatement->
class_name().c_str(),surroundingStatement->
get_file_info()->get_file_id());
10424#if REMOVE_STATEMENT_DEBUG
10425 if (surroundingStatement != NULL)
10427 printf (
"Looping toward the top of the file for a statement to attach comments and CPP directives to: surroundingStatement = %p = %s file = %s file id = %d line = %d \n",
10428 surroundingStatement,surroundingStatement->
class_name().c_str(),
10429 surroundingStatement->
get_file_info()->get_filenameString().c_str(),
10435 printf (
"surroundingStatement == NULL \n");
10440 if (previousVisitedStatementSet.find(surroundingStatement) != previousVisitedStatementSet.end())
10442 printf (
"This statement has been previously visited: surroundingStatement = %p = %s \n",surroundingStatement,surroundingStatement->
class_name().c_str());
10444 printf (
"ERROR: SageInterface::findSurroundingStatementFromSameFile(): cannot located surrounding statement from same file (return NULL) \n");
10446 surroundingStatement = NULL;
10452 previousVisitedStatementSet.insert(surroundingStatement);
10456 if (surroundingStatement == NULL || isSgGlobal(surroundingStatement) != NULL)
10459#if REMOVE_STATEMENT_DEBUG
10460 printf (
"We just ran off the start (top) of the file... targetStmt = %p = %s \n",targetStmt,targetStmt->
class_name().c_str());
10466 surroundingStatementPreceedsTargetStatement =
false;
10469 surroundingStatement = targetStmt;
10470 SgStatement* previousStatement = surroundingStatement;
10474 std::set<SgStatement*> forwardVisitedStatementSet;
10477 while ( (surroundingStatement != NULL) && (surroundingStatement_fileId != targetStmt->
get_file_info()->get_file_id()) )
10480 if (forwardVisitedStatementSet.find(surroundingStatement) != forwardVisitedStatementSet.end())
10482 printf (
"This statement has been previously visited: surroundingStatement = %p = %s \n",surroundingStatement,surroundingStatement->
class_name().c_str());
10484 printf (
"ERROR: SageInterface::findSurroundingStatementFromSameFile(): cannot located surrounding statement from same file (return NULL) \n");
10486 surroundingStatement = NULL;
10492 forwardVisitedStatementSet.insert(surroundingStatement);
10495 previousStatement = surroundingStatement;
10498 if (surroundingStatement == NULL)
10501#if REMOVE_STATEMENT_DEBUG
10502 printf (
"We just ran off the end (bottom) of the file... \n");
10507 returningNullSurroundingStatement =
true;
10511 surroundingStatement_fileId = surroundingStatement->
get_file_info()->get_file_id();
10512#if REMOVE_STATEMENT_DEBUG
10513 printf (
"Looping toward the bottom of the file for a statement to attach comments and CPP directives to: surroundingStatement = %p = %s file = %s file id = %d line = %d \n",
10514 surroundingStatement,surroundingStatement->
class_name().c_str(),
10515 surroundingStatement->
get_file_info()->get_filenameString().c_str(),
10522 if (surroundingStatement == NULL)
10524#if REMOVE_STATEMENT_DEBUG
10525 printf (
"Resetting the surroundingStatement to the previousStatement = %p = %s \n",previousStatement,previousStatement->
class_name().c_str());
10527 surroundingStatement = previousStatement;
10530 if (surroundingStatement == targetStmt)
10534#if REMOVE_STATEMENT_DEBUG
10535 printf (
"Setting the surroundingStatement to be global scope \n");
10537 surroundingStatement = TransformationSupport::getGlobalScope(targetStmt);
10543 ROSE_ASSERT(surroundingStatement != NULL);
10547 printf (
"This is a special statement (not associated with the original source code, comment relocation is not supported for these statements) targetStmt file id = %d \n",targetStmt->
get_file_info()->get_file_id());
10548 surroundingStatement = NULL;
10551#if REMOVE_STATEMENT_DEBUG
10552 printf (
"BOTTOM of findSurroundingStatementFromSameFile(): surroundingStatementPreceedsTargetStatement = %s surroundingStatement = %p \n",surroundingStatementPreceedsTargetStatement ?
"true" :
"false",surroundingStatement);
10553 if (surroundingStatement != NULL)
10555 printf (
"surroundingStatement = %p = %s \n",surroundingStatement,surroundingStatement->
class_name().c_str());
10561 return surroundingStatement;
10571 virtual void visit(
SgNode* n) {
10575 Visitor().
traverse(root, postorder);
10585 ROSE_ASSERT(oldStmt);
10586 ROSE_ASSERT(newStmt);
10588 if (oldStmt == newStmt)
return;
10599 ROSE_ASSERT (f_do->get_body() == oldStmt);
10600 if (!isSgBasicBlock(newStmt))
10602 f_do->set_body(isSgBasicBlock(newStmt));
10619 printf (
"In SageInterface::replaceStatement(): physical_file_id = %d \n",physical_file_id);
10630 if (movePreprocessingInfoValue)
10638 printf (
"In SageInterface::replaceStatement(): calling moveUpPreprocessingInfo() changed to movePreprocessingInfo() \n");
10650 bool usePrepend =
true;
10652 movePreprocessingInfo ( oldStmt, newStmt, PreprocessingInfo::undef, PreprocessingInfo::undef, usePrepend );
10673 printf (
"In SageInterface::moveDeclarationToAssociatedNamespace(): declarationStatement = %p = %s \n",declarationStatement,declarationStatement->
class_name().c_str());
10674 printf (
" --- previousDeclarationStatement = %p = %s \n",previousDeclarationStatement,previousDeclarationStatement != NULL ? previousDeclarationStatement->
class_name().c_str() :
"null");
10675 printf (
" --- nextDeclarationStatement = %p \n",nextDeclarationStatement);
10676 printf (
" --- nextDeclarationStatement = %p = %s \n",nextDeclarationStatement, nextDeclarationStatement != NULL ? nextDeclarationStatement->
class_name().c_str() :
"null");
10680 if (previousDeclarationStatement != NULL)
10686 printf (
"There is no previous statement so there is no namespace to close off! \n");
10689 printf (
"Exiting as a test! \n");
10694 if (nextDeclarationStatement != NULL)
10701 printf (
"There is no next statement so there is no namespace to reopen! \n");
10705 printf (
"Exiting as a test! \n");
10710 if (previousDeclarationStatement != NULL && nextDeclarationStatement != NULL)
10714 printf (
"Identified the most common case... \n");
10719 printf (
"declarationScope = %p = %s \n",declarationScope,declarationScope->
class_name().c_str());
10723 printf (
"Exiting as a test! \n");
10729 if (previousDeclarationStatement != NULL && nextDeclarationStatement == NULL)
10733 printf (
"Found 2nd most common case: previousDeclarationStatement != NULL && nextDeclarationStatement == NULL \n");
10737 printf (
"Exiting as a test! \n");
10743 if (previousDeclarationStatement == NULL && nextDeclarationStatement == NULL)
10745 printf (
"This case should require no special handling, unless we are still in the wrong namespace \n");
10748 printf (
"Exiting as a test! \n");
10753 printf (
"This case should have been caught above! \n");
10756 printf (
"Exiting as a test! \n");
10763 if (declarationParent == NULL)
10766 printf (
"declarationStatement->get_parent() = %p = %s \n",declarationStatement->
get_parent(), (declarationStatement->
get_parent() != NULL) ? declarationStatement->
get_parent()->
class_name().c_str() :
"null");
10772 if (declarationParent != NULL)
10775 ROSE_ASSERT(declarationScope != NULL);
10778 if (namespaceDefinition != NULL)
10781 ROSE_ASSERT(namespaceDeclaration != NULL);
10783 printf (
"The declaration has been identified to be associuated with a valid namespace = %p = %s \n",namespaceDeclaration,namespaceDeclaration->
get_name().str());
10784 printf (
" --- declarationParent = %p = %s \n",declarationParent,declarationParent->
class_name().c_str());
10785 printf (
" --- Move declaration from scope = %p = %s to namespace = %p = %s \n",declarationParent,declarationParent->
class_name().c_str(),namespaceDeclaration,namespaceDeclaration->
get_name().str());
10788 printf (
"Exiting as a test! \n");
10795 printf (
"declaration is not associated with a namespace, so we don't have to wrap it: declarationScope = %p = %s \n",declarationScope,declarationScope->
class_name().c_str());
10802 printf (
"Warning: declarationParent == NULL: declarationStatement->get_parent() = %p = %s \n",declarationStatement->
get_parent(), (declarationStatement->
get_parent() != NULL) ? declarationStatement->
get_parent()->
class_name().c_str() :
"null");
10814 if (isSgTemplateInstantiationDefn(node) != NULL)
10817 printf (
"Note: In SageInterface::isTemplateInstantiationNode(): skipping SgTemplateInstantiationDefn \n");
10821 return isSgTemplateInstantiationDecl(node)
10824 || isSgTemplateInstantiationDefn(node)
10825 || isSgTemplateInstantiationFunctionDecl(node)
10826 || isSgTemplateInstantiationMemberFunctionDecl(node)
10827 || isSgTemplateInstantiationTypedefDeclaration(node)
10828 || isSgTemplateInstantiationDirectiveStatement(node)
10837SageInterface::isTemplateDeclarationNode(
SgNode* node)
10840 if (isSgTemplateDefinition(node) != NULL)
10843 printf (
"Note: In SageInterface::isTemplateDeclarationNode(): skipping SgTemplateDefinition \n");
10847 return isSgTemplateInstantiationDecl(node)
10850 || isSgTemplateInstantiationDefn(node)
10851 || isSgTemplateInstantiationFunctionDecl(node)
10852 || isSgTemplateInstantiationMemberFunctionDecl(node)
10853 || isSgTemplateInstantiationTypedefDeclaration(node)
10854 || isSgTemplateInstantiationDirectiveStatement(node)
10867 std::vector<SgDeclarationStatement*> templateInstantiationVector;
10879 if (declaration != NULL)
10881 templateInstantiationVector.push_back(declaration);
10890 std::cerr <<
"This feature for now is available with autotools only!" << std::endl;
10894 std::vector<SgDeclarationStatement*>::iterator j = templateInstantiationVector.begin();
10895 while (j != templateInstantiationVector.end())
10909 SgExpression * pattern_exp = isSgExpression(new_pattern);
10910 ROSE_ASSERT (anchor_exp != NULL);
10911 ROSE_ASSERT (pattern_exp != NULL);
10914 Rose_STL_Container<SgNode*> opaque_exp_list = NodeQuery::querySubTree(pattern_exp,V_SgExpression);
10915 for (
size_t i = 0; i<opaque_exp_list.size(); i++)
10917 SgExpression* opaque_exp = isSgExpression(opaque_exp_list[i]);
10918 ROSE_ASSERT (opaque_exp != NULL);
10919 if (opaque_exp->
variantT() == V_SgVariantExpression)
10928 return new_pattern;
10935 static int counter = 0;
10938 bool collision =
false;
10941 name =
"__" + baseName + boost::lexical_cast<string > (counter++) +
"__";
10947 collision = (nameSymbol != NULL);
10950 Rose_STL_Container<SgNode*> childScopes = NodeQuery::querySubTree(scope, V_SgScopeStatement);
10952 BOOST_FOREACH(
SgNode* childScope, childScopes)
10958 nameSymbol = childScopeStatement->lookup_symbol(
SgName(name),NULL,NULL);
10960 collision = collision || (nameSymbol != NULL);
10962 }
while (collision);
10972 SgType* variableType = expressionType;
10979 SgType* expressionBaseType = expressionType->
stripType(SgType::STRIP_TYPEDEF_TYPE | SgType::STRIP_REFERENCE_TYPE | SgType::STRIP_RVALUE_REFERENCE_TYPE);
10984 if (
SgArrayType* arrayType=isSgArrayType(expressionType)) {
10985 if(
SgArrayType* strippedArrayType = isSgArrayType(arrayType->stripType(SgType::STRIP_TYPEDEF_TYPE))) {
10986 SgType* strippedArrayBaseType = strippedArrayType->get_base_type();
10992 if (isSgPointerDerefExp(expression))
11000 ROSE_ASSERT(tempVarInitExpression != NULL);
11011 if (initializeInDeclaration)
11018 ROSE_ASSERT(tempVarDeclaration != NULL);
11021 if (reEvaluate != NULL)
11035 return std::make_pair(tempVarDeclaration, varRefExpression);
11048 SgType* variableType = expressionType;
11051 if (
SgArrayType* arrayType=isSgArrayType(expressionType))
11053 if(
SgArrayType* strippedArrayType = isSgArrayType(arrayType->stripType(SgType::STRIP_TYPEDEF_TYPE))) {
11054 SgType* strippedArrayBaseType = strippedArrayType->get_base_type();
11068 ROSE_ASSERT(tempVarDeclaration != NULL);
11072 return std::make_pair(tempVarDeclaration, varRefExpression);
11079 replaceExpressionInSgExpressionPtrList(
SgExpression* oldExp,
SgExpression* newExp, SgExpressionPtrList& lst,
bool replAll =
false)
11081 SgExpressionPtrList::iterator lim = lst.end();
11082 SgExpressionPtrList::iterator pos = lst.begin();
11087 pos = std::find(pos, lim, oldExp);
11089 if (pos != lim) { *pos = newExp; ++pos; chg =
true; }
11090 }
while (replAll && (pos != lim));
11104 ROSE_ASSERT(oldExp);
11105 ROSE_ASSERT(newExp);
11106 if (oldExp==newExp)
return;
11108 if (isSgVarRefExp(newExp))
11112 ROSE_ASSERT(parent!=NULL);
11118 if (isSgExprStatement(parent)) {
11119 isSgExprStatement(parent)->set_expression(newExp);
11120 }
else if (isSgForStatement(parent)) {
11121 ROSE_ASSERT (isSgForStatement(parent)->get_increment() == oldExp);
11122 isSgForStatement(parent)->set_increment(newExp);
11125 if(matlabFor->get_index() == oldExp)
11126 matlabFor->set_index(newExp);
11127 else if(matlabFor->get_range() == oldExp)
11128 matlabFor->set_range(newExp);
11130 ROSE_ASSERT(!
"sub-expression not found");
11132 if(jovFor->get_initialization() == oldExp)
11133 jovFor->set_initialization(newExp);
11134 else if(jovFor->get_while_expression() == oldExp)
11135 jovFor->set_while_expression(newExp);
11136 else if(jovFor->get_by_or_then_expression() == oldExp)
11137 jovFor->set_by_or_then_expression(newExp);
11139 ROSE_ASSERT(!
"sub-expression not found");
11140 }
else if (
SgRangeExp* rngexp = isSgRangeExp(parent)) {
11141 if (rngexp->get_start() == oldExp)
11142 rngexp->set_start(newExp);
11143 else if (rngexp->get_end() == oldExp)
11144 rngexp->set_end(newExp);
11145 else if (rngexp->get_stride() == oldExp)
11146 rngexp->set_stride(newExp);
11148 ROSE_ASSERT(!
"sub-expression not found");
11149 }
else if (isSgReturnStmt(parent)) {
11150 isSgReturnStmt(parent)->set_expression(newExp);
11151 }
else if (isSgBinaryOp(parent)!=NULL) {
11152 if (oldExp==isSgBinaryOp(parent)->get_lhs_operand()) {
11154 }
else if (oldExp==isSgBinaryOp(parent)->get_rhs_operand()) {
11159 }
else if (isSgUnaryOp(parent)!=NULL){
11160 if (oldExp==isSgUnaryOp(parent)->get_operand_i())
11164 }
else if (isSgConditionalExp(parent) != NULL) {
11174 }
else if (isSgExprListExp(parent) != NULL) {
11175 SgExpressionPtrList& explist = isSgExprListExp(parent)->get_expressions();
11176 for (Rose_STL_Container<SgExpression*>::iterator i=explist.begin();i!=explist.end();i++) {
11177 if (isSgExpression(*i)==oldExp) {
11183 }
else if (isSgValueExp(parent)) {
11188 ROSE_ASSERT(oldExp == actexp->get_expression());
11189 actexp->set_expression(newExp);
11191 if (oldExp == attrexp->get_object()) {
11192 attrexp->set_object(newExp);
11193 }
else if (oldExp == attrexp->get_args()) {
11195 ASSERT_not_null(newLst);
11197 attrexp->set_args(newLst);
11202 }
else if ((parentExp=isSgExpression(parent)) != NULL) {
11205 ROSE_ASSERT (worked);
11206 }
else if (isSgInitializedName(parent)) {
11208 if (oldExp == initializedNameParent->get_initializer()) {
11210 ROSE_ASSERT(isSgInitializer(newExp));
11211 initializedNameParent->set_initializer(isSgInitializer(newExp));
11216 }
else if (isSgCaseOptionStmt(parent)) {
11218 if (oldExp == case_stmt->
get_key()) {
11220 }
else if(oldExp == case_stmt->get_key_range_end()) {
11221 case_stmt->set_key_range_end(newExp);
11225 }
else if (isSgProcessControlStatement(parent)) {
11227 if (oldExp == ctrl_stmt->get_quiet()) {
11228 ctrl_stmt->set_quiet(newExp);
11229 }
else if (oldExp == ctrl_stmt->get_code()) {
11230 ctrl_stmt->set_code(newExp);
11234 }
else if (isSgFortranDo(parent)) {
11236 if (oldExp == fortranDo->get_initialization()) {
11237 fortranDo->set_initialization(newExp);
11238 }
else if(oldExp == fortranDo->get_bound()) {
11239 fortranDo->set_bound(newExp);
11240 }
else if (oldExp == fortranDo->get_increment()) {
11241 fortranDo->set_increment(newExp);
11247 ROSE_ASSERT(oldExp == stm->get_condition());
11248 stm->set_condition(newExp);
11251 ROSE_ASSERT(oldExp == ptype->get_modexpr());
11252 ptype->set_modexpr(newExp);
11255 ROSE_ASSERT(oldExp == stm->get_time());
11256 stm->set_time(newExp);
11258 ROSE_ASSERT(oldExp == clause->get_size());
11259 clause->set_size(newExp);
11261 ROSE_ASSERT(oldExp == dcl->get_renamed());
11262 dcl->set_renamed(newExp);
11264 ROSE_ASSERT(oldExp == dcl->get_entryBarrier());
11265 dcl->set_entryBarrier(newExp);
11267 ROSE_ASSERT(oldExp == stm->get_guard());
11268 stm->set_guard(newExp);
11270 ROSE_ASSERT(oldExp == delc->get_delta());
11271 delc->set_delta(newExp);
11273 ROSE_ASSERT(oldExp == digc->get_digits());
11274 digc->set_digits(newExp);
11276 replaceExpressionInSgExpressionPtrList(oldExp, newExp, disc->get_discriminants());
11278 ROSE_ASSERT(oldExp == rngc->get_range());
11279 rngc->set_range(newExp);
11281 replaceExpressionInSgExpressionPtrList(oldExp, newExp, idxc->get_indexRanges());
11283 ROSE_ASSERT(oldExp == vtdcl->get_discriminant());
11284 vtdcl->set_discriminant(newExp);
11286 ROSE_ASSERT(oldExp == clause->get_alignment());
11287 clause->set_alignment(newExp);
11290 if (newLst && (oldExp == vtwhen->get_choices()))
11291 vtwhen->set_choices(newLst);
11295 if (oldExp == clause->get_offset())
11296 clause->set_offset(newExp);
11297 else if (oldExp == clause->get_range() && isSgRangeExp(newExp))
11298 clause->set_range(isSgRangeExp(newExp));
11299 else if (oldExp == clause->get_component() && isSgVarRefExp(newExp))
11300 clause->set_component(isSgVarRefExp(newExp));
11304 if (oldExp == rendcl->get_renamed_function())
11305 rendcl->set_renamed_function(newExp);
11309 cerr<<
"SageInterface::replaceExpression(). Unhandled parent expression type of SageIII enum value: " <<parent->
class_name()<<endl;
11324 return Rose::getNextStatement(currentStmt);
11333 return isSgIntVal(e) && isSgIntVal(e)->get_value() == value;
11338 ROSE_ASSERT(func1&& func2);
11339 bool result =
false;
11340 if (func1 == func2)
11346 if (func1->get_name() == func2->get_name())
11351 if (func1->get_qualified_name().getString() +
11352 func1->get_mangled_name().getString() ==
11353 func2->get_qualified_name().getString() +
11354 func2->get_mangled_name().getString()
11360 if (func1->get_name() == func2->get_name())
11365 cout<<
"Error: SageInterface::isSameFunction(): unhandled language"<<endl;
11376 bool result =
false;
11377 ROSE_ASSERT(stmt != NULL);
11379 ROSE_ASSERT(p_scope != NULL);
11384 if (stmtlist[stmtlist.size()-1] == stmt)
11390 if (stmtlist[stmtlist.size()-1] == stmt)
11395 if (stmtlist[stmtlist.size()-1] == stmt)
11407 virtual void visit(
SgNode* n) {
11409 if (valueExp != NULL) {
11410 valueExp->set_originalExpressionTree(NULL);
11414 if (cast_exp != NULL) {
11415 cast_exp->set_originalExpressionTree(NULL);
11420 Visitor().traverse(top, preorder);
11425 while (s && !isSgSwitchStatement(s)) {
11429 return isSgSwitchStatement(s);
11434 while (s && !isSgOmpClauseBodyStatement(s)) {
11440 return isSgOmpClauseBodyStatement(s);
11446 for (; s; s = isSgStatement(s->
get_parent())) {
11451 case V_SgDoWhileStmt: {
11452 if (label.empty()) {
11457 case V_SgForStatement: {
11458 if (label.empty()) {
11463 case V_SgFortranDo:
11464 case V_SgFortranNonblockedDo: {
11465 if (label.empty() ||
11466 label == isSgFortranDo(sc)->get_string_label()) {
11471 case V_SgWhileStmt: {
11472 if (label.empty() ||
11473 label == isSgWhileStmt(sc)->get_string_label()) {
11478 case V_SgSwitchStatement: {
11479 if (stopOnSwitches)
return sc;
11482 case V_SgJavaForEachStatement: {
11483 if (label.empty()) {
11488 case V_SgJavaLabelStatement: {
11489 if (label.empty() ||
11490 label == isSgJavaLabelStatement(sc)->get_label().getString()) {
11506 virtual void visit(
SgNode* n) {
11507 if (isSgBasicBlock(n)) {
11509 bool changes =
true;
11512 for (SgStatementPtrList::iterator i = bb->
get_statements().begin();
11514 if (isSgGotoStatement(*i)) {
11516 SgStatementPtrList::iterator inext = i;
11520 if (!isSgLabelStatement(*inext))
11535 RemoveJumpsToNextStatementVisitor().traverse(top, postorder);
11544 ROSE_ASSERT (parent);
11548 ROSE_ASSERT (bb || fis);
11549 SgStatementPtrList& siblings =
11551 SgStatementPtrList::iterator j =
11552 std::find(siblings.begin(), siblings.end(), stmt);
11553 ROSE_ASSERT (j != siblings.end());
11566 SgLabelStatementPtrSet& used;
11567 SgLabelStatementPtrSet& all;
11570 FindUsedAndAllLabelsVisitor(SgLabelStatementPtrSet& used,
11571 SgLabelStatementPtrSet& all):
11572 used(used), all(all) {}
11574 virtual void visit(
SgNode* n) {
11575 if (isSgGotoStatement(n)) {
11576 used.insert(isSgGotoStatement(n)->get_label());
11578 if (isSgLabelStatement(n)) {
11579 all.insert(isSgLabelStatement(n));
11584 SgLabelStatementPtrSet used;
11585 SgLabelStatementPtrSet unused;
11586 FindUsedAndAllLabelsVisitor(used, unused).traverse(top, preorder);
11588 for (SgLabelStatementPtrSet::iterator i = used.begin();
11589 i != used.end(); ++i) {
11590 assert (unused.find(*i) != unused.end());
11603 for (SgLabelStatementPtrSet::iterator i = unused.begin();
11604 i != unused.end(); ++i) {
11612 l_stmt->set_statement(NULL);
11622 if (isSgWhileStmt(loopStmt))
return isSgWhileStmt(loopStmt)->
get_body();
11623 if (isSgForStatement(loopStmt))
return isSgForStatement(loopStmt)->
get_loop_body();
11624 if (isSgDoWhileStmt(loopStmt))
return isSgDoWhileStmt(loopStmt)->
get_body();
11626 ROSE_ASSERT (!
"Bad loop kind");
11631 if (isSgWhileStmt(loopStmt)) {
11632 isSgWhileStmt(loopStmt)->
set_body(body);
11633 }
else if (isSgForStatement(loopStmt)) {
11635 }
else if (isSgDoWhileStmt(loopStmt)) {
11636 isSgDoWhileStmt(loopStmt)->
set_body(body);
11638 ROSE_ASSERT (!
"Bad loop kind");
11644 if (isSgWhileStmt(loopStmt))
return isSgWhileStmt(loopStmt)->
get_condition();
11645 if (isSgForStatement(loopStmt))
return isSgForStatement(loopStmt)->get_test();
11646 if (isSgDoWhileStmt(loopStmt))
return isSgDoWhileStmt(loopStmt)->
get_condition();
11648 ROSE_ASSERT (!
"Bad loop kind");
11653 if (isSgWhileStmt(loopStmt)) {
11655 }
else if (isSgForStatement(loopStmt)) {
11656 isSgForStatement(loopStmt)->set_test(cond);
11657 }
else if (isSgDoWhileStmt(loopStmt)) {
11660 ROSE_ASSERT (!
"Bad loop kind");
11669 SgCastExp* cast_exp = isSgCastExp(exp);
11670 if (cast_exp != NULL)
11673 assert(operand != 0);
11674 return SkipCasting(operand);
11683 ROSE_ASSERT(loop!=NULL);
11685 SgStatementPtrList &init = loop ->get_init_stmt();
11686 if (init.size() !=1)
11697 ROSE_ASSERT(ivarname != NULL);
11699 if (isSgAssignInitializer(initor))
11701 lbast = isSgAssignInitializer(initor)->
get_operand();
11716 ROSE_ASSERT(funcDef!=NULL);
11718 ROSE_ASSERT(funcBody!=NULL);
11720 std::ostringstream os;
11721 os<<ivarname->get_name().getString();
11726 if (visibleSym != NULL)
11737 Rose_STL_Container<SgNode*> varRefs = NodeQuery::querySubTree(loop,V_SgVarRefExp);
11738 for (Rose_STL_Container<SgNode *>::iterator i = varRefs.begin(); i != varRefs.end(); i++)
11741 if (vRef->get_symbol()==osymbol)
11742 vRef->set_symbol(nsymbol);
11747 init.push_back(ninit);
11754 trans_records.forLoopInitNormalizationTable[loop] =
true;
11755 trans_records.forLoopInitNormalizationRecord[loop] = make_pair (decl, ndecl) ;
11768 ROSE_ASSERT (loop != NULL);
11770 if (!trans_records.forLoopInitNormalizationTable[loop])
11775 ROSE_ASSERT (decl!= NULL);
11776 ROSE_ASSERT (ndecl!= NULL);
11780 SgStatementPtrList &init = loop ->get_init_stmt();
11781 ROSE_ASSERT(init.size() ==1);
11786 ROSE_ASSERT (exp_stmt != NULL);
11787 SgAssignOp* assign_op = isSgAssignOp(exp_stmt->get_expression());
11788 ROSE_ASSERT (assign_op != NULL);
11795 init.push_back(decl);
11806 Rose_STL_Container<SgNode*> varRefs = NodeQuery::querySubTree(loop,V_SgVarRefExp);
11807 for (Rose_STL_Container<SgNode *>::iterator i = varRefs.begin(); i != varRefs.end(); i++)
11810 if (vRef->get_symbol()==osymbol)
11811 vRef->set_symbol(nsymbol);
11815 trans_records.forLoopInitNormalizationTable[loop] =
false;
11821 ROSE_ASSERT(loop != NULL);
11828 if (test_stmt!=NULL)
11830 if (isSgNullStatement(test_stmt))
11836 if (isSgBinaryOp(test))
11840 ROSE_ASSERT(testlhs && testrhs);
11845 SgVarRefExp* testlhs_var = isSgVarRefExp(SkipCasting(testlhs));
11846 if (testlhs_var == NULL )
11849 if (var_symbol==NULL)
11853 case V_SgLessThanOp:
11858 case V_SgGreaterThanOp:
11862 case V_SgLessOrEqualOp:
11863 case V_SgGreaterOrEqualOp:
11864 case V_SgNotEqualOp:
11873 ROSE_ASSERT(loop != NULL);
11877 if (isSgBinaryOp(test))
11881 ROSE_ASSERT(testlhs && testrhs);
11886 SgVarRefExp* testlhs_var = isSgVarRefExp(SkipCasting(testlhs));
11887 if (testlhs_var == NULL )
11890 if (var_symbol==NULL)
11896 ROSE_ASSERT(incr != NULL);
11898 case V_SgPlusPlusOp:
11901 SgVarRefExp* incr_var = isSgVarRefExp(SkipCasting(isSgPlusPlusOp(incr)->get_operand()));
11902 if (incr_var == NULL)
return false;
11903 if ( incr_var->get_symbol() != var_symbol)
11909 case V_SgMinusMinusOp:
11912 SgVarRefExp* incr_var = isSgVarRefExp(SkipCasting(isSgMinusMinusOp(incr)->get_operand()));
11913 if (incr_var == NULL)
return false;
11914 if ( incr_var->get_symbol() != var_symbol)
11920 case V_SgMinusAssignOp:
11922 SgVarRefExp* incr_var = isSgVarRefExp(SkipCasting(isSgMinusAssignOp(incr)->get_lhs_operand()));
11924 ROSE_ASSERT (rhs != NULL);
11925 if (incr_var == NULL)
return false;
11926 if ( incr_var->get_symbol() != var_symbol)
11933 case V_SgPlusAssignOp:
11946 ROSE_ASSERT(loop != NULL);
11964 ROSE_ASSERT(body!=NULL);
11982 ROSE_ASSERT (loop != NULL);
11984 if (isSgNullExpression(e_3))
11987 loop->set_increment(iv);
12002 ROSE_ASSERT(func!=NULL);
12003 AstInterfaceImpl faImpl(func->get_definition()->
get_body());
12004 AstInterface fa(&faImpl);
12005 ArrayAnnotation* annot = ArrayAnnotation::get_inst();
12006 ArrayInterface array_interface (*annot);
12007 array_interface.initialize(fa, AstNodePtrImpl(func->get_definition()));
12008 array_interface.observe(fa);
12009 LoopTransformInterface :: set_astInterface(fa);
12010 LoopTransformInterface :: set_arrayInterface(&array_interface);
12014 AstNodePtr result = AstNodePtrImpl(loop->
get_parent()) ;
12016 LoopUnrolling lu(unrolling_factor);
12019 result = lu(lpTrans, result);
12063#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
12065 if (unrolling_factor <= 1)
12086 cerr<<
"Error in SageInterface::loopUnrolling(): target loop is not canonical."<<endl;
12090 ROSE_ASSERT(ivar&& lb && ub && step);
12091 ROSE_ASSERT(isSgBasicBlock(orig_body));
12094 bool needFringe =
true;
12095 SgForStatement* fringe_loop = deepCopy<SgForStatement>(target_loop);
12113 ROSE_ASSERT(scope != NULL);
12117 attachComment(fringe_decl,
"iter_count = (ub-lb+1)%step ==0?(ub-lb+1)/step: (ub-lb+1)/step+1;");
12118 attachComment(fringe_decl,
"fringe = iter_count%unroll_factor==0 ? 0:unroll_factor*step");
12125 ConstantFolding::constantFoldingOptimization(fringe_decl,
false);
12127 ROSE_ASSERT(ivarname != NULL);
12131 if (isSgIntVal(init1->get_operand_i()))
12132 if (isSgIntVal(init1->get_operand_i())->get_value() == 0)
12133 needFringe =
false;
12137 ROSE_ASSERT(ub_bin_op);
12147 ROSE_ASSERT(step_bin_op != NULL);
12150 bool isPlus =
false;
12151 if (isSgPlusAssignOp(step_bin_op))
12153 else if (isSgMinusAssignOp(step_bin_op))
12157 cerr<<
"Error in SageInterface::loopUnrolling(): illegal incremental exp of a canonical loop"<<endl;
12163 for (
size_t i =1; i<unrolling_factor; i++)
12167 std::vector<SgVarRefExp*> refs = querySubTree<SgVarRefExp> (body, V_SgVarRefExp);
12168 for (std::vector<SgVarRefExp*>::iterator iter = refs.begin(); iter !=refs.end(); iter++)
12197 ConstantFolding::constantFoldingOptimization(scope,
false);
12209static size_t myfactorial (
size_t n)
12212 for (
size_t i=2; i<=n; i++)
12223std::vector<size_t> getPermutationOrder(
size_t n,
size_t lexicoOrder)
12225 size_t k = lexicoOrder;
12226 std::vector<size_t> s(n);
12228 for (
size_t i=0; i<n; i++)
12232 size_t factorial = myfactorial(n-1);
12234 if (k/n>=factorial)
12236 printf(
"Error: in getPermutationOrder(), lexicoOrder is larger than n!-1\n");
12252 for (
size_t j=0; j<n-1; j++)
12256 int tempj = (k/factorial) % (n - j);
12259 int temps = s[j+tempj];
12262 for (
size_t i=j+tempj; i>j; i--)
12269 factorial = factorial /(n-(j+1));
12272 for (
size_t i = 0; i<n; i++)
12304 ROSE_ASSERT(loopNest != NULL);
12305 ROSE_ASSERT(targetLevel >0);
12312 std::vector<SgForStatement* > loops= SageInterface::querySubTree<SgForStatement>(loopNest,V_SgForStatement);
12313 ROSE_ASSERT(loops.size()>=targetLevel);
12331 cerr<<
"Error in SageInterface::loopTiling(): target loop is not canonical."<<endl;
12335 ROSE_ASSERT(ivar&& lb && ub && step);
12343 parent = isSgLocatedNode(loopNest ->get_parent());
12345 ROSE_ASSERT(parent!= NULL);
12347 string ivar2_name =
"_lt_var_"+ivar->get_name().getString();
12357 if (isSgBinaryOp(orig_test))
12359 if (isSgLessOrEqualOp(orig_test))
12361 else if (isSgGreaterOrEqualOp(orig_test))
12367 cerr<<
"Error: illegal condition operator for a canonical loop"<<endl;
12374 cerr<<
"Error: illegal condition expression for a canonical loop"<<endl;
12378 ROSE_ASSERT(cond_stmt != NULL);
12383 SgExpression* orig_incr_exp = target_loop->get_increment();
12384 if( isSgPlusAssignOp(orig_incr_exp))
12388 else if (isSgMinusAssignOp(orig_incr_exp))
12394 cerr<<
"Error: illegal increment expression for a canonical loop"<<endl;
12406 ROSE_ASSERT(assign_op);
12410 ROSE_ASSERT(bin_op);
12430 if (lexicoOrder == 0)
12433 ROSE_ASSERT(loop != NULL);
12435 ROSE_ASSERT (depth >1);
12436 ROSE_ASSERT(lexicoOrder<myfactorial(depth));
12439 std::vector<SgForStatement* > loopNest = SageInterface::querySubTree<SgForStatement>(loop,V_SgForStatement);
12440 ROSE_ASSERT(loopNest.size()>=depth);
12441 std::vector<std::vector<SgNode*> > loopHeads;
12442 for (std::vector<SgForStatement* > ::iterator i = loopNest.begin(); i!= loopNest.end(); i++)
12445 std::vector<SgNode*> head;
12447 head.push_back(cur_loop->get_test());
12448 head.push_back(cur_loop->get_increment());
12449 loopHeads.push_back(head);
12453 std::vector<size_t> changedOrder = getPermutationOrder (depth, lexicoOrder);
12456 for (
size_t i=0; i<depth; i++)
12459 if (i != changedOrder[i])
12462 std::vector<SgNode*> newhead = loopHeads[changedOrder[i]];
12470 init->set_parent(cur_loop);
12475 cur_loop->set_test(test);
12483 cur_loop->set_increment(incr);
12497 ROSE_ASSERT(loop != NULL);
12503 SgAssignOp* assign_op = isSgAssignOp (do_loop->get_initialization());
12504 ROSE_ASSERT (assign_op != NULL);
12506 ROSE_ASSERT (var != NULL);
12507 ivarname = var->get_symbol()->get_declaration();
12508 ROSE_ASSERT (ivarname != NULL);
12522 SgStatementPtrList & init = fs->get_init_stmt();
12523 if (init.size() !=1)
12525 cerr<<
"SageInterface::getLoopIndexVariable(), no or more than one initialization statements are encountered. Not supported yet "<<endl;
12536 if (isSgVariableDeclaration(init1))
12540 ROSE_ASSERT(ivarname != NULL);
12547 SgVarRefExp* var = isSgVarRefExp(SkipCasting(ivarast));
12550 ivarname = var->get_symbol()->get_declaration();
12557 if (
SgCommaOpExp* comma_exp = isSgCommaOpExp(exp_stmt->get_expression()))
12564 SgVarRefExp* var = isSgVarRefExp(assign_op->get_lhs_operand());
12567 ivarname = var->get_symbol()->get_declaration();
12575 mlog[Sawyer::Message::Common::WARN] <<
"Warning: SageInterface::getLoopIndexVariable(). Unhandled init_stmt type of SgForStatement"<<endl;
12576 mlog[Sawyer::Message::Common::WARN] <<
"Init statement is :"<<init1->
class_name() <<
" " <<init1->
unparseToString()<<endl;
12594 ROSE_ASSERT (ivar != NULL);
12595 ROSE_ASSERT (subtree_root != NULL);
12596 bool result =
false;
12601 if (i_index == ivar)
12621 ROSE_ASSERT (loop !=NULL);
12622 SgStatementPtrList& stmt_list = loop->get_init_stmt();
12623 if (stmt_list.size() >1)
return true;
12624 if (stmt_list.size() == 0)
return false;
12629 if (decl_stmt != NULL)
12634 ROSE_ASSERT (exp_stmt != NULL);
12635 if (isSgCommaOpExp (exp_stmt->get_expression()) )
12645 ROSE_ASSERT(loop != NULL);
12653 SgAssignOp* init_assign = isSgAssignOp (init);
12658 bool isCase1=
false;
12663 ivarname = var->get_symbol()->get_declaration();
12665 if (ivarname && lbast )
12677 SgBinaryOp* test = isSgBinaryOp(fs->get_test_expr());
12681 case V_SgLessOrEqualOp:
12682 if (isInclusiveUpperBound != NULL)
12683 *isInclusiveUpperBound =
true;
12684 if (hasIncrementalIterationSpace != NULL)
12685 *hasIncrementalIterationSpace =
true;
12687 case V_SgLessThanOp:
12688 if (isInclusiveUpperBound != NULL)
12689 *isInclusiveUpperBound =
false;
12690 if (hasIncrementalIterationSpace != NULL)
12691 *hasIncrementalIterationSpace =
true;
12693 case V_SgGreaterOrEqualOp:
12694 if (isInclusiveUpperBound != NULL)
12695 *isInclusiveUpperBound =
true;
12696 if (hasIncrementalIterationSpace != NULL)
12697 *hasIncrementalIterationSpace =
false;
12699 case V_SgGreaterThanOp:
12700 if (isInclusiveUpperBound != NULL)
12701 *isInclusiveUpperBound =
false;
12702 if (hasIncrementalIterationSpace != NULL)
12703 *hasIncrementalIterationSpace =
false;
12712 if (testvar == NULL)
12718 ubast = loop->get_bound();
12720 if (isInclusiveUpperBound != NULL)
12721 *isInclusiveUpperBound =
true;
12724 ROSE_ASSERT (incr != NULL);
12725 if (isSgNullExpression(incr))
12727 cerr<<
"Error:isCanonicalDoLoop() found NULL increment expression. Please call doLoopNormalization() first!"<<endl;
12728 ROSE_ASSERT (
false);
12730 if (hasIncrementalIterationSpace != NULL)
12732 *hasIncrementalIterationSpace =
true;
12734 if (
SgIntVal* i_v = isSgIntVal(incr))
12736 if (i_v->get_value()<0)
12737 *hasIncrementalIterationSpace =
false;
12743 case V_SgPlusAssignOp:
12744 case V_SgMinusAssignOp:
12745 incr_var = isSgVarRefExp(SkipCasting(isSgBinaryOp(incr)->get_lhs_operand()));
12748 case V_SgPlusPlusOp:
12749 case V_SgMinusMinusOp:
12750 incr_var = isSgVarRefExp(SkipCasting(isSgUnaryOp(incr)->get_operand()));
12756 if (incr_var == NULL)
12770 if (body != NULL) {
12771 *body = fs->get_body();
12808 ROSE_ASSERT (s != NULL);
12811 std::set<SgNode*> bset = SgNodeHelper::loopRelevantBreakStmtNodes (s);
12812 if (bset.size()!=0 )
12826 ROSE_ASSERT(loop != NULL);
12837 SgStatementPtrList & init = fs->get_init_stmt();
12838 if (init.size() !=1)
12841 SgExpression* ivarast=NULL, *lbast=NULL, *ubast=NULL, *stepast=NULL;
12844 bool isCase1=
false, isCase2=
false;
12846 if (isSgVariableDeclaration(init1))
12850 ROSE_ASSERT(ivarname != NULL);
12852 if (isSgAssignInitializer(initor))
12854 lbast = isSgAssignInitializer(initor)->
get_operand();
12860 SgVarRefExp* var = isSgVarRefExp(SkipCasting(ivarast));
12863 ivarname = var->get_symbol()->get_declaration();
12868 ROSE_ASSERT(!(isCase1&&isCase2));
12870 if (!(isCase1||isCase2))
12882 case V_SgLessOrEqualOp:
12883 if (isInclusiveUpperBound != NULL)
12884 *isInclusiveUpperBound =
true;
12885 if (hasIncrementalIterationSpace != NULL)
12886 *hasIncrementalIterationSpace =
true;
12888 case V_SgLessThanOp:
12889 if (isInclusiveUpperBound != NULL)
12890 *isInclusiveUpperBound =
false;
12891 if (hasIncrementalIterationSpace != NULL)
12892 *hasIncrementalIterationSpace =
true;
12894 case V_SgGreaterOrEqualOp:
12895 if (isInclusiveUpperBound != NULL)
12896 *isInclusiveUpperBound =
true;
12897 if (hasIncrementalIterationSpace != NULL)
12898 *hasIncrementalIterationSpace =
false;
12900 case V_SgGreaterThanOp:
12901 if (isInclusiveUpperBound != NULL)
12902 *isInclusiveUpperBound =
false;
12903 if (hasIncrementalIterationSpace != NULL)
12904 *hasIncrementalIterationSpace =
false;
12913 if (testvar == NULL)
12937 case V_SgPlusAssignOp:
12938 case V_SgMinusAssignOp:
12939 incr_var = isSgVarRefExp(SkipCasting(isSgBinaryOp(incr)->get_lhs_operand()));
12942 case V_SgPlusPlusOp:
12943 case V_SgMinusMinusOp:
12944 incr_var = isSgVarRefExp(SkipCasting(isSgUnaryOp(incr)->get_operand()));
12947 case V_SgAssignOp: {
12948 incr_var=isSgVarRefExp(SkipCasting(isSgBinaryOp(incr)->get_lhs_operand()));
12949 if(incr_var == NULL)
12951 SgAddOp* addOp=isSgAddOp(SkipCasting(isSgBinaryOp(incr)->get_rhs_operand()));
12952 SgSubtractOp* subtractOp=isSgSubtractOp(SkipCasting(isSgBinaryOp(incr)->get_rhs_operand()));
12956 else if(subtractOp)
12957 arithOp=subtractOp;
12960 ROSE_ASSERT(arithOp!=0);
12961 if(
SgVarRefExp* varRefExp=isSgVarRefExp(SkipCasting(isSgBinaryOp(arithOp)->get_lhs_operand()))) {
12963 incr_var=varRefExp;
12965 }
else if(
SgVarRefExp* varRefExp=isSgVarRefExp(SkipCasting(isSgBinaryOp(arithOp)->get_rhs_operand()))) {
12966 if(isSgAddOp(arithOp)) {
12968 incr_var=varRefExp;
12978 if (incr_var == NULL)
12999 if (body != NULL) {
13008 ROSE_ASSERT(loop != NULL);
13009 ROSE_ASSERT(lb != NULL);
13014 if (forstmt != NULL)
13019 Rose_STL_Container<SgNode* > testList = NodeQuery::querySubTree( *((forstmt->get_init_stmt()).begin()), V_SgAssignOp);
13020 if (testList.size()>0)
13022 ROSE_ASSERT(testList.size()==1);
13023 SgAssignOp * assignop = isSgAssignOp((*testList.begin()));
13024 ROSE_ASSERT(assignop);
13034 Rose_STL_Container<SgNode* > testList = NodeQuery::querySubTree( *((forstmt->get_init_stmt()).begin()), V_SgAssignInitializer );
13035 ROSE_ASSERT(testList.size()==1);
13037 ROSE_ASSERT(init != NULL);
13038 init->set_operand(lb);
13043 else if (dostmt != NULL)
13046 ROSE_ASSERT (init != NULL);
13048 ROSE_ASSERT (a_op!=NULL);
13055 cerr<<
"Error. SageInterface::setLoopLowerBound(), illegal loop type:"<< loop->
class_name()<<endl;
13056 ROSE_ASSERT (
false);
13063 ROSE_ASSERT(loop != NULL);
13064 ROSE_ASSERT(ub != NULL);
13068 if (forstmt != NULL)
13071 SgBinaryOp * binop= isSgBinaryOp(isSgExprStatement(forstmt->get_test())->get_expression());
13072 ROSE_ASSERT(binop != NULL);
13076 else if (dostmt != NULL)
13078 dostmt->set_bound(ub);
13084 cerr<<
"Error. SageInterface::setLoopUpperBound(), illegal loop type:"<< loop->
class_name()<<endl;
13085 ROSE_ASSERT (
false);
13093 ROSE_ASSERT(loop != NULL);
13094 ROSE_ASSERT(stride != NULL);
13098 if (dostmt != NULL)
13100 dostmt->set_increment(stride);
13104 else if (forstmt != NULL)
13108 Rose_STL_Container<SgNode*> testList = NodeQuery::querySubTree( forstmt->get_increment(), V_SgPlusPlusOp);
13109 if (testList.size()>0)
13111 ROSE_ASSERT(testList.size() == 1);
13113 (isSgPlusPlusOp( *testList.begin())->
get_operand()));
13115 forstmt->set_increment(plusassignop);
13119 testList = NodeQuery::querySubTree(forstmt->get_increment(), V_SgMinusMinusOp);
13120 if (testList.size()>0)
13122 ROSE_ASSERT(testList.size()==1);
13124 (isSgMinusMinusOp(*testList.begin())->
get_operand()));
13126 forstmt->set_increment(plusassignop);
13130 testList = NodeQuery::querySubTree( forstmt->get_increment(), V_SgPlusAssignOp);
13131 if (testList.size()>0)
13133 ROSE_ASSERT(testList.size()==1);
13134 SgPlusAssignOp * assignop = isSgPlusAssignOp(*(testList.begin()));
13135 ROSE_ASSERT(assignop!=NULL);
13140 testList = NodeQuery::querySubTree(forstmt->get_increment(), V_SgMinusAssignOp);
13141 if (testList.size()>0)
13143 ROSE_ASSERT(testList.size()==1);
13146 SgExprStatement* exprstmt = isSgExprStatement((*testList.begin())->get_parent());
13147 ROSE_ASSERT(exprstmt !=NULL);
13149 exprstmt->set_expression(plusassignop);
13160 testList = NodeQuery::querySubTree(forstmt->get_increment(), V_SgAddOp);
13161 if (testList.size()>0)
13163 ROSE_ASSERT(testList.size()==1);
13165 SgAddOp * addop = isSgAddOp(*(testList.begin()));
13166 ROSE_ASSERT(addop!=NULL);
13180 testList = NodeQuery::querySubTree(forstmt->get_increment(), V_SgSubtractOp);
13181 if (testList.size()>0)
13183 ROSE_ASSERT(testList.size()==1);
13185 SgSubtractOp * subtractop = isSgSubtractOp(*(testList.begin()));
13186 ROSE_ASSERT(subtractop!=NULL);
13189 SgAssignOp *assignop = isSgAssignOp((*testList.begin())->get_parent());
13190 ROSE_ASSERT(assignop !=NULL);
13197 cerr<<
"Error. SageInterface::setLoopStride(), illegal loop type:"<< loop->
class_name()<<endl;
13198 ROSE_ASSERT (
false);
13209 SgExpression *exp = (n != 0)? n->get_expression() : isSgExpression(s);
13212 case V_SgPlusAssignOp:
13213 case V_SgMinusAssignOp:
13214 case V_SgAndAssignOp:
13215 case V_SgIorAssignOp:
13216 case V_SgMultAssignOp:
13217 case V_SgDivAssignOp:
13218 case V_SgModAssignOp:
13219 case V_SgXorAssignOp:
13227 if ( init->variantT() == V_SgAssignInitializer)
13228 init = isSgAssignInitializer(init)->
get_operand();
13232 *readlhs = (exp->
variantT() != V_SgAssignOp);
13246 Rose_STL_Container<SgNode*> gotos = NodeQuery::querySubTree(top,V_SgGotoStatement);
13247 for (
size_t i = 0; i < gotos.size(); ++i)
13252 if (!lsParent)
continue;
13255 size_t j = std::find(bbStatements.begin(), bbStatements.end(), ls) - bbStatements.begin();
13257 ROSE_ASSERT (j != bbStatements.size());
13259 while (j < bbStatements.size() - 1 && isSgLabelStatement(bbStatements[j + 1]))
13263 gs->
set_label(isSgLabelStatement(bbStatements[j]));
13279 ROSE_ASSERT(decl != NULL);
13280 ROSE_ASSERT(assign_stmt != NULL);
13283 SgAssignOp * assign_op = isSgAssignOp (assign_stmt->get_expression());
13284 if (assign_op == NULL)
13287 if (assign_op_var == NULL)
return false;
13291 if (decl_var->get_initptr()!= NULL )
return false;
13298 if (decl_var_symbol!=NULL)
13301 if (assign_op_var->get_symbol() != decl_var_symbol)
return false;
13306 if (assign_op_var->get_symbol()->
get_name() != decl_var ->get_name())
return false;
13320 if (removeAssignStmt)
13324 decl_var->set_initptr(initor);
13335 ROSE_ASSERT(assign_stmt != NULL);
13336 SgAssignOp * assign_op = isSgAssignOp (assign_stmt->get_expression());
13337 if (assign_op == NULL)
13340 if (assign_op_var == NULL)
13344 ROSE_ASSERT(decl != NULL);
13346 if (decl_var->get_initptr()!= NULL)
13353 ROSE_ASSERT(decl_var != NULL);
13355 if (decl_var_symbol != NULL) {
13357 if (assign_op_var->get_symbol() != decl_var_symbol)
13363 if (assign_op_var->get_symbol()->
get_name() != decl_var ->get_name())
13376 decl_var->set_initptr(initor);
13406 ROSE_ASSERT (decl != NULL);
13410 if (initor == NULL)
13417 rhs = ainitor->get_operand();
13423 decl_var->set_initptr(NULL);
13435 cerr<<
"SageInterface::splitVariableDeclaration() topLevelOnly == false is not yet implemented."<<endl;
13436 ROSE_ASSERT (
false);
13439 Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(scope, V_SgVariableDeclaration);
13440 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
13445 ROSE_ASSERT(decl != NULL);
13458 ROSE_ASSERT (root != NULL);
13461 Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(root, V_SgVarRefExp);
13465 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
13468 ROSE_ASSERT (vRef != NULL);
13469 result.push_back(vRef);
13476 ROSE_ASSERT (root != NULL);
13477 Rose_STL_Container<SgNode*> constructorList= NodeQuery::querySubTree(root, V_SgConstructorInitializer);
13478 for (
size_t i =0; i< constructorList.size(); i++)
13483 Rose_STL_Container<SgNode*> varList = NodeQuery::querySubTree (a_type->get_index(),V_SgVarRefExp);
13484 for (
size_t j =0 ; j< varList.size(); j++)
13486 SgVarRefExp* var_exp = isSgVarRefExp(varList[j]) ;
13487 currentVarRefList.push_back(var_exp);
13511 SgExpression* lhsCopy = isSgExpression(lhs->copy(treeCopy));
13512 ROSE_ASSERT (lhsCopy);
13536 SgExpression* lhsCopy = isSgExpression(lhs->copy(treeCopy));
13537 ROSE_ASSERT (lhsCopy);
13561 SgExpression* lhsCopy = isSgExpression(lhs->copy(treeCopy));
13562 ROSE_ASSERT (lhsCopy);
13579 ROSE_ASSERT(from != NULL);
13581#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
13585 ROSE_ASSERT (
false);
13590 SgStatement* stmt = getStatementOfExpression(from);
13592 if (!isSgForInitStatement(stmt->
get_parent())) {
13601 if (!parent && isSgForInitStatement(stmt->
get_parent()))
13607 SgName varname =
"rose_temp__";
13608 if (newName ==
"") {
13616 vector<SgExpression*> ancestors;
13617 for (
SgExpression *expr = from, *anc = isSgExpression(fromparent); anc != 0;
13618 expr = anc, anc = isSgExpression(anc->get_parent()))
13620 if ((isSgAndOp(anc) && expr != isSgAndOp(anc)->get_lhs_operand()) ||
13623 ancestors.push_back(anc);
13626 for (vector<SgExpression*>::reverse_iterator ai = ancestors.rbegin(); ai != ancestors.rend(); ++ai)
13629 switch ((*ai)->variantT()) {
13634 case V_SgConditionalExp:
13636 default: assert (!
"Should not happen"); abort();
13641 if (ancestors.size() != 0) {
13649 ROSE_ASSERT (initname);
13651 replaceExpressionWithExpression(from, varref);
13655 initname->set_initializer(ai);
13657 myStatementInsert(stmt, vardecl,
true);
13678 SplitStatementGenerator gen;
13684 Rose_STL_Container<SgNode*> gotos = NodeQuery::querySubTree(top,
13685 V_SgGotoStatement);
13686 map<SgLabelStatement*, SgLabelStatement*> labelsToReplace;
for
13687 (
size_t i = 0; i < gotos.size(); ++i) {
13690 if (!gsParent)
continue;
13692 size_t j = std::find(bbStatements.begin(), bbStatements.end(), gs)
13693 - bbStatements.begin();
13694 ROSE_ASSERT (j != bbStatements.size());
13695 if (j == 0)
continue;
13696 if (isSgLabelStatement(bbStatements[j - 1])) {
13697 labelsToReplace[isSgLabelStatement(bbStatements[j - 1])] =
13701 for (
size_t i = 0; i < gotos.size(); ++i) {
13704 while (labelsToReplace.find(oldLabel) != labelsToReplace.end()) {
13705 oldLabel = labelsToReplace[oldLabel];
13715 case V_SgBoolValExp:
return (isSgBoolValExp(e)->get_value() != 0);
13717 case V_SgBoolValExp:
return (isSgBoolValExp(e)->get_value() ==
true);
13719 case V_SgIntVal:
return isSgIntVal(e)->get_value() != 0;
13720 case V_SgCastExp:
return isConstantTrue(isSgCastExp(e)->get_operand());
13722 case V_SgAddressOfOp:
return true;
13723 default:
return false;
13729 case V_SgBoolValExp:
return isSgBoolValExp(e)->get_value() ==
false;
13730 case V_SgIntVal:
return isSgIntVal(e)->get_value() == 0;
13731 case V_SgCastExp:
return
13733 case V_SgNotOp:
return isConstantTrue(isSgNotOp(e)->get_operand());
13734 default:
return false;
13741 if (!fc)
return false;
13743 if (fr == NULL)
return false;
13744 return fr->get_symbol()->get_declaration() == decl;
13750 if (!fc)
return false;
13752 if (fr == NULL)
return false;
13754 fr->get_symbol()->get_declaration()->get_qualified_name().getString();
13755 return (name == qualifiedName &&
13756 fc->get_args()->get_expressions().size() == arity);
13761 ROSE_ASSERT( e != NULL);
13777 ROSE_ASSERT(expList);
13779 expList->append_expression(exp);
13785 for (
size_t i = 0; i < exp.size(); ++i)
13794template <
class actualFunction>
13804 ROSE_ASSERT(paralist);
13809 cerr <<
"Waring! Setting a used SgFunctionParameterList to function: "
13810 << (func->get_name()).getString()<<endl
13811 <<
" Sharing parameter lists can corrupt symbol tables!"<<endl
13812 <<
" Please use deepCopy() to get an exclusive parameter list for each function declaration!"<<endl;
13817 if (func->get_parameterList() != NULL)
13818 if (func->get_parameterList() != paralist)
13819 delete func->get_parameterList();
13821 func->set_parameterList(paralist);
13829 ROSE_ASSERT(paraList != NULL);
13830 ROSE_ASSERT(initName != NULL);
13832 if (isPrepend ==
true)
13833 paraList->prepend_arg(initName);
13835 paraList->append_arg(initName);
13842 ROSE_ASSERT(initName->
get_parent() == paraList);
13852 if (func_decl != NULL)
13858 ROSE_ASSERT(func_def);
13868 initName->set_declptr(func_decl);
13880 initName->set_scope(scope);
13900 return addArg(paraList,initName,
false);
13905 return addArg(paraList,initName,
true);
13911 ROSE_ASSERT(pragma);
13912 if (decl->get_pragma()!=NULL)
delete (decl->get_pragma());
13913 decl->set_pragma(pragma);
13924 void testAstForUniqueNodes (
SgNode* node );
13927 printf (
"In SageInterface::appendStatement(): stmt = %p = %s scope = %p \n",stmt,stmt->
class_name().c_str(),scope);
13936 printf (
" --- scope was not specified as input! \n");
13941 ROSE_ASSERT(stmt != NULL);
13942 ROSE_ASSERT(scope != NULL);
13945 printf (
"In SageInterface::appendStatement(): stmt = %p = %s scope = %p = %s \n",stmt,stmt->
class_name().c_str(),scope,scope->
class_name().c_str());
13952 if (declarationStatement != NULL)
13980 scope->insertStatementInScope(stmt,
false);
13984 bool skipAddingStatement =
false;
13986 if (classDeclaration != NULL)
13992 printf (
"Since the parent of this SgClassDeclaration is set, it must have been previously added to the AST: classDeclaration = %p = %s \n",classDeclaration,classDeclaration->
class_name().c_str());
13998 skipAddingStatement = (classDeclaration->get_isAutonomousDeclaration() ==
false);
14002 skipAddingStatement = (classDeclaration->get_isAutonomousDeclaration() ==
false) || (classDeclaration->
get_parent() != NULL);
14017 if (statementAlreadyExistsInScope ==
true)
14019 if (isSgTemplateInstantiationDecl(classDeclaration) != NULL)
14023#if PRINT_DEVELOPER_WARNINGS
14024 printf (
"RARE ISSUE #1: In SageInterface::appendStatement(): This template instantiation has previously been added to the scope, so avoid doing so again (see test2013_198.C): classDeclaration = %p = %s scope = %p = %s \n",
14032 printf (
"RARE ISSUE #2: In SageInterface::appendStatement(): This statement has previously been added to the scope, so avoid doing so again (see rose.h): stmt = %p = %s scope = %p = %s \n",
14037 skipAddingStatement =
true;
14044 if (enumDeclaration != NULL)
14047 skipAddingStatement = (enumDeclaration->get_isAutonomousDeclaration() ==
false);
14056 if (skipAddingStatement ==
false && statementAlreadyExistsInScope ==
true)
14059 printf (
"RARE ISSUE #2: In SageInterface::appendStatement(): This statement has previously been added to the scope, so avoid doing so again (see rose.h): stmt = %p = %s scope = %p = %s \n",
14063 printf (
"Exiting as a test! \n");
14066 skipAddingStatement =
true;
14071 printf (
" --- skipAddingStatement = %s \n",skipAddingStatement ?
"true" :
"false");
14074 if (skipAddingStatement ==
false)
14086 printf (
" --- calling insertStatementInScope(): scope = %p = %s stmt = %p = %s \n",scope,scope->
class_name().c_str(),stmt,stmt->
class_name().c_str());
14088 scope->insertStatementInScope(stmt,
false);
14115 testAstForUniqueNodes(scope);
14124 ROSE_ASSERT (stmt != NULL);
14125 ROSE_ASSERT (for_init_stmt != NULL);
14128 printf (
"In SageInterface::appendStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: stmt) \n",stmt,stmt->
class_name().c_str(),scope,scope->
class_name().c_str());
14137 printf (
"In SageInterface::appendStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: scope) \n",stmt,stmt->
class_name().c_str(),scope,scope->
class_name().c_str());
14145 for_init_stmt->append_init_stmt (stmt);
14151 for (
size_t i = 0; i < stmts.size(); ++i)
14154#ifdef ROSE_DEBUG_NEW_EDG_ROSE_CONNECTION
14155 printf (
"In appendStatementList(): stmts[i = %" PRIuPTR
"] = %p = %s \n",i,stmts[i],stmts[i]->class_name().c_str());
14161 if (stmts[i]->get_parent() != NULL)
14164#ifdef ROSE_DEBUG_NEW_EDG_ROSE_CONNECTION
14165 printf (
" --- In appendStatementList(): stmts[i = %" PRIuPTR
"] will be added to scope (because stmts[i]->get_parent() != NULL (= %p = %s) \n",i,stmts[i]->get_parent(),stmts[i]->get_parent()->class_name().c_str());
14172 printf (
" --- WARNING: In appendStatementList(): stmts[i = %" PRIuPTR
"] not added to scope (because stmts[i]->get_parent() == NULL) \n",i);
14181 ROSE_ASSERT (stmt != NULL);
14184 printf (
"In SageInterface::prependStatement(): stmt = %p = %s scope = %p \n",stmt,stmt->
class_name().c_str(),scope);
14194 ROSE_ASSERT(scope != NULL);
14204 printf (
"In SageInterface::prependStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: stmt) \n",
14216 printf (
"In SageInterface::prependStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: scope) \n",
14228 printf (
"Calling insertStatementInScope() \n");
14234 scope->insertStatementInScope(stmt,
true);
14254 printf (
"Leaving SageInterface::prependStatement() \n");
14262 ROSE_ASSERT (stmt != NULL);
14263 ROSE_ASSERT (for_init_stmt != NULL);
14266 printf (
"In SageInterface::prependStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: stmt) \n",stmt,stmt->
class_name().c_str(),scope,scope->
class_name().c_str());
14275 printf (
"In SageInterface::prependStatement(): stmt = %p = %s scope = %p = %s (resetInternalMapsForTargetStatement: scope) \n",stmt,stmt->
class_name().c_str(),scope,scope->
class_name().c_str());
14283 for_init_stmt->prepend_init_stmt (stmt);
14288 for (
size_t i = stmts.size(); i > 0; --i)
14300 ROSE_ASSERT (scope != NULL);
14303 case V_SgBasicBlock:
14304 case V_SgClassDefinition:
14305 case V_SgFunctionDefinition:
14307 case V_SgNamespaceDefinitionStatement:
14311 case V_SgAssociateStatement :
14312 case V_SgBlockDataStatement :
14313 case V_SgCatchOptionStmt:
14314 case V_SgDoWhileStmt:
14315 case V_SgForAllStatement:
14316 case V_SgForStatement:
14317 case V_SgFortranDo:
14319 case V_SgSwitchStatement:
14320 case V_SgUpcForAllStatement:
14321 case V_SgWhileStmt:
14326 cout<<
"unrecognized or unhandled scope type for SageInterface::hasSimpleChildrenList() "<<endl;
14339 SgDeclarationStatementPtrList & declarationList = globalScope->
get_declarations();
14342 SgDeclarationStatementPtrList::iterator i = declarationList.begin();
14344 while (i != declarationList.end() && (*i)->get_file_info() != NULL && (*i)->get_file_info()->isFrontendSpecific() ==
true)
14347 printf (
"(*i)->get_file_info()->get_file_id() = %d isFrontendSpecific = %s \n",(*i)->get_file_info()->get_file_id(),(*i)->get_file_info()->isFrontendSpecific() ?
"true" :
"false");
14349 last_statement = *i;
14354 ROSE_ASSERT(last_statement != NULL);
14356 printf (
"last_statement = %p = %s \n",last_statement,last_statement->
class_name().c_str());
14359 printf (
"Exiting as a test! \n");
14363 return last_statement;
14372 ROSE_ASSERT(targetStmt &&newStmt);
14373 ROSE_ASSERT(targetStmt != newStmt);
14375 if (parent == NULL)
14377 cerr <<
"Empty parent pointer for target statement. May be caused by the wrong order of target and new statements in insertStatement(targetStmt, newStmt)"<<endl;
14378 ROSE_ASSERT(parent);
14381 if (isSgLabelStatement(parent) != NULL)
14384 printf (
"In SageInterface::insertStatement(): Detected case of label statement as parent, using parent of label statement \n");
14389 ROSE_ASSERT(isSgLabelStatement(parent) == NULL);
14393 printf (
"In SageInterface::insertStatement(): insert newStmt = %p = %s before/after targetStmt = %p = %s \n",newStmt,newStmt->
class_name().c_str(),targetStmt,targetStmt->
class_name().c_str());
14411 ROSE_ASSERT(scope);
14414 printf (
"targetStmt = %p = %s \n",targetStmt,targetStmt->
class_name().c_str());
14415 printf (
"scope = %p = %s \n",scope,scope->
class_name().c_str());
14433 ROSE_ASSERT(isSgStatement(parent) != NULL);
14438 ROSE_ASSERT(targetStmt != NULL);
14442 printf (
"In SageInterface::insertStatement(): after checking for associated comments \n");
14443 reportNodesMarkedAsModified(scope);
14449 if (autoMovePreprocessingInfo)
14451 if (comments != NULL && isSgBasicBlock(newStmt) == NULL)
14453 vector<int> captureList;
14455 printf (
"Found attached comments (at %p = %s, inserting %p = %s insertBefore = %s): comments->size() = %" PRIuPTR
" \n",
14456 targetStmt,targetStmt->
class_name().c_str(),newStmt,newStmt->
class_name().c_str(),insertBefore ?
"true" :
"false",comments->size());
14463 printf (
"Warning: at present statements being inserted should not have attached comments of CPP directives (could be a problem, but comment relocation is not disabled). \n");
14468 int commentIndex = 0;
14469 AttachedPreprocessingInfoType::iterator i;
14470 for (i = comments->begin(); i != comments->end(); i++)
14472 ROSE_ASSERT ( (*i) != NULL );
14474 printf (
" Attached Comment (relativePosition=%s): %s\n",
14475 ((*i)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
14476 (*i)->getString().c_str());
14477 printf (
"Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
14478 (*i)->get_file_info()->display(
"comment/directive location");
14481 if ((*i)->getRelativePosition() == relativePosition)
14484 captureList.push_back(commentIndex);
14491 if (captureList.empty() ==
false)
14497 ROSE_ASSERT(surroundingStatement != targetStmt);
14498 ROSE_ASSERT(surroundingStatement != NULL);
14500 if (surroundingStatement == NULL)
14503 surroundingStatement = (insertBefore ==
true) ? newStmt : newStmt;
14508 vector<int>::iterator j = captureList.begin();
14509 while (j != captureList.end())
14517 (*comments)[*j] = NULL;
14524 for (
size_t n = 0; n < captureList.size(); n++)
14526 AttachedPreprocessingInfoType::iterator k = comments->begin();
14527 while (k != comments->end())
14532 comments->erase(k);
14545 if (comments != NULL)
14547 printf (
"Warning: special rules appear to apply to the insertion of a SgBasicBlock which has attached comments and/or CPP directives (comment relocation disabled). \n");
14554 printf (
"In SageInterface::insertStatement(): after processing associated comments \n");
14555 reportNodesMarkedAsModified(scope);
14558 if (isSgIfStmt(parent))
14560 if (isSgIfStmt(parent)->get_conditional()==targetStmt)
14566 if (isSgIfStmt(parent)->get_true_body()==targetStmt)
14586 if (isSgIfStmt(parent)->get_false_body()==targetStmt)
14600 if (isSgWhileStmt(parent))
14602 if (isSgWhileStmt(parent)->get_condition()==targetStmt)
14608 if (isSgWhileStmt(parent)->get_body()==targetStmt)
14611 isSgWhileStmt(parent)->
set_body(newparent);
14621 if (isSgDoWhileStmt(parent))
14623 if (isSgDoWhileStmt(parent)->get_condition()==targetStmt)
14629 if (isSgDoWhileStmt(parent)->get_body()==targetStmt)
14632 isSgDoWhileStmt(parent)->
set_body(newparent);
14642 if (isSgForStatement(parent))
14644 if (isSgForStatement(parent)->get_loop_body()==targetStmt)
14655 if (isSgForStatement(parent)->get_test()==targetStmt)
14676 p->set_body(newparent);
14684 ROSE_ASSERT(stmnt != NULL);
14706 printf (
"In SageInterface::insertStatement(): at BASE of function \n");
14707 reportNodesMarkedAsModified(scope);
14716 for (
size_t i = 0; i < newStmts.size(); ++i)
14723 for (
size_t i = newStmts.size(); i > 0; --i)
14732 insertStatement(targetStmt,newStmt,
false, autoMovePreprocessingInfo);
14743 ROSE_ASSERT (stmt != NULL);
14744 ROSE_ASSERT (scope != NULL);
14756 ROSE_ASSERT (scope != NULL);
14757 vector <SgStatement* >::iterator iter;
14759 for (iter= stmt_list.begin(); iter != stmt_list.end(); iter++)
14761 if (iter == stmt_list.begin())
14767 ROSE_ASSERT (prev_stmt != NULL);
14776 ROSE_ASSERT(newStmt!=NULL);
14777 ROSE_ASSERT(scope!=NULL);
14779 if (!isSgDeclarationStatement(targetStmt)) {
14789 ROSE_ASSERT(scope!=NULL);
14791 if (!isSgDeclarationStatement(targetStmt)) {
14814 ROSE_ASSERT(target);
14815 ROSE_ASSERT(operand);
14816 ROSE_ASSERT(target!=operand);
14817 switch (target->variantT())
14819 case V_SgActualArgumentExpression:
14820 isSgActualArgumentExpression(target)->set_expression(operand);
14823 isSgAsmOp(target)->set_expression(operand);
14826 isSgSizeOfOp(target)->set_operand_expr(operand);
14829 isSgTypeIdOp(target)->set_operand_expr(operand);
14832 isSgVarArgOp(target)->set_operand_expr(operand);
14834 case V_SgVarArgStartOneOperandOp:
14835 isSgVarArgStartOneOperandOp(target)->set_operand_expr(operand);
14837 case V_SgAssignInitializer:
14838 isSgAssignInitializer (target)->
set_operand(operand);
14841 if (isSgUnaryOp(target)!=NULL)
14845 cerr<<
"\tSageInterface::setOperand(): unhandled case for target expression of type "
14846 <<target->class_name()<<endl;
14851 markLhsValues(target);
14857 ROSE_ASSERT(target);
14859 ROSE_ASSERT(target!=lhs);
14860 bool hasrhs =
false;
14866 if (varargcopy!=NULL)
14868 varargcopy->set_lhs_operand(lhs);
14869 if( varargcopy->get_rhs_operand()!=NULL) hasrhs=
true;
14871 else if(varargstart!=NULL)
14873 varargstart->set_lhs_operand(lhs);
14874 if( varargstart->get_rhs_operand()!=NULL) hasrhs=
true;
14876 else if(binary!=NULL)
14883 cout<<
"SageInterface::setLhsOperand(): unhandled case for target expression of type "
14884 <<target->class_name()<<endl;
14891 markLhsValues(target);
14896 ROSE_ASSERT(target);
14898 ROSE_ASSERT(target!=rhs);
14899 bool haslhs =
false;
14905 if (varargcopy!=NULL)
14907 varargcopy->set_rhs_operand(rhs);
14908 if( varargcopy->get_lhs_operand()!=NULL) haslhs=
true;
14910 else if(varargstart!=NULL)
14912 varargstart->set_rhs_operand(rhs);
14913 if( varargstart->get_lhs_operand()!=NULL) haslhs=
true;
14915 else if(binary!=NULL)
14922 cout<<
"SageInterface::setRhsOperand(): unhandled case for target expression of type "
14923 <<target->class_name()<<endl;
14929 markLhsValues(target);
14948 ROSE_ASSERT(parentFileList != NULL);
14954 if (parentDirectory != NULL)
14957 parentDirectory->get_directoryList()->get_listOfDirectories().push_back(directory);
14964 project = isSgProject(parentFileList->
get_parent());
14965 ROSE_ASSERT(project != NULL);
14968 project->get_directoryList()->get_listOfDirectories().push_back(directory);
14975 directory->get_fileList()->get_listOfFiles().push_back(file);
14978 parentFileList->get_listOfFiles().erase(find(parentFileList->get_listOfFiles().begin(),parentFileList->get_listOfFiles().end(),file));
14988 ROSE_ASSERT(structDecl != NULL);
14989 ROSE_ASSERT(scope != NULL);
14991 ROSE_ASSERT(nondefdecl != NULL);
15017 SgName name = structDecl->get_name();
15031 if (mysymbol == NULL)
15033 printf (
"Note: SageInterface::fixStructDeclaration(): structDecl = %p nondefdecl = %p (mysymbol == NULL) \n",structDecl,nondefdecl);
15037 ROSE_ASSERT(structDecl->
get_scope() != NULL);
15042 ROSE_ASSERT(mysymbol);
15045 printf (
"############## DANGER:DANGER:DANGER ################\n");
15047 printf (
"In SageInterface::fixStructDeclaration(): Adding class symbol to scope = %p = %s \n",scope,scope->
class_name().c_str());
15055 printf (
"*** WARNING: In SageInterface::fixStructDeclaration(): (mysymbol == NULL) Commented out the setting of the parent to be the same as the scope \n");
15064 printf (
"In SageInterface::fixStructDeclaration(): (mysymbol == NULL) Skipped building an associated symbol! \n");
15069 ROSE_ASSERT(nondefdecl->get_type() != NULL);
15072 ROSE_ASSERT(nondefdecl->get_type()->
variantT() != V_SgNode);
15075 ROSE_ASSERT(isSgClassType(nondefdecl->get_type()) != NULL);
15079 if (nondefdecl->get_type() == NULL)
15083 ROSE_ASSERT (nondefdecl->get_type() != NULL);
15086 if (defdecl != NULL)
15089 ROSE_ASSERT(defdecl->get_type()->
variantT() != V_SgNode);
15092 ROSE_ASSERT(isSgClassType(defdecl->get_type()) != NULL);
15096 if (defdecl != NULL)
15099 ROSE_ASSERT(defdecl->get_type() != NULL);
15100 if (defdecl->get_type() != nondefdecl->get_type())
15102 printf (
"ERROR: defdecl->get_type() != nondefdecl->get_type(): what are these: \n");
15103 printf (
" defdecl->get_type() = %p = %s \n",defdecl ->get_type(),defdecl ->get_type()->class_name().c_str());
15104 SgNamedType* namedType_definingDecl = isSgNamedType(defdecl->get_type());
15105 if (namedType_definingDecl != NULL)
15107 printf (
"namedType_definingDecl->get_declaration() = %p = %s \n",namedType_definingDecl->get_declaration(),namedType_definingDecl->get_declaration()->
class_name().c_str());
15109 printf (
" nondefdecl->get_type() = %p = %s \n",nondefdecl->get_type(),nondefdecl->get_type()->
class_name().c_str());
15110 SgNamedType* namedType_nondefiningDecl = isSgNamedType(nondefdecl->get_type());
15111 if (namedType_nondefiningDecl != NULL)
15113 printf (
"namedType_nondefiningDecl->get_declaration() = %p = %s \n",namedType_nondefiningDecl->get_declaration(),namedType_nondefiningDecl->get_declaration()->
class_name().c_str());
15129 ROSE_ASSERT(structDecl);
15130 ROSE_ASSERT(scope);
15132 ROSE_ASSERT(nondefdecl);
15151 if (mysymbol==NULL)
15158 ROSE_ASSERT(mysymbol);
15160 printf (
"In SageInterface::fixNamespaceDeclaration(): inserting namespace symbol into scope = %p = %s \n",scope,scope->
class_name().c_str());
15164 ROSE_ASSERT(defdecl);
15176 ROSE_ASSERT(varDecl != NULL);
15177 ROSE_ASSERT(scope != NULL);
15179 SgInitializedNamePtrList namelist = varDecl->
get_variables();
15184 printf (
"In SageInterface::fixVariableDeclaration(): varDecl = %p scope = %p = %s \n",varDecl,scope,scope->
class_name().c_str());
15187 ROSE_ASSERT(namelist.size() > 0);
15189 SgInitializedNamePtrList::iterator i;
15190 for (i = namelist.begin(); i != namelist.end(); i++)
15193 ROSE_ASSERT(initName != NULL);
15195 SgName name = initName->get_name();
15197 printf (
" -- initName = %p : %s\n", initName, name.str());
15198 printf (
" -- initName->get_scope() = %p (%s)\n", initName->get_scope(), initName->get_scope() ? initName->get_scope()->
class_name().c_str() :
"");
15207 if (preAssociatedScope != NULL)
15210 printf (
"In SageInterface::fixVariableDeclaration(): Note that this variable already has an associated scope! preAssociatedScope = %p = %s (but will be reset below) \n",preAssociatedScope,preAssociatedScope->
class_name().c_str());
15213 requiredScope = preAssociatedScope;
15218 initName->set_scope(requiredScope);
15235 ROSE_ASSERT(requiredScope != NULL);
15236 SgVariableSymbol* varSymbol = requiredScope->lookup_variable_symbol(name);
15238 printf (
" -- varSymbol = %p (%s)\n", varSymbol, varSymbol ? varSymbol->
class_name().c_str() :
"");
15241 if (varSymbol == NULL)
15245 if (scope == initName->get_scope())
15247 if (isSgTemplateVariableDeclaration(varDecl)) {
15252 ROSE_ASSERT(varSymbol);
15264 ROSE_ASSERT(prev_decl);
15268 if (initName != prev_decl)
15269 initName->set_prev_decl_item(prev_decl);
15271 ROSE_ASSERT(initName->get_prev_decl_item() != initName);
15290 Rose_STL_Container<SgNode*> varList;
15293 Rose_STL_Container<SgNode*> reflist = NodeQuery::querySubTree(root, V_SgVarRefExp);
15294 for (Rose_STL_Container<SgNode*>::iterator i=reflist.begin();i!=reflist.end();i++)
15296 varRef= isSgVarRefExp(*i);
15297 ROSE_ASSERT(varRef->get_symbol());
15300 ROSE_ASSERT (initname != NULL);
15303 SgName varName=initname->get_name();
15314 if (varRef == arrowExp->get_rhs_operand_i())
15318 SgType* lhs_type = arrowExp->get_lhs_operand_i()->get_type() ;
15319 lhs_type = lhs_type->
stripType(SgType::STRIP_MODIFIER_TYPE | SgType::STRIP_REFERENCE_TYPE | SgType::STRIP_RVALUE_REFERENCE_TYPE | SgType::STRIP_TYPEDEF_TYPE);
15321 ROSE_ASSERT(ptrType);
15322 SgClassType* clsType = isSgClassType(ptrType->get_base_type()-> stripType(SgType::STRIP_MODIFIER_TYPE | SgType::STRIP_REFERENCE_TYPE | SgType::STRIP_RVALUE_REFERENCE_TYPE | SgType::STRIP_TYPEDEF_TYPE));
15323 ROSE_ASSERT(clsType);
15341 if (varRef == dotExp->get_rhs_operand_i())
15346 SgType* lhs_type = dotExp->get_lhs_operand_i()->get_type() ;
15347 lhs_type = lhs_type->
stripType(SgType::STRIP_MODIFIER_TYPE | SgType::STRIP_REFERENCE_TYPE | SgType::STRIP_RVALUE_REFERENCE_TYPE | SgType::STRIP_TYPEDEF_TYPE);
15349 ROSE_ASSERT(clsType);
15373 if (realSymbol==NULL)
15380 ROSE_ASSERT(realSymbol!=(varRef->get_symbol()));
15387 bool toDelete =
true;
15389 SgSymbol* symbolToDelete = varRef->get_symbol();
15390 varRef->set_symbol(isSgVariableSymbol(realSymbol));
15393 if (varList.empty())
15395 VariantVector vv(V_SgVarRefExp);
15396 varList = NodeQuery::queryMemoryPool(vv);
15399 for (Rose_STL_Container<SgNode*>::iterator i = varList.begin();
15400 i != varList.end(); ++i)
15404 if (var->get_symbol() == symbolToDelete)
15414 delete symbolToDelete;
15423 delete (varRef->get_symbol());
15427 varRef->set_symbol(isSgVariableSymbol(realSymbol));
15434 if (cleanUnusedSymbols)
15441 Rose_STL_Container<SgNode*> symbolList;
15442 VariantVector sym_vv(V_SgVariableSymbol);
15443 symbolList = NodeQuery::queryMemoryPool(sym_vv);
15445 Rose_STL_Container<SgNode*> varList;
15446 VariantVector var_vv(V_SgVarRefExp);
15450 varList = NodeQuery::querySubTree(root, V_SgVarRefExp);
15453 for (Rose_STL_Container<SgNode*>::iterator i = symbolList.begin();
15454 i != symbolList.end(); ++i)
15457 ROSE_ASSERT(symbolToDelete);
15461 bool toDelete =
true;
15465 for (Rose_STL_Container<SgNode*>::iterator j = varList.begin();
15466 j != varList.end(); ++j)
15471 if (var->get_symbol() == symbolToDelete)
15482 std::cout <<
"Symbol " << symbolToDelete->
get_name().str() <<
' ' << symbolToDelete <<
15483 ' ' << symbolToDelete->get_declaration() <<
" is deleted." << std::endl;
15485 delete symbolToDelete->get_declaration();
15486 delete symbolToDelete;
15499 ROSE_ASSERT(label_stmt);
15508 if (isSgFunctionDefinition(scope) !=
nullptr)
15510 ASSERT_not_null(label_scope);
15516 SgLabelSymbol* lsymbol = label_scope->lookup_label_symbol(name);
15518 if (lsymbol ==
nullptr)
15523 ASSERT_not_null(lsymbol);
15535 ROSE_ASSERT (stmt != NULL);
15536 ROSE_ASSERT (label_value >0 && label_value <=99999);
15539 if (label_scope == NULL)
15543 ROSE_ASSERT (label_scope != NULL);
15545 SgLabelSymbol * symbol = label_scope->lookup_label_symbol (label_name);
15546 if (symbol == NULL)
15552 ROSE_ASSERT(symbol != NULL);
15553 symbol->set_fortran_statement(stmt);
15554 symbol->set_numeric_label_value(label_value);
15559 cerr<<
"Error. SageInterface::setFortranNumericLabel() tries to set a duplicated label value!"<<endl;
15560 ROSE_ASSERT (
false);
15569 case SgLabelSymbol::e_start_label_type:
15571 stmt->set_numeric_label(ref_exp);
15574 case SgLabelSymbol::e_end_label_type:
15576 stmt->set_end_numeric_label(ref_exp);
15581 std::cerr <<
"SageInterface::setFortranNumericLabel: unimplemented for label_type " << label_type <<
"\n";
15593 ROSE_ASSERT (func_def != NULL);
15598 std::set<SgNode*>::iterator iter ;
15599 for (iter=symbols.begin(); iter !=symbols.end(); iter++)
15604 int cur_val = l_symbol->get_numeric_label_value();
15605 if (result <=cur_val)
15606 result = cur_val +10;
15610 ROSE_ASSERT (result <= 99999);
15621 ROSE_ASSERT(scope != NULL);
15626 ROSE_ASSERT(fTable != NULL);
15633 printf (
"WARNING: Skip setting the scope of the SgFunctionTypeTable scope = %p = %s \n",scope,scope->
class_name().c_str());
15639 printf (
"In SageInterface::fixStatement(): stmt = %p = %s \n",stmt,stmt->
class_name().c_str());
15652 if (tmfunc != NULL)
15653 assert(tmfunc->
variantT() == V_SgTemplateMemberFunctionDeclaration);
15654 else if (mfunc != NULL)
15655 assert(mfunc->
variantT() == V_SgMemberFunctionDeclaration || mfunc->
variantT() == V_SgTemplateInstantiationMemberFunctionDecl);
15656 else if (tfunc != NULL)
15657 assert(tfunc->
variantT() == V_SgTemplateFunctionDeclaration);
15658 else if (procfunc != NULL)
15659 assert(procfunc->
variantT() == V_SgProcedureHeaderStatement);
15660 else if (progfunc != NULL)
15661 assert(progfunc->
variantT() == V_SgProgramHeaderStatement);
15662 else if (func != NULL)
15663 assert(func->
variantT() == V_SgFunctionDeclaration || func->
variantT() == V_SgTemplateInstantiationFunctionDecl);
15667 printf (
"In SageInterface::fixStatement(): scope = %p = %s \n",scope,scope->
class_name().c_str());
15668 printf (
"In SageInterface::fixStatement(): stmt->get_scope() = %p \n",stmt->
get_scope());
15680 printf (
"Looking up the function symbol using name = %s and type = %p = %s \n",func->get_name().str(),func->get_type(),func->get_type()->
class_name().c_str());
15686 if (tmfunc != NULL)
15688 SgTemplateParameterPtrList & templateParameterList = tmfunc->get_templateParameters();
15691 func_symbol = scope->lookup_template_member_function_symbol (func->get_name(), func->get_type(),&templateParameterList);
15693 else if (mfunc != NULL)
15696 SgTemplateArgumentPtrList* templateArgumentList = (templateInstantiationMemberFunctionDecl != NULL) ? &(templateInstantiationMemberFunctionDecl->
get_templateArguments()) : NULL;
15698 func_symbol = scope->lookup_nontemplate_member_function_symbol (func->get_name(), func->get_type(),templateArgumentList);
15700 else if (tfunc != NULL)
15702 SgTemplateParameterPtrList & templateParameterList = tfunc->get_templateParameters();
15704 printf (
"In SageInterface::fixStatement(): templateParameterList.size() = %" PRIuPTR
" \n",templateParameterList.size());
15708 func_symbol = scope->lookup_template_function_symbol (func->get_name(), func->get_type(),&templateParameterList);
15710 else if (procfunc != NULL)
15713 printf (
"In SageInterface::fixStatement(): procfunc->get_name() = %s calling lookup_function_symbol() \n",procfunc->get_name().str());
15715 func_symbol = scope->lookup_function_symbol (procfunc->get_name(), procfunc->get_type());
15716 assert(func_symbol != NULL);
15718 else if (progfunc != NULL)
15720 func_symbol = scope->lookup_function_symbol (progfunc->get_name(), progfunc->get_type());
15721 assert(func_symbol != NULL);
15723 else if (func != NULL)
15726 printf (
"In SageInterface::fixStatement(): func->get_name() = %s calling lookup_function_symbol() \n",func->get_name().str());
15729 SgTemplateArgumentPtrList* templateArgumentList = (templateInstantiationFunctionDecl != NULL) ? &(templateInstantiationFunctionDecl->
get_templateArguments()) : NULL;
15731 func_symbol = scope->lookup_function_symbol (func->get_name(), func->get_type(),templateArgumentList);
15736 if (func_symbol == NULL)
15748 printf (
"In SageInterface::fixStatement(): func_symbol = %p \n",func_symbol);
15750 assert(func_symbol != NULL);
15761 printf (
"Need to handle SgTemplateDeclaration IR nodes as well...(implement later) \n");
15769 if (isSgVariableDeclaration(stmt))
15776 ROSE_ASSERT(classDeclaration !=
nullptr);
15779 else if (isSgClassDeclaration(stmt))
15783 else if (isSgLabelStatement(stmt))
15787 else if (isSgFunctionDeclaration(stmt))
15795 ROSE_ASSERT(fTable);
15804 printf (
"In SageInterface::fixStatement(): scope = %p = %s \n",scope,scope->
class_name().c_str());
15805 printf (
"In SageInterface::fixStatement(): stmt->get_scope() = %p \n",stmt->
get_scope());
15816 printf (
"Looking up the function symbol using name = %s and type = %p = %s \n",func->get_name().str(),func->get_type(),func->get_type()->
class_name().c_str());
15818 SgFunctionSymbol* func_symbol = scope->lookup_function_symbol (func->get_name(), func->get_type());
15820 printf (
"In SageInterface::fixStatement(): func_symbol = %p \n",func_symbol);
15821 if (func_symbol == NULL)
15833 ROSE_ASSERT (func_symbol != NULL);
15839 printf (
"In SageInterface::fixStatement(): found a valid function so no need to insert new symbol \n");
15847 if (local_symbol == NULL)
15852 if (func != src_func )
15862 else if (isSgTemplateDeclaration(stmt) != NULL)
15877 case V_SgEnumDeclaration:
15878 case V_SgTemplateDeclaration:
15879 case V_SgTypedefDeclaration:
15880 case V_SgFunctionDeclaration:
15881 case V_SgMemberFunctionDeclaration:
15882 case V_SgTemplateInstantiationFunctionDecl:
15897 printf (
"In SageInterface::fixStatement(): switch default case used (likely OK): stmt = %p = %s \n",stmt,stmt->
class_name().c_str());
15900 printf (
"switch case not handled properly: stmt = %p = %s \n",stmt,stmt->
class_name().c_str());
15932 ROSE_ASSERT(func != NULL && scope != NULL);
15934 ROSE_ASSERT(func != NULL);
15935 ROSE_ASSERT(scope != NULL);
15937 SgStatementPtrList stmtList, sameFuncList;
15944 SgDeclarationStatementPtrList::iterator i;
15945 for (i=declList.begin();i!=declList.end();i++)
15946 stmtList.push_back(*i);
15954 if (firstNondefiningFunctionDeclaration != NULL)
15959 printf (
"In SageInterface::updateDefiningNondefiningLinks(): func = %p Found a valid pointer to a firstNondefiningFunctionDeclaration = %p \n",func,firstNondefiningFunctionDeclaration);
15970 printf (
"WARNING: symbol for func->get_firstNondefiningDeclaration() = %p = %s = %s is not present in the scope = %p = %s associated with the firstNondefiningDeclaration \n",
15978 SgSymbol* functionSymbol = scope->lookup_function_symbol(func->get_name(),func->get_type());
15979 if (functionSymbol != NULL)
15981 printf (
"In SageInterface::updateDefiningNondefiningLinks(): func = %p Found a valid symbol = %p \n",func,functionSymbol);
15985 printf (
"In SageInterface::updateDefiningNondefiningLinks(): func = %p functionSymbol == NULL \n",func);
15990 SgStatementPtrList::iterator j;
15991 for (j = stmtList.begin(); j != stmtList.end(); j++)
15994 if (func_decl != NULL)
16001 sameFuncList.push_back(func_decl);
16007 printf (
"func = %p \n",func);
16011 ROSE_ASSERT(func != NULL);
16015 for (j = sameFuncList.begin(); j != sameFuncList.end(); j++)
16020 ROSE_ASSERT(func != NULL);
16023 ROSE_ASSERT(sameFuncList.empty() ==
false);
16025 if (func == isSgFunctionDeclaration(*(sameFuncList.begin())))
16027 for (j = sameFuncList.begin(); j != sameFuncList.end(); j++)
16031 printf (
"In SageInterface::updateDefiningNondefiningLinks(): (case 1) Testing j = %p set_firstNondefiningDeclaration(%p) \n",*j,func);
16035 if (func_decl != func)
16042 printf (
"In SageInterface::updateDefiningNondefiningLinks(): (case 1) Calling j = %p set_firstNondefiningDeclaration(%p) \n",*j,func);
16052 printf (
"In SageInterface::updateDefiningNondefiningLinks(): (case 2) Testing func = %p set_firstNondefiningDeclaration(%p) \n",func,isSgFunctionDeclaration(*(sameFuncList.begin()))->
get_firstNondefiningDeclaration());
16059 printf (
"In SageInterface::updateDefiningNondefiningLinks(): (case 2) Calling func = %p set_firstNondefiningDeclaration(%p) \n",func,isSgFunctionDeclaration(*(sameFuncList.begin()))->
get_firstNondefiningDeclaration());
16068 assert(source_file != NULL);
16069 assert(position == PreprocessingInfo::before || position == PreprocessingInfo::after);
16071 SgGlobal * global_scope = source_file->get_globalScope();
16074 ROSE_ASSERT(result);
16090 PreprocessingInfo::DirectiveType dtype )
16092 ASSERT_not_null(target);
16095 PreprocessingInfo::DirectiveType mytype=dtype;
16100 if (mytype == PreprocessingInfo::CpreprocessorUnknownDeclaration)
16106 mytype = PreprocessingInfo::C_StyleComment;
16111 mytype = PreprocessingInfo::CplusplusStyleComment;
16116 mytype = PreprocessingInfo::F90StyleComment;
16121 mytype = PreprocessingInfo::AdaStyleComment;
16126 mytype = PreprocessingInfo::JovialStyleComment;
16130 cout <<
"WARNING: SageInterface::attachComment(): Unknown programming language \n";
16136 bool resetPositionInfo =
false;
16139 case PreprocessingInfo::C_StyleComment: comment =
"/* " + content +
" */";
break;
16140 case PreprocessingInfo::CplusplusStyleComment: comment =
"// " + content;
break;
16141 case PreprocessingInfo::FortranStyleComment: comment =
" C " + content;
break;
16142 case PreprocessingInfo::F90StyleComment: comment =
"!" + content;
break;
16143 case PreprocessingInfo::AdaStyleComment: comment =
"-- " + content;
break;
16144 case PreprocessingInfo::JovialStyleComment:
16148 case PreprocessingInfo::CpreprocessorLineDeclaration:
16149 comment =
"#myline " + content;
16150 mytype = PreprocessingInfo::CplusplusStyleComment;
16151 resetPositionInfo =
true;
16153 case PreprocessingInfo::CpreprocessorIfndefDeclaration: comment =
"#ifndef " + content +
"\n";
break;
16154 case PreprocessingInfo::CpreprocessorDefineDeclaration: comment =
"#define " + content +
"\n";
break;
16155 case PreprocessingInfo::CpreprocessorEndifDeclaration: comment =
"#endif" + (content.empty() ?
"\n" : (
" /* " + content +
" */\n"));
break;
16156 case PreprocessingInfo::CpreprocessorEnd_ifDeclaration: comment =
"#end if" + (content.empty() ?
"\n" : (
" /* " + content +
" */\n"));
break;
16160 printf (
"Error: default in switch reached in SageInterface::attachComment() PreprocessingInfo::DirectiveType == %d \n",mytype);
16165 result =
new PreprocessingInfo (mytype,comment,
"transformation-generated", 0, 0, 0, position);
16168 if (resetPositionInfo ==
true)
16171 *(result->get_file_info()) = *(target->get_file_info());
16181 ASSERT_not_null(result);
16182 target->addToAttachedPreprocessingInfo(result);
16188 PreprocessingInfo::CpreprocessorIfDeclaration,
16190 "transformation-generated", 0, 0, 0,
16191 PreprocessingInfo::before
16193 target->addToAttachedPreprocessingInfo(if_macro);
16196 PreprocessingInfo::CpreprocessorEndifDeclaration,
16198 "transformation-generated", 0, 0, 0,
16199 PreprocessingInfo::after
16201 target->addToAttachedPreprocessingInfo(endif_macro);
16214static map<SgSourceFile*, map<string, PreprocessingInfo*> > fileHeaderDict;
16219 if (isSystemHeader)
16220 header_key=
"<"+header_file_name+
">";
16222 header_key=
"\""+header_file_name+
"\"";
16224 if (fileHeaderDict.count(source_file) && fileHeaderDict[source_file].count(header_key))
16225 return fileHeaderDict[source_file][header_key];
16227 vector<SgLocatedNode*> candidates;
16230 SgGlobal* global= source_file -> get_globalScope();
16232 candidates.push_back(global);
16235 SgDeclarationStatementPtrList decl_stmt_list = global->
get_declarations();
16236 for (SgDeclarationStatementPtrList::iterator iter= decl_stmt_list.begin(); iter!=decl_stmt_list.end(); iter++)
16237 candidates.push_back(*iter);
16239 bool found =
false;
16240 for (
size_t ci=0; ci<candidates.size(); ci++)
16245 if (comments == NULL)
continue;
16246 AttachedPreprocessingInfoType::iterator i;
16247 for (i = comments->begin (); i != comments->end (); i++)
16249 if ((*i)->getTypeOfDirective () != PreprocessingInfo::CpreprocessorIncludeDeclaration)
continue;
16250 string content = (*i)->getString ();
16251 if (content.find(header_key) != string::npos)
16253 fileHeaderDict[source_file][header_key] = *i;
16264 return fileHeaderDict[source_file][header_key];
16274 bool supportTokenUnparsing =
false;
16276 assert(source_file != NULL);
16277 assert(position == PreprocessingInfo::before || position == PreprocessingInfo::after);
16279 SgGlobal * global_scope = source_file->get_globalScope();
16282 if (isSystemHeader)
16283 content =
"#include <" + header_file_name +
"> \n";
16285 content =
"#include \"" + header_file_name +
"\" \n";
16288 ROSE_ASSERT(result);
16296 supportTokenUnparsing = source_file->get_unparse_tokens();
16297 bool supportUnparseHeaders = source_file->get_unparseHeaderFiles();
16300 printf (
"supportTokenUnparsing = %s \n",supportTokenUnparsing ?
"true" :
"false");
16301 printf (
"supportUnparseHeaders = %s \n",supportUnparseHeaders ?
"true" :
"false");
16302 printf (
"source_file = %p \n",source_file);
16303 printf (
"global_scope = %p \n",global_scope);
16306 printf (
"Exiting as a test! \n");
16311 if (supportTokenUnparsing ==
false)
16320 if (supportUnparseHeaders ==
true)
16325 printf (
"physical_file_id = %d \n",physical_file_id);
16330 printf (
"Exiting as a test! \n");
16337 global_scope->prepend_statement(emptyDeclaration);
16341 printf (
"Exiting as a test! \n");
16342 ROSE_ASSERT(
false);
16353 bool supportTokenUnparsing =
false;
16359 printf (
"In SageInterface::insertHeader(): filename = %s \n",filename.c_str());
16360 printf (
" --- position = %s \n",PreprocessingInfo::relativePositionName(position).c_str());
16366 ROSE_ASSERT(scope);
16369 ROSE_ASSERT(globalScope != NULL);
16377 if (isSystemHeader)
16378 content =
"#include <" + filename +
"> \n";
16380 content =
"#include \"" + filename +
"\" \n";
16389 ROSE_ASSERT(sourceFile != NULL);
16391 supportTokenUnparsing = sourceFile->get_unparse_tokens();
16393 bool supportUnparseHeaders = sourceFile->get_unparseHeaderFiles();
16395 if (supportUnparseHeaders)
16398 string suffix = Rose::StringUtility ::fileNameSuffix(filename);
16401 if (suffix==
"h" ||suffix==
"hpp"|| suffix==
"hh"||suffix==
"H" ||suffix==
"hxx"||suffix==
"h++" ||suffix==
"tcc")
16406 printf (
"supportTokenUnparsing = %s \n",supportTokenUnparsing ?
"true" :
"false");
16407 printf (
"supportUnparseHeaders = %s \n",supportUnparseHeaders ?
"true" :
"false");
16408 printf (
"sourceFile = %p \n",sourceFile);
16409 printf (
"globalScope = %p \n",globalScope);
16412 printf (
"supportTokenUnparsing = %s \n",supportTokenUnparsing ?
"true" :
"false");
16415 printf (
"Exiting as a test! \n");
16419 SgDeclarationStatementPtrList & stmtList = globalScope->
get_declarations();
16422 printf (
"stmtList.size() = %zu \n",stmtList.size());
16425 if (stmtList.size() > 0)
16427 for (SgDeclarationStatementPtrList::iterator j = stmtList.begin (); j != stmtList.end (); j++)
16431 if ( ((*j)->get_file_info())->isSameFile(srcScope->
get_file_info ()) || ((*j)->get_file_info ())->isTransformation() )
16433 result =
new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration, content,
"Transformation generated",0, 0, 0, PreprocessingInfo::before);
16434 ROSE_ASSERT(result != NULL);
16436 printf (
"Building a PreprocessingInfo: result = %p \n",result);
16444 if (supportTokenUnparsing ==
false)
16446 (*j)->addToAttachedPreprocessingInfo(result,position);
16450 (*j)->addToAttachedPreprocessingInfo(result,position);
16452 printf (
"In SageInterface::insertHeader(): Calling set_containsTransformationToSurroundingWhitespace(true) \n");
16456 (*j)->set_containsTransformationToSurroundingWhitespace(
true);
16465 printf (
"In SageInterface::insertHeader(): declarationStatement = %p = %s \n",declarationStatement,declarationStatement->
class_name().c_str());
16466 printf (
"In SageInterface::insertHeader(): declarationStatement->get_containsTransformationToSurroundingWhitespace() = %s \n",
16467 declarationStatement->get_containsTransformationToSurroundingWhitespace() ?
"true" :
"false");
16474 if (supportUnparseHeaders ==
true)
16479 printf (
"physical_file_id = %d \n",physical_file_id);
16481 emptyDeclaration->get_startOfConstruct()->set_physical_file_id(physical_file_id);
16482 emptyDeclaration->get_endOfConstruct()->set_physical_file_id(physical_file_id);
16484 printf (
"Exiting as a test! \n");
16485 ROSE_ASSERT(
false);
16489 emptyDeclaration->addToAttachedPreprocessingInfo(result, position);
16495 printf (
"break out of for loop: result = %p \n",result);
16505 cerr<<
"SageInterface::insertHeader() Empty file is found!"<<endl;
16506 cerr<<
"#include xxx is preprocessing information which has to be attached to some other located node (a statement for example)"<<endl;
16507 cerr<<
"You may have to insert some statement first before inserting a header"<<endl;
16508 ROSE_ASSERT(
false);
16509 result =
new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration, content,
"Transformation generated",0, 0, 0, PreprocessingInfo::after);
16510 ROSE_ASSERT(result);
16521 if (result != NULL)
16532 printf (
"Exiting as a test! \n");
16533 ROSE_ASSERT(
false);
16537 printf (
"Leaving SageInterface::insertHeader(): filename = %s \n",filename.c_str());
16541 printf (
"Exiting as a test! \n");
16542 ROSE_ASSERT(
false);
16552 ROSE_ASSERT (stmt != NULL);
16553 ROSE_ASSERT (newheader != NULL);
16556 printf (
"In SageInterface::insertHeader (SgStatement* stmt, PreprocessingInfo* newheader, bool asLastHeader) \n");
16562 position = PreprocessingInfo::after;
16564 position = PreprocessingInfo::before;
16570 if (comments != NULL)
16579 AttachedPreprocessingInfoType::iterator i, firsti, lasti;
16580 for (i = comments->begin (); i != comments->end (); i++)
16587 if ((*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorIncludeDeclaration)
16590 if ((*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorIncludeDeclaration)
16592 if (firstExistingHeader == NULL)
16594 firstExistingHeader = (*i);
16598 lastExistingHeader = (*i);
16604 if ( (*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorIncludeDeclaration ||
16605 (*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorEndifDeclaration )
16608 if ((*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorIncludeDeclaration)
16610 if (firstExistingHeader == NULL)
16612 firstExistingHeader = (*i);
16616 lastExistingHeader = (*i);
16619 if ((*i)->getTypeOfDirective () == PreprocessingInfo::CpreprocessorEndifDeclaration)
16621 if (firstExistingEndif == NULL)
16623 firstExistingEndif = (*i);
16638 if (lastExistingHeader == NULL)
16642 comments->insert (lasti+1, newheader);
16647 if (firstExistingHeader == NULL)
16651 comments->insert (firsti, newheader);
16659 printf (
"Exiting as a test! \n");
16660 ROSE_ASSERT(
false);
16669 ROSE_ASSERT (source_file != NULL);
16670 SgGlobal* globalScope = source_file->get_globalScope();
16671 ROSE_ASSERT (globalScope != NULL);
16675 if (isSystemHeader)
16676 content =
"#include <" + filename +
"> \n";
16678 content =
"#include \"" + filename +
"\" \n";
16685 position = PreprocessingInfo::after;
16687 position = PreprocessingInfo::before;
16690 SgDeclarationStatementPtrList & stmtList = globalScope->
get_declarations ();
16691 if (stmtList.size()>0)
16693 for (SgDeclarationStatementPtrList::iterator j = stmtList.begin (); j != stmtList.end (); j++)
16698 if ( (*j)->get_file_info()->isSameFile(globalScope->
get_file_info()) || (*j)->get_file_info()->isTransformation() )
16701 printf (
"In SageInterface::insertHeader(): Found statement to attached #include: *j = %p = %s \n",*j,(*j)->class_name().c_str());
16702 printf (
" --- unparseToString() = %s \n",(*j)->unparseToString().c_str());
16704 result =
new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration, content,
"Transformation generated",0, 0, 0, PreprocessingInfo::before);
16705 ROSE_ASSERT(result);
16709 printf (
"Exiting as a test! \n");
16718 cerr<<
"SageInterface::insertHeader() Empty file is found!"<<endl;
16719 cerr<<
"#include xxx is preprocessing information which has to be attached to some other located node (a statement for example)"<<endl;
16720 cerr<<
"You may have to insert some statement first before inserting a header"<<endl;
16723 result =
new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration,
16724 content,
"Transformation generated",0, 0, 0, PreprocessingInfo::after);
16725 ROSE_ASSERT(result);
16732 printf (
"In SageInterface::insertHeader(): Marking include file for filename = %s as a transformation \n",filename.c_str());
16742 printf (
"Exiting as a test! \n");
16743 ROSE_ASSERT(
false);
16761 ROSE_ASSERT(target != NULL);
16768 PreprocessingInfo::DirectiveType mytype = PreprocessingInfo::CpreprocessorIfDeclaration;
16771 printf (
"Warning: attachArbitraryText(): attaching arbitrary text to the AST as a #if declaration: text = %s \n",text.c_str());
16773 result =
new PreprocessingInfo (mytype,text,
"transformation-generated", 0, 0, 0, position);
16774 ROSE_ASSERT(result);
16781 target->addToAttachedPreprocessingInfo(result);
16795 ROSE_ASSERT(target != NULL);
16796 AttachedPreprocessingInfoType *info= target->getAttachedPreprocessingInfo ();
16797 if (info == NULL)
return;
16798 AttachedPreprocessingInfoType::iterator j;
16799 for (j = info->begin (); j != info->end (); j++)
16801 if ((*j)->getTypeOfDirective()==PreprocessingInfo::CMacroCall)
16803#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
16805 std::ostringstream os;
16806 token_container tc = (*j)->get_macro_call()->expanded_macro;
16807 token_container::const_iterator iter;
16808 for (iter=tc.begin(); iter!=tc.end(); iter++)
16809 os<<(*iter).get_value();
16812 string pragmaText = target->get_pragma()->get_pragma();
16813 string targetString = (*j)->getString();
16814 string replacement = os.str();
16816 size_t pos1 = pragmaText.find(targetString);
16817 while (pos1 != string::npos)
16819 pragmaText.replace(pos1, targetString.size(), replacement);
16820 pos1 = pragmaText.find(targetString);
16822 delete target->get_pragma();
16836 if (isSgWhileStmt(loopOrSwitch) || isSgDoWhileStmt(loopOrSwitch) ||
16837 isSgForStatement(loopOrSwitch)) {
16839 }
else if (isSgSwitchStatement(loopOrSwitch)) {
16840 body = isSgSwitchStatement(loopOrSwitch)->
get_body();
16842 ROSE_ASSERT (body);
16844 if (!breaks.empty()) {
16845 static int breakLabelCounter = 0;
16850 isSgScopeStatement(loopOrSwitch->
get_parent()));
16852 for (
size_t j = 0; j < breaks.size(); ++j) {
16857 newGoto->
set_parent(breaks[j]->get_parent());
16864 ROSE_ASSERT(node!=NULL);
16874 ROSE_ASSERT(node!=NULL);
16887 ROSE_ASSERT(stmt_src != NULL);
16888 ROSE_ASSERT(stmt_dst != NULL);
16891 if (infoList == NULL)
16894 printf (
"In SageInterface::movePreprocessingInfo(): infoList == NULL: exiting movePreprocessingInfo() \n");
16899 AttachedPreprocessingInfoType* infoToRemoveList =
new AttachedPreprocessingInfoType();
16902 printf (
"In SageInterface::movePreprocessingInfo(): \n");
16903 printf (
" --- stmt_src = %p = %s src_position = %d \n",stmt_src,stmt_src->
class_name().c_str(),src_position);
16905 if (src_declarationStatement != NULL)
16908 printf (
"src_declarationStatement->get_definingDeclaration() = %p \n",src_declarationStatement->
get_definingDeclaration());
16910 printf (
" --- stmt_dst = %p = %s dst_position = %d \n",stmt_dst,stmt_dst->
class_name().c_str(),dst_position);
16912 if (dst_declarationStatement != NULL)
16915 printf (
"dst_declarationStatement->get_definingDeclaration() = %p \n",dst_declarationStatement->
get_definingDeclaration());
16917 printf (
" --- src_position = %s \n",PreprocessingInfo::relativePositionName(src_position).c_str());
16918 printf (
" --- dst_position = %s \n",PreprocessingInfo::relativePositionName(dst_position).c_str());
16919 printf (
" --- usePrepend = %s \n",usePrepend ?
"true" :
"false");
16921 printf (
" --- infoList = %p \n",infoList);
16922 printf (
" --- infoToRemoveList = %p \n",infoToRemoveList);
16925 printf (
" --- dst_infoList = %p \n",dst_infoList);
16928 printf (
"****************************************************************** \n");
16929 printf (
"In SageInterface::movePreprocessingInfo(): Attached comments and CPP directives: stmt_src \n");
16931 printf (
"In SageInterface::movePreprocessingInfo(): Attached comments and CPP directives: stmt_dst \n");
16933 printf (
"****************************************************************** \n");
16943 printf (
" --- infoList->size() = %zu \n",infoList->size());
16944 printf (
" --- infoToRemoveList->size() = %zu \n",infoToRemoveList->size());
16950 for (Rose_STL_Container<PreprocessingInfo*>::iterator i = (*infoList).begin(); i != (*infoList).end(); i++)
16953 ROSE_ASSERT(*i != NULL);
16958 ROSE_ASSERT(info != NULL);
16961 printf (
"counter = %d Processing PreprocessingInfo = %s \n",counter,info->getString().c_str());
16970 for (Rose_STL_Container<PreprocessingInfo*>::iterator i = (*infoList).begin(); i != (*infoList).end(); i++)
16972 ROSE_ASSERT(*i != NULL);
16975 ROSE_ASSERT(info != NULL);
16978 (info->getTypeOfDirective()==PreprocessingInfo::C_StyleComment)||
16979 (info->getTypeOfDirective()==PreprocessingInfo::CplusplusStyleComment)||
16980 (info->getTypeOfDirective()==PreprocessingInfo::FortranStyleComment)||
16981 (info->getTypeOfDirective()==PreprocessingInfo::F90StyleComment)||
16982 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorIncludeDeclaration )||
16983 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorIncludeNextDeclaration )||
16984 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorDefineDeclaration )||
16985 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorUndefDeclaration)||
16986 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorIfdefDeclaration )||
16987 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorIfndefDeclaration )||
16988 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorIfDeclaration )||
16989 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorDeadIfDeclaration )||
16990 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorElseDeclaration )||
16991 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorElifDeclaration )||
16992 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorEndifDeclaration ) ||
16993 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorEnd_ifDeclaration ) ||
16994 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorLineDeclaration) ||
16995 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorErrorDeclaration) ||
16996 (info->getTypeOfDirective()==PreprocessingInfo::CpreprocessorWarningDeclaration) ||
16998 (info->getTypeOfDirective()==PreprocessingInfo::ClinkageSpecificationStart) ||
16999 (info->getTypeOfDirective()==PreprocessingInfo::ClinkageSpecificationEnd)
17004 if ( src_position == PreprocessingInfo::undef || info->getRelativePosition() == src_position)
17006 if (usePrepend ==
true)
17009 if (prevItem == NULL)
17027 info->setAsTransformation();
17035 stmt_dst->set_containsTransformationToSurroundingWhitespace(
true);
17036 if (isMarkedAsModified ==
false)
17043 (*infoToRemoveList).push_back(*i);
17047 if (dst_position != PreprocessingInfo::undef)
17049 info->setRelativePosition(dst_position);
17055 AttachedPreprocessingInfoType::iterator j;
17056 for (j = (*infoToRemoveList).begin(); j != (*infoToRemoveList).end(); j++)
17058 infoList->erase( find(infoList->begin(),infoList->end(),*j) );
17094 return info && (info->getRelativePosition () != pos);
17104 return info && !isNotRelPos (info, pos);
17111 ASSERT_not_null(src_node);
17114 AttachedPreprocessingInfoType* info = src_node->get_attachedPreprocessingInfoPtr();
17118 remove_copy_if(info->begin(),
17120 back_inserter(save_buf),
17121 [pos](
auto x) {
return !isRelPos(x, pos); }
17125 AttachedPreprocessingInfoType::iterator
17126 new_end = remove_if(info->begin(),
17128 [pos](
auto x) { return isRelPos(x, pos); }
17130 info->erase(new_end, info->end());
17134static AttachedPreprocessingInfoType *
17138 AttachedPreprocessingInfoType* info_list = s->get_attachedPreprocessingInfoPtr ();
17141 info_list =
new AttachedPreprocessingInfoType;
17142 ROSE_ASSERT (info_list);
17143 s->set_attachedPreprocessingInfoPtr (info_list);
17147 ROSE_ASSERT (info_list);
17154 if (save_buf.size()==0)
return;
17156 AttachedPreprocessingInfoType* info = createInfoList (dst_node);
17157 ROSE_ASSERT (info);
17164 if (pos==PreprocessingInfo::before)
17166 for(AttachedPreprocessingInfoType::reverse_iterator i=save_buf.rbegin();i!=save_buf.rend();i++)
17167 info->insert(info->begin(),*i);
17170 else if (pos==PreprocessingInfo::after)
17171 copy (save_buf.begin (), save_buf.end (), back_inserter (*info));
17172 else if (pos==PreprocessingInfo::inside)
17174 copy (save_buf.begin (), save_buf.end (), back_inserter (*info));
17175 cerr<<
"SageInterface::pastePreprocessingInfo() pos==PreprocessingInfo::inside is not supported."<<endl;
17176 save_buf[0]->display(
"ttt");
17182 ROSE_ASSERT(locatedNode != NULL);
17183 AttachedPreprocessingInfoType *comments =
17186 if (comments != NULL)
17188 printf (
"-----------------------------------------------\n");
17189 printf (
"Found an IR node (at %p of type: %s) in file %s \n",
17190 locatedNode, locatedNode->
class_name ().c_str (),
17191 (locatedNode->
get_file_info ()->get_filenameString ()).c_str ());
17193 AttachedPreprocessingInfoType::iterator i;
17194 for (i = comments->begin (); i != comments->end (); i++)
17197 (
"with attached preprocessingInfo numbering #%d :------------- \nclassification= %s:\nString format:%s\n",
17199 PreprocessingInfo::directiveTypeName ((*i)->getTypeOfDirective ()).
17200 c_str (), (*i)->getString ().c_str ());
17201 if ((*i)->getRelativePosition () == PreprocessingInfo::inside)
17202 printf (
"relative position is: inside\n");
17204 printf (
"relative position is: %s\n", \
17205 ((*i)->getRelativePosition () == PreprocessingInfo::before) ?
"before" :
"after");
17210 printf (
"No attached preprocessing info. (at %p of type: %s): \n", locatedNode,
17226template <
class ParentNode>
17236 if (basicblock == NULL) {
17238 (stmt.*setter)(basicblock);
17242 ROSE_ASSERT (basicblock != NULL);
17249 if (!isSgBasicBlock(b)) {
17257 ROSE_ASSERT (isSgBasicBlock(b));
17258 return isSgBasicBlock(b);
17264 if (!isSgBasicBlock(b)) {
17272 ROSE_ASSERT (isSgBasicBlock(b));
17273 return isSgBasicBlock(b);
17279 if (!isSgBasicBlock(b)) {
17287 ROSE_ASSERT (isSgBasicBlock(b));
17288 return isSgBasicBlock(b);
17293 ROSE_ASSERT (fs != NULL);
17295 return ensureBasicBlock_aux(*fs, &SgUpcForAllStatement::get_loop_body, &SgUpcForAllStatement::set_loop_body);
17300 if (!isSgBasicBlock(b)) {
17308 ROSE_ASSERT (isSgBasicBlock(b));
17309 return isSgBasicBlock(b);
17314 if (!isSgBasicBlock(b)) {
17322 ROSE_ASSERT (isSgBasicBlock(b));
17323 return isSgBasicBlock(b);
17328 if (!isSgBasicBlock(b)) {
17336 ROSE_ASSERT (isSgBasicBlock(b));
17337 return isSgBasicBlock(b);
17342 if (!isSgBasicBlock(b)) {
17350 printf (
"In SageInterface::ensureBasicBlockAsTrueBodyOfIf(): Added SgBasicBlock b = %p to addedBasicBlockNodes.size() = %zu \n",b,addedBasicBlockNodes.size());
17353 ROSE_ASSERT (isSgBasicBlock(b));
17354 return isSgBasicBlock(b);
17364 ROSE_ASSERT(bb != NULL);
17365 addedBasicBlockNodes.push_back(bb);
17367 printf (
"In SageInterface::recordNormalizations(): Added SgBasicBlock = %p to addedBasicBlockNodes.size() = %zu \n",bb,addedBasicBlockNodes.size());
17378 printf (
"In SageInterface::cleanupNontransformedBasicBlockNode(): addedBasicBlockNodes.size() = %zu \n",addedBasicBlockNodes.size());
17381 for (vector<SgBasicBlock*>::iterator i = addedBasicBlockNodes.begin(); i != addedBasicBlockNodes.end(); i++)
17384 ROSE_ASSERT(b != NULL);
17388 printf (
"This SgBasicBlock can be denormalized: b = %p \n",b);
17391 ROSE_ASSERT(parentOfBlock != NULL);
17396 ROSE_ASSERT(s != NULL);
17398 switch (parentOfBlock->
variantT())
17402 SgIfStmt* ifStatement = isSgIfStmt(parentOfBlock);
17406 printf (
"Calling set_true_body on ifStatement = %p = %s \n",ifStatement,ifStatement->
class_name().c_str());
17411 printf (
"Calling set_parent on s = %p = %n \n",s,s->
class_name().c_str());
17416 printf (
"DONE: Calling set_parent on s = %p = %n \n",s,s->
class_name().c_str());
17425 printf (
"Calling set_false_body on ifStatement = %p = %s \n",ifStatement,ifStatement->
class_name().c_str());
17430 printf (
"Calling set_parent on s = %p = %n \n",s,s->
class_name().c_str());
17435 printf (
"DONE: Calling set_parent on s = %p = %n \n",s,s->
class_name().c_str());
17439 printf (
"Mark as NOT modified after calling set_false_body on ifStatement = %p = %n \n",ifStatement,ifStatement->
class_name().c_str());
17442 printf (
"Error: case not handled in case V_SgIfStmt: parentOfBlock = %p = %s \n",parentOfBlock,parentOfBlock->
class_name().c_str());
17450 case V_SgWhileStmt:
17452 SgWhileStmt* whileStatement = isSgWhileStmt(parentOfBlock);
17453 if (b == whileStatement->
get_body())
17462 case V_SgSwitchStatement:
17465 if (b == switchStatement->
get_body())
17474 case V_SgForStatement:
17486 case V_SgCaseOptionStmt:
17488 SgCaseOptionStmt* caseOptionStatement = isSgCaseOptionStmt(parentOfBlock);
17489 if (b == caseOptionStatement->
get_body())
17498 case V_SgDefaultOptionStmt:
17501 if (b == defaultOptionStatement->
get_body())
17503 defaultOptionStatement->
set_body(s);
17510 case V_SgDoWhileStmt:
17512 SgDoWhileStmt* doWhileStatement = isSgDoWhileStmt(parentOfBlock);
17513 if (b == doWhileStatement->
get_body())
17523 printf (
"Error: case not handled in switch: parentOfBlock = %p = %s \n",parentOfBlock,parentOfBlock->
class_name().c_str());
17529 if (wasPreviouslyModified ==
false)
17534 printf (
"In SageInterface::cleanupNontransformedBasicBlockNode(): parentOfBlock reset to FALSE after IR node member function call (e.g. set_body()): parentOfBlock = %p = %s \n",parentOfBlock,parentOfBlock->
class_name().c_str());
17541 printf (
"Exiting as a test! \n");
17548 printf (
"Leaving SageInterface::cleanupNontransformedBasicBlockNode(): addedBasicBlockNodes.size() = %zu \n",addedBasicBlockNodes.size());
17556 if (!createEmptyBody && (b == NULL || isSgNullStatement(b)))
17558 if (!isSgBasicBlock(b)) {
17566 ROSE_ASSERT (isSgBasicBlock(b));
17567 return isSgBasicBlock(b);
17572 if (!isSgBasicBlock(b)) {
17577 ROSE_ASSERT (isSgBasicBlock(b));
17578 return isSgBasicBlock(b);
17584 if (!isSgBasicBlock(b)) {
17589 ROSE_ASSERT (isSgBasicBlock(b));
17590 return isSgBasicBlock(b);
17602 case V_SgForStatement:
17604 if (isSgForStatement(p)->get_loop_body() == s)
17608 case V_SgUpcForAllStatement:
17611 if (upcforall.get_loop_body() == s)
17615 case V_SgWhileStmt:
17617 if (isSgWhileStmt(p)->get_body() == s)
17621 case V_SgDoWhileStmt:
17623 if (isSgDoWhileStmt(p)->get_body() == s)
17627 case V_SgSwitchStatement:
17629 if (isSgSwitchStatement(p)->get_body() == s)
17633 case V_SgCaseOptionStmt:
17635 if (isSgCaseOptionStmt(p)->get_body() == s)
17639 case V_SgDefaultOptionStmt:
17641 if (isSgDefaultOptionStmt(p)->get_body() == s)
17645 case V_SgCatchOptionStmt:
17647 if (isSgCatchOptionStmt(p)->get_body() == s)
17653 if (isSgIfStmt(p)->get_true_body() == s)
17655 else if (isSgIfStmt(p)->get_false_body() == s)
17661 if (isSgOmpBodyStatement(p))
17673 ROSE_ASSERT (singleStmt != NULL);
17674 ROSE_ASSERT (isSgBasicBlock(singleStmt) == NULL);
17686 case V_SgForStatement:
17688 if (isSgForStatement(p)->get_loop_body() == s)
17692 case V_SgUpcForAllStatement:
17696 if (upcforall.get_loop_body() == s)
17700 case V_SgWhileStmt:
17702 if (isSgWhileStmt(p)->get_body() == s)
17706 case V_SgDoWhileStmt:
17708 if (isSgDoWhileStmt(p)->get_body() == s)
17712 case V_SgSwitchStatement:
17714 if (isSgSwitchStatement(p)->get_body() == s)
17718 case V_SgCaseOptionStmt:
17720 if (isSgCaseOptionStmt(p)->get_body() == s)
17724 case V_SgDefaultOptionStmt:
17726 if (isSgDefaultOptionStmt(p)->get_body() == s)
17730 case V_SgCatchOptionStmt:
17732 if (isSgCatchOptionStmt(p)->get_body() == s)
17738 if (isSgIfStmt(p)->get_true_body() == s)
17740 else if (isSgIfStmt(p)->get_false_body() == s)
17746 if (isSgOmpBodyStatement(p))
17753 ROSE_ASSERT (rt != NULL);
17767 case V_SgBasicBlock:
return isSgBasicBlock(p);
17768 case V_SgForStatement:
17770 if (isSgForStatement(p)->get_loop_body() == s)
17772 else if (isSgForStatement(p)->get_test() == s)
17775 else if (isSgForStatement(p)->get_for_init_stmt() == s)
17781 case V_SgUpcForAllStatement:
17785 if (upcforall.get_loop_body() == s)
17788 ROSE_ASSERT( (s == upcforall.get_for_init_stmt())
17789 || (s == upcforall.get_test())
17793 case V_SgWhileStmt:
17795 if (isSgWhileStmt(p)->get_body() == s)
17797 else if (isSgWhileStmt(p)->get_condition() == s)
17803 case V_SgDoWhileStmt:
17805 if (isSgDoWhileStmt(p)->get_body() == s)
17807 else if (isSgDoWhileStmt(p)->get_condition() == s)
17813 case V_SgSwitchStatement:
17815 if (isSgSwitchStatement(p)->get_body() == s)
17817 else if (isSgSwitchStatement(p)->get_item_selector() == s)
17823 case V_SgCatchOptionStmt:
17825 if (isSgCatchOptionStmt(p)->get_body() == s)
17827 else if (isSgCatchOptionStmt(p)->get_condition() == s)
17835 if (isSgIfStmt(p)->get_true_body() == s)
17837 else if (isSgIfStmt(p)->get_false_body() == s)
17839 else if (isSgIfStmt(p)->get_conditional() == s)
17847 if (isSgOmpBodyStatement(p))
17862 void SageInterface::changeAllLoopBodiesToBlocks(
SgNode* top) {
17863 cerr<<
"Warning: SageInterface::changeAllLoopBodiesToBlocks() is being replaced by SageInterface::changeAllBodiesToBlocks()."<<endl;
17864 cerr<<
"Please use SageInterface::changeAllBodiesToBlocks() if you can."<<endl;
17872 bool allowEmptyBody;
17873 Visitor (
bool flag):allowEmptyBody(flag) {}
17874 virtual void visit(
SgNode* n) {
17879 case V_SgForStatement: {
17883 case V_SgWhileStmt: {
17887 case V_SgDoWhileStmt: {
17891 case V_SgSwitchStatement: {
17900 printf (
"In changeAllBodiesToBlocks(): case SgIfStmt: n->get_isModified() = %s \n",n->
get_isModified() ?
"true" :
"false");
17907 printf (
"In changeAllBodiesToBlocks(): AFTER RESET: case SgIfStmt: n->get_isModified() = %s \n",n->
get_isModified() ?
"true" :
"false");
17912 case V_SgCatchOptionStmt: {
17916 case V_SgUpcForAllStatement: {
17923 if (isSgOmpBodyStatement(n))
17930 if (wasPreviouslyModified ==
false)
17935 printf (
"In SageInterface::changeAllBodiesToBlocks(): parentOfBlock reset to FALSE after IR node member function call (e.g. set_body()): parentOfBlock = %p = %s \n",n,n->
class_name().c_str());
17944 Visitor(createEmptyBody).traverse(top, postorder);
17965#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
17966 SgStatement* enclosingStatement = getStatementOfExpression(from);
17967 SgExprStatement* exprStatement = isSgExprStatement(enclosingStatement);
17969 SgForStatement* forStatement = isSgForStatement(enclosingStatement);
17970 SgReturnStmt* returnStatement = isSgReturnStmt(enclosingStatement);
17976 ROSE_ASSERT (exprStatement || forStatement || returnStatement || varDeclarationStatement);
17978 if (varDeclarationStatement)
17985 ROSE_ASSERT (root);
17988 if (forStatement && forStatement->get_increment() == root)
17999 forStatement->get_increment()->
set_parent(incrStmt);
18003 forStatement->set_increment(ne);
18010 assert (enclosingStmtParent);
18011 SgWhileStmt* whileStatement = isSgWhileStmt(enclosingStmtParent);
18012 SgDoWhileStmt* doWhileStatement = isSgDoWhileStmt(enclosingStmtParent);
18013 SgIfStmt* ifStatement = isSgIfStmt(enclosingStmtParent);
18015 SgForStatement* enclosingForStatement = isSgForStatement(enclosingStmtParent);
18016 if (enclosingForStatement && enclosingForStatement->get_test() == exprStatement)
18028 pushTestIntoBody(enclosingForStatement);
18031 else if (whileStatement && whileStatement->
get_condition() == exprStatement)
18044 pushTestIntoBody(whileStatement);
18048 else if (doWhileStatement && doWhileStatement->
get_condition() == exprStatement)
18064 myStatementInsert(doWhileStatement, new_statement,
false);
18066 SgName varname =
"rose__temp1";
18071 varname,
buildBoolType(), assignInitializer, new_statement);
18074 initname->set_scope(new_statement);
18106 else if (ifStatement && ifStatement->
get_conditional() == exprStatement)
18112 myStatementInsert(ifStatement, new_statement,
false);
18114 SgName varname =
"rose__temp2";
18123 initname->set_scope(new_statement);
18148 else if (switchStatement && switchStatement->
get_item_selector() == exprStatement)
18150 SgExpression* switchCond = exprStatement->get_expression();
18151 ROSE_ASSERT (switchCond);
18156 myStatementInsert(switchStatement, new_statement,
false);
18158 SgName varname =
"rose__temp3";
18205#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
18206 SgStatement* stmt = getStatementOfExpression(from);
18208 if (isSgExprStatement(stmt))
18222 if (isSgAssignOp(top) && isSgAssignOp(top)->get_rhs_operand() == from)
18240 convertInitializerIntoAssignment(init);
18243 SgExprStatement* new_stmt = isSgExprStatement(getStatementOfExpression(from));
18244 assert (new_stmt != NULL);
18245 replaceAssignmentStmtWithStatement(new_stmt, to);
18262 ROSE_ASSERT(func&&s);
18264 Rose_STL_Container <SgNode* > stmts = NodeQuery::querySubTree(func, V_SgReturnStmt);
18266 Rose_STL_Container<SgNode*>::iterator i;
18267 for (i=stmts.begin();i!=stmts.end();i++)
18270 ROSE_ASSERT(cur_stmt);
18273 bool needRewrite = (exp != NULL) && !(isSgValueExp(exp));
18284 if (stmts.size()==0 )
18289 cout<<
"In instrumentEndOfFunction(), found an empty function body.! "<<endl;
18301 return ((stmt->get_declarationModifier()).get_storageModifier()).isStatic();
18308 return ((stmt->get_declarationModifier()).get_storageModifier()).setStatic();
18314 return ((stmt->get_declarationModifier()).get_storageModifier()).isExtern();
18322 return ((stmt->get_declarationModifier()).get_storageModifier()).setExtern();
18329 return name->get_storageModifier().isMutable();
18342 std::vector<SgInitializedName*> in_params;
18354 std::vector<SgInitializedName*> out_params;
18364 case V_SgCharVal:
return (
long long)(isSgCharVal(expr)->get_value());
18365 case V_SgUnsignedCharVal:
return isSgUnsignedCharVal(expr)->get_value();
18366 case V_SgShortVal:
return (
long long)(isSgShortVal(expr)->get_value());
18367 case V_SgUnsignedShortVal:
return isSgUnsignedShortVal(expr)->get_value();
18368 case V_SgIntVal:
return (
long long)(isSgIntVal(expr)->get_value());
18369 case V_SgUnsignedIntVal:
return isSgUnsignedIntVal(expr)->get_value();
18370 case V_SgLongIntVal:
return (
long long)(isSgLongIntVal(expr)->get_value());
18371 case V_SgUnsignedLongVal:
return isSgUnsignedLongVal(expr)->get_value();
18372 case V_SgLongLongIntVal:
return isSgLongLongIntVal(expr)->get_value();
18373 case V_SgUnsignedLongLongIntVal:
return isSgUnsignedLongLongIntVal(expr)->get_value();
18374 case V_SgBoolValExp:
return (
long long )(isSgBoolValExp(expr)->get_value());
18380 printf (
"ERROR: In SageInterface::getIntegerConstantValue(): default reached: expr = %p = %s \n",expr,expr->
class_name().c_str());
18381 ROSE_ASSERT (
false);
18386 ROSE_ASSERT (!
"Bad kind return in getIntegerConstantValue");
18391#ifdef ROSE_ENABLE_BINARY_ANALYSIS
18400 ROSE_ASSERT(binary!=NULL);
18405 if (1==headers.size()) {
18406 requisite_header = headers[0];
18408 for (SgAsmGenericHeaderPtrList::const_iterator hi=headers.begin(); hi!=headers.end(); ++hi) {
18409 if (isSgAsmPEFileHeader(*hi)) {
18410 requisite_header = isSgAsmPEFileHeader(*hi);
18415 ROSE_ASSERT(requisite_header!=NULL);
18418 const SgAsmInterpretationPtrList &interps = binary->get_interpretations()->
get_interpretations();
18419 for (SgAsmInterpretationPtrList::const_iterator ii=interps.begin(); ii!=interps.end(); ++ii) {
18420 const SgAsmGenericHeaderPtrList &headers = (*ii)->get_headers()->get_headers();
18421 for (SgAsmGenericHeaderPtrList::const_iterator hi=headers.begin(); hi!=headers.end(); ++hi) {
18422 if ((*hi)==requisite_header)
18427 ROSE_ASSERT(!
"no appropriate interpretation");
18440 SgNode* copy = n->copy(*
this);
18444 if (fileInfo != NULL)
18453 } collectDependentDeclarationsCopyType;
18461 vector<PreprocessingInfo*> cppDirectiveList;
18463 void visit(
SgNode *astNode);
18471 if (locatedNode != NULL)
18475 if (comments != NULL)
18478 printf (
"Found attached comments (at %p of type: %s): \n",locatedNode,locatedNode->
sage_class_name());
18480 AttachedPreprocessingInfoType::iterator i;
18481 for (i = comments->begin(); i != comments->end(); i++)
18483 ROSE_ASSERT ( (*i) != NULL );
18485 printf (
" Attached Comment (relativePosition=%s): %s\n",
18486 ((*i)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
18487 (*i)->getString().c_str());
18488 printf (
"Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
18489 (*i)->get_file_info()->display(
"comment/directive location");
18497 cppDirectiveList.push_back(*i);
18499 printf (
" Attached include directive (relativePosition=%s): %s\n",
18500 ((*i)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
18501 (*i)->getString().c_str());
18509 printf (
"No attached comments (at %p of type: %s): \n",locatedNode,locatedNode->
sage_class_name());
18520vector<PreprocessingInfo*>
18527 return t.cppDirectiveList;
18531vector<PreprocessingInfo*>
18538 return t.cppDirectiveList;
18543outputPreprocessingInfoList (
const vector<PreprocessingInfo*> & l )
18547 vector<PreprocessingInfo*>::const_iterator i = l.begin();
18548 while ( i != l.end() )
18550 printf (
" Attached include directive (relativePosition=%s): %s\n",
18551 ((*i)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
18552 (*i)->getString().c_str());
18567 case V_SgNamespaceDefinitionStatement:
18570 declaration = namespaceDefinition->get_namespaceDeclaration();
18574 case V_SgClassDefinition:
18575 case V_SgTemplateInstantiationDefn:
18584 printf (
"Error: default reached in getAssociatedDeclaration(): scope = %p = %s \n",scope,scope->
class_name().c_str());
18590 ROSE_ASSERT(declaration != NULL);
18592 return declaration;
18601 vector<SgDeclarationStatement*> declarationList;
18605 vector<SgSymbol*> symbolList;
18608 set<SgDeclarationStatement*> alreadySavedDeclarations;
18611 void visit(
SgNode *astNode);
18627 ROSE_ASSERT(scope != NULL);
18632 SgGlobal* globalScope = isSgGlobal(scope);
18633 if (globalScope == NULL)
18640 ROSE_ASSERT(parentScope != NULL);
18641 while (globalScope == NULL)
18643 associatedDeclaration = getAssociatedDeclaration(parentScope);
18644 ROSE_ASSERT(associatedDeclaration != NULL);
18646 parentScope = parentScope->
get_scope();
18647 globalScope = isSgGlobal(parentScope);
18653 return returnDeclaration;
18659outputDeclarationList (
const vector<SgDeclarationStatement*> & l )
18664 vector<SgDeclarationStatement*>::const_iterator i = l.begin();
18665 while ( i != l.end() )
18667 printf (
"In outputDeclarationList(): list[%d] = %p = %s = %s \n",counter++,*i,(*i)->class_name().c_str(),
SageInterface::get_name(*i).c_str());
18675 if (declaration != NULL)
18684 if (alreadySavedDeclarations.find(dependentDeclaration) == alreadySavedDeclarations.end())
18687 printf (
"In CollectDependentDeclarationsTraversal::visit(): selected dependentDeclaration = %p = %s = %s \n",
18691 declarationList.push_back(dependentDeclaration);
18694 alreadySavedDeclarations.insert(dependentDeclaration);
18696 printf (
"In CollectDependentDeclarationsTraversal::visit(): astNode = %p = %s = %s \n",astNode,astNode->
class_name().c_str(),
SageInterface::get_name(astNode).c_str());
18697 printf (
"############### ADDING dependentDeclaration = %p = %s to alreadySavedDeclarations set (size = %" PRIuPTR
") \n",
18698 dependentDeclaration,dependentDeclaration->
class_name().c_str(),alreadySavedDeclarations.size());
18706 printf (
"In CollectDependentDeclarationsTraversal::visit(): astNode = %p = %s = %s \n",astNode,astNode->
class_name().c_str(),
SageInterface::get_name(astNode).c_str());
18707 printf (
"############### EXISTING dependentDeclaration = %p = %s found in alreadySavedDeclarations set (size = %" PRIuPTR
") \n",
18708 dependentDeclaration,dependentDeclaration->
class_name().c_str(),alreadySavedDeclarations.size());
18715static std::vector<SgTypedefDeclaration*> collectTypedefDeclarations(
SgType* type)
18717 ROSE_ASSERT(type != NULL);
18718 std::vector<SgTypedefDeclaration*> result;
18719 SgType* currentType = type;
18729 modType = isSgModifierType(currentType);
18732 currentType = modType->get_base_type();
18736 refType = isSgReferenceType(currentType);
18739 currentType = refType->get_base_type();
18743 pointType = isSgPointerType(currentType);
18746 currentType = pointType->get_base_type();
18750 arrayType = isSgArrayType(currentType);
18753 currentType = arrayType->get_base_type();
18757 typedefType = isSgTypedefType(currentType);
18768 result.push_back(decl);
18782 if (result.size()>0)
18784 cout<<
"------------Found a chain of typedef decls: count="<<result.size()<<endl;
18785 for (vector <SgTypedefDeclaration*>::const_iterator iter = result.begin();
18786 iter!=result.end(); iter ++)
18813 if (fileInfo != NULL && fileInfo->isFrontendSpecific() ==
false && (isSgStatement(astNode) != NULL) )
18815 printf (
"\n\nIn CollectDependentDeclarationsTraversal::visit(): astNode = %p = %s = %s \n",astNode,astNode->
class_name().c_str(),
SageInterface::get_name(astNode).c_str());
18818 printf (
"alreadySavedDeclarations.size() = %" PRIuPTR
" \n",alreadySavedDeclarations.size());
18819 for (set<SgDeclarationStatement*>::iterator i = alreadySavedDeclarations.begin(); i != alreadySavedDeclarations.end(); i++)
18821 printf (
"alreadySavedDeclarations %d: %p = %s \n",counter++,*i,(*i)->class_name().c_str());
18832 if (initializedname != NULL)
18834 SgType* type = initializedname->get_type();
18837 std::vector <SgTypedefDeclaration*> typedefVec = collectTypedefDeclarations(type);
18838 for (std::vector <SgTypedefDeclaration*>::const_iterator iter =typedefVec.begin();
18839 iter != typedefVec.end(); iter++)
18842 addDeclaration(typedef_decl);
18866 SgNamedType* namedType = isSgNamedType(strippedType);
18867 if (namedType != NULL)
18875 if (classDeclaration != NULL)
18882 if (declaration != NULL)
18885 addDeclaration(declaration);
18888 addDeclaration (classDeclaration);
18899 ROSE_ASSERT(classSymbol != NULL);
18902 symbolList.push_back(classSymbol);
18907 if (enum_decl != NULL)
18910 ROSE_ASSERT(declaration != NULL);
18911 addDeclaration(declaration);
18916 ROSE_ASSERT(esymbol!= NULL);
18917 symbolList.push_back(esymbol);
18921 printf (
"Found reference to type = %p = %s strippedType = %p = %s \n",type,type->
class_name().c_str(),strippedType,strippedType->
class_name().c_str());
18928 if (functionCallExp != NULL)
18933 if (declaration != NULL)
18934 addDeclaration(declaration);
18941 if (functionSymbol)
18942 symbolList.push_back(functionSymbol);
18947 SgEnumVal * eval = isSgEnumVal(astNode);
18950 declaration = eval->get_declaration();
18951 ROSE_ASSERT(declaration != NULL);
18952 addDeclaration(declaration);
18954 ROSE_ASSERT(symbol != NULL);
18955 symbolList.push_back(symbol);
18960static std::map<const SgStatement*, bool> visitedDeclMap;
18972 printf (
"\n\n********************************************************** \n");
18973 printf (
" Inside of getDependentDeclarations(stmt = %p = %s) \n",stmt,stmt->
class_name().c_str());
18974 printf (
"********************************************************** \n");
18976 visitedDeclMap[stmt]=
true;
18980 declarationList = t.declarationList;
18981 symbolList = t.symbolList;
18984 copy(t.declarationList.begin(),t.declarationList.end(), back_inserter(declarationList));
18985 copy(t.symbolList.begin(),t.symbolList.end(), back_inserter(symbolList));
18987 sort (declarationList.begin(), declarationList.end());
18988 vector<SgDeclarationStatement*>::iterator new_end = unique(declarationList.begin(), declarationList.end());
18989 declarationList.erase(new_end, declarationList.end());
18991 sort (symbolList.begin(), symbolList.end());
18992 vector<SgSymbol*>::iterator end2 = unique(symbolList.begin(), symbolList.end());
18993 symbolList.erase(end2, symbolList.end());
18997 for (vector<SgDeclarationStatement*>::const_iterator iter = t.declarationList.begin();
18998 iter !=t.declarationList.end(); iter++)
19001 SgType* base_type = NULL;
19006 if (isSgClassDeclaration(decl))
19008 base_type = isSgClassDeclaration(decl)->get_type();
19010 if (isSgTypedefDeclaration(decl))
19014 base_type = isSgTypedefDeclaration(decl)->get_base_type()->
stripType(SgType::STRIP_POINTER_TYPE|SgType::STRIP_ARRAY_TYPE|SgType::STRIP_REFERENCE_TYPE|SgType::STRIP_RVALUE_REFERENCE_TYPE|SgType::STRIP_MODIFIER_TYPE);
19022 if (isSgClassType(base_type))
19024 SgClassDeclaration* class_decl = isSgClassDeclaration(isSgClassType(base_type)->get_declaration()->get_definingDeclaration());
19025 if (class_decl!=NULL)
19027 body_stmt = class_decl->get_definition();
19031 if ((body_stmt!=NULL) &&(!visitedDeclMap[body_stmt]))
19043vector<SgDeclarationStatement*>
19046 vector<SgDeclarationStatement*> sortedNode;
19048 if (nodevec.size()==0 )
19051 if (nodevec.size() ==1)
19055 Rose_STL_Container<SgNode*> queryResult = NodeQuery::querySubTree(project,V_SgDeclarationStatement);
19056 for (Rose_STL_Container<SgNode*>::const_iterator iter = queryResult.begin();
19057 iter!= queryResult.end(); iter++)
19060 SgNode* cur_node = *iter;
19062 ROSE_ASSERT(cur_stmt!=NULL);
19074 ROSE_ASSERT (cur_stmt != func_decl);
19077 vector<SgDeclarationStatement*>::const_iterator i = find (nodevec.begin(), nodevec.end(), cur_stmt);
19078 if (i!=nodevec.end())
19082 vector<SgDeclarationStatement*>::const_iterator j = find (sortedNode.begin(), sortedNode.end(), *i);
19083 if (j == sortedNode.end())
19084 sortedNode.push_back(*i);
19088 if (nodevec.size() != sortedNode.size())
19090 cerr<<
"Fatal error in sortSgNodeListBasedOnAppearanceOrderInSource(): nodevec.size() != sortedNode.size()"<<endl;
19091 cerr<<
"nodevec() have "<< nodevec.size()<<
" elements. They are:"<<endl;
19092 for (vector<SgDeclarationStatement*>::const_iterator iter = nodevec.begin(); iter != nodevec.end(); iter++)
19094 cerr<<(*iter)<<
" "<<(*iter)->class_name() <<
" "<<(*iter)->unparseToString()<<endl;
19096 cerr<<
"sortedNode() have " << sortedNode.size() <<
" elements. They are:"<<endl;
19097 for (vector<SgDeclarationStatement*>::const_iterator iter = sortedNode.begin(); iter != sortedNode.end(); iter++)
19099 cerr<<(*iter)<<
" "<<(*iter)->class_name() <<
" "<<(*iter)->unparseToString()<<endl;
19102 ROSE_ASSERT(nodevec.size() == sortedNode.size());
19109std::vector<SgDeclarationStatement*>
19115 printf (
"\n\n********************************************************** \n");
19116 printf (
" Inside of getDependentDeclarations(stmt = %p = %s) \n",stmt,stmt->
class_name().c_str());
19117 printf (
"********************************************************** \n");
19122 return t.declarationList;
19125 visitedDeclMap.clear();
19126 vector<SgDeclarationStatement*> declarationList;
19127 vector<SgSymbol*> symbolList;
19131 printf (
"\n\n ********************************************************** \n");
19132 cout<<
"Found dependent decl: count="<<declarationList.size()<<endl;
19133 for ( vector<SgDeclarationStatement*>::const_iterator iter = declarationList.begin();
19134 iter != declarationList.end(); iter++)
19136 cout<<
"\t"<<(*iter)->class_name()<<
" at line "<<(*iter)->get_file_info()->get_line()<<endl;
19137 if ((*iter)->variantT()== V_SgFunctionDeclaration)
19138 cout<<
"func name is:"<<isSgFunctionDeclaration(*iter)->get_name().getString()<<endl;
19141 printf (
"\n ********************************************************** \n");
19144 return declarationList;
19153 bool returnValue =
false;
19156 printf (
"In SageInterface::isPrefixOperatorName(): functionName = %s (might have to check the return type to distinguish the deref operator from the multiply operator) \n",functionName.str());
19159 if (functionName.is_null() ==
false)
19162 if ( functionName ==
"operator++" || functionName ==
"operator--" || functionName ==
"operator&" ||
19163 functionName ==
"operator!" || functionName ==
"operator*" || functionName ==
"operator+" ||
19164 functionName ==
"operator-" || functionName ==
"operator+" || functionName ==
"operator~")
19166 returnValue =
true;
19170 return returnValue;
19182 bool returnValue =
false;
19189 size_t numberOfOperands = 0;
19191 if (memberFunctionRefExp != NULL)
19193 ROSE_ASSERT(functionRefExp == NULL);
19195 if (memberFunctionDeclaration != NULL)
19197 functionName = memberFunctionDeclaration->get_name();
19198 numberOfOperands = memberFunctionDeclaration->get_args().size();
19204 if (functionRefExp != NULL)
19207 if (functionDeclaration != NULL)
19209 functionName = functionDeclaration->get_name();
19210 numberOfOperands = functionDeclaration->get_args().size();
19216 printf (
"In SageInterface::isPrefixOperator(): unknown case of exp = %p = %s \n",exp,exp->
class_name().c_str());
19221 printf (
"In SageInterface::isPrefixOperator(): functionName = %s numberOfOperands = %" PRIuPTR
" (might have to check the return type to distinguish the deref operator from the multiply operator) \n",functionName.str(),numberOfOperands);
19226 if (memberFunctionRefExp != NULL)
19229 ROSE_ASSERT(functionRefExp == NULL);
19230 if (numberOfOperands == 0)
19233 returnValue =
true;
19238 returnValue =
false;
19244 ROSE_ASSERT(functionRefExp != NULL);
19245 ROSE_ASSERT(memberFunctionRefExp == NULL);
19246 if (numberOfOperands == 1)
19249 returnValue =
true;
19254 ROSE_ASSERT(numberOfOperands == 2);
19255 returnValue =
false;
19261 printf (
"Leaving SageInterface::isPrefixOperator(): returnValue = %s \n",returnValue ?
"true" :
"false");
19264 return returnValue;
19280 bool returnValue =
false;
19282 if (memberFunctionRefExp == NULL)
19286 if (memberFunctionDeclaration != NULL)
19288 SgName functionName = memberFunctionDeclaration->get_name();
19289 if ( (functionName ==
"operator[]") && (isSgType(memberFunctionDeclaration->get_type()) != NULL) )
19291 returnValue =
true;
19295 if ( (functionName ==
"operator()") && (isSgType(memberFunctionDeclaration->get_type()) != NULL) )
19297 returnValue =
true;
19301 returnValue =
false;
19306 return returnValue;
19317 ROSE_ASSERT(scope != NULL);
19320 printf (
"In SageInterface::lastStatementOfScopeWithTokenInfo(): scope = %p = %s \n",scope,scope->
class_name().c_str());
19323 SgIfStmt* ifStatement = isSgIfStmt(scope);
19324 if (ifStatement != NULL)
19327 if (lastStatement == NULL || (tokenStreamSequenceMap.find(lastStatement) == tokenStreamSequenceMap.end() || tokenStreamSequenceMap[lastStatement] == NULL))
19330 if (lastStatement == NULL || (tokenStreamSequenceMap.find(lastStatement) == tokenStreamSequenceMap.end() || tokenStreamSequenceMap[lastStatement] == NULL))
19332 lastStatement = NULL;
19336 printf (
"Note: SgIfStmt scope in SageInterface::lastStatementOfScopeWithTokenInfo(): returning lastStatement = %p \n",lastStatement);
19337 if (lastStatement != NULL)
19339 printf (
" --- lastStatement = %p = %s \n",lastStatement,lastStatement->
class_name().c_str());
19342 return lastStatement;
19346 if (statementList.rbegin() != statementList.rend())
19349 SgStatementPtrList::reverse_iterator i = statementList.rbegin();
19351 while (i != statementList.rend() && (tokenStreamSequenceMap.find(*i) == tokenStreamSequenceMap.end() || tokenStreamSequenceMap[*i] == NULL) )
19356 if (i == statementList.rend())
19358 lastStatement = NULL;
19362 lastStatement = *i;
19366 return lastStatement;
19380 void visit (
SgNode* node)
19390 printf (
"Found declaration = %p = %s name = %s \n",decl,decl->
class_name().c_str(),
get_name(decl).c_str());
19391 if (decl != definingDeclaration && decl != firstNondefiningDeclaration)
19393 otherDeclaration = decl;
19396 if (definingDeclaration != NULL)
19398 definingDeclaration->get_declarationModifier().get_accessModifier().display(
"definingDeclaration: accessModifier");
19401 if (firstNondefiningDeclaration != NULL)
19403 firstNondefiningDeclaration->get_declarationModifier().get_accessModifier().display(
"firstNondefiningDeclaration: accessModifier");
19406 if (otherDeclaration != NULL)
19408 otherDeclaration->get_declarationModifier().get_accessModifier().display(
"otherDeclaration: accessModifier");
19418 DeclarationTraversal traversal;
19419 traversal.traverse(astNode, preorder);
19431 void visit (
SgNode* node)
19437 if (functionDefinition != NULL)
19440 ROSE_ASSERT(functionDeclaration != NULL);
19442 string functionName = functionDeclaration->get_name();
19444 printf (
"functionName = %s \n",functionName.c_str());
19446 if (functionName ==
"main")
19450 ROSE_ASSERT(functionBody != NULL);
19452 ROSE_ASSERT(symbolTable != NULL);
19455 symbolTable->
print();
19460 if (namespaceDefinition != NULL)
19463 ROSE_ASSERT(namespaceDeclaration != NULL);
19465 string namespaceName = namespaceDeclaration->
get_name();
19467 printf (
"namespaceName = %s \n",namespaceName.c_str());
19469 if (namespaceName ==
"B")
19472 ROSE_ASSERT(symbolTable != NULL);
19475 symbolTable->
print();
19483 ScopeTraversal traversal;
19484 traversal.traverse(astNode, preorder);
19492 if (fileInfo != NULL)
19498 if (locatedNode != NULL)
19507 printf (
"In markNodeToBeUnparsed(): physical_file_id = %d \n",physical_file_id);
19510 locatedNode->
get_file_info()->set_physical_file_id(physical_file_id);
19512 printf (
"Note: calling node markTransformationsForOutput(): node = %p = %s \n",node,node->
class_name().c_str());
19516 markTransformationsForOutput(node);
19521 printf (
"Note: node is not a SgLocatedNode: node = %p = %s \n",node,node->
class_name().c_str());
19528 printf (
"Note: no Sg_File_Info was found: node = %p = %s \n",node,node->
class_name().c_str());
19533 if (locatedNode != NULL)
19542 printf (
"In SageInterface::markNodeToBeUnparsed(): locatedNode = %p = %s calling set_physical_file_id(%d) \n",locatedNode,locatedNode->
class_name().c_str(),physical_file_id);
19544 locatedNode->
get_file_info()->set_physical_file_id(physical_file_id);
19549 printf (
"Note: no Sg_File_Info was found: node = %p = %s \n",node,node->
class_name().c_str());
19582 class InheritedAttribute
19585 int physical_file_id;
19586 bool isCastSubtree;
19587 InheritedAttribute(
int file_id): physical_file_id(file_id), isCastSubtree(
false) {}
19588 InheritedAttribute(
const InheritedAttribute & X)
19590 isCastSubtree = X.isCastSubtree;
19591 physical_file_id = X.physical_file_id;
19602 InheritedAttribute evaluateInheritedAttribute (
SgNode* node, InheritedAttribute inheritedAttribute)
19604 InheritedAttribute returnAttribute(inheritedAttribute);
19606 SgCastExp* castExpression = isSgCastExp(node);
19607 if (castExpression != NULL)
19609 returnAttribute.isCastSubtree =
true;
19612 if (returnAttribute.isCastSubtree ==
true)
19616 printf (
"In markSubtreeToBeUnparsedTreeTraversal(): subtree of a SgCastExp: node = %p = %s physical_file_id = %d \n",
19617 node,node->
class_name().c_str(),inheritedAttribute.physical_file_id);
19623 printf (
"In markSubtreeToBeUnparsedTreeTraversal(): Calling markNodeToBeUnparsed(): node = %p = %s physical_file_id = %d \n",
19624 node,node->
class_name().c_str(),inheritedAttribute.physical_file_id);
19630 return returnAttribute;
19634 InheritedAttribute inheritedAttribute(physical_file_id);
19637 SubtreeTraversal traversal;
19640 printf (
"\nIn markSubtreeToBeUnparsedTreeTraversal(): calling traverse \n");
19643 traversal.traverse(root, inheritedAttribute);
19645 printf (
"This function does not compile with GNU 4.9 or older compilers (part of ROSE used only with more modern compilers) \n");
19654vector<SgDeclarationStatement*>
19655generateCopiesOfDependentDeclarations (
const vector<SgDeclarationStatement*>& dependentDeclarations,
SgScopeStatement* targetScope)
19666 printf (
"\n\n********************************************************** \n");
19667 printf (
" Inside of generateCopiesOfDependentDeclarations(stmt = %p = %s) \n",stmt,stmt->
class_name().c_str());
19668 printf (
"********************************************************** \n");
19671 vector<SgDeclarationStatement*> copiesOfDependentDeclarations;
19676 printf (
"Output the dependentDeclarations: dependentDeclarations.size() = %" PRIuPTR
" \n",dependentDeclarations.size());
19677 outputDeclarationList(dependentDeclarations);
19680 printf (
"************************************************ \n");
19681 printf (
"*** Make all copies of dependentDeclarations *** \n");
19682 printf (
"************************************************ \n");
19686 ROSE_ASSERT(targetScope != NULL);
19689 ROSE_ASSERT(isSgGlobal(targetScope) != NULL);
19691 for (vector<SgDeclarationStatement*>::const_iterator i = dependentDeclarations.begin(); i != dependentDeclarations.end(); i++)
19694 printf (
"Copying declaration = %p = %s = %s \n",*i,(*i)->class_name().c_str(),
SageInterface::get_name(*i).c_str());
19698 SgNode* copy_node = NULL;
19703 if (functionDeclaration != NULL)
19712 printf (
"WARNING: In SageInterface -- generateCopiesOfDependentDeclarations(): I think this is the wrong lookup symbol function that is being used here! \n");
19719 printf (
"In generateCopiesOfDependentDeclarations(): Copy mechanism appied to SgFunctionDeclaration functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->
get_firstNondefiningDeclaration());
19721 printf (
"functionDeclaration = %p \n",functionDeclaration);
19722 printf (
"functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->
get_definingDeclaration());
19724 printf (
"functionDeclaration->get_scope() = %p \n",functionDeclaration->
get_scope());
19725 printf (
"targetScope = %p \n",targetScope);
19728 assert(copy_functionDeclaration != NULL);
19730 copy_functionDeclaration->
set_parent(targetScope);
19740 assert(copy_functionDeclaration->
get_scope() != NULL);
19741 assert(copy_functionDeclaration->
get_scope() == targetScope);
19742 assert(copy_functionDeclaration->
get_scope()->lookup_function_symbol(copy_functionDeclaration->get_name(),
19743 copy_functionDeclaration->get_type()) != NULL);
19744 assert(copy_functionDeclaration->
get_scope()->lookup_function_symbol(copy_functionDeclaration->get_name(),
19747 copy_node = copy_functionDeclaration;
19749 printf (
"In generateCopiesOfDependentDeclarations(): DONE: Copy mechanism appied to SgFunctionDeclaration \n");
19763 cout<<
"Copying a defining typedef declaration:"<<tdecl->
unparseToString()<<endl;
19765 cout<<
"Copying a non-defining typedef declaration:"<<tdecl->
unparseToString()<<endl;
19769 tdecl_copy->set_typedefBaseTypeContainsDefiningDeclaration (
false);
19772 copy_node = (*i)->copy(collectDependentDeclarationsCopyType);
19776 ROSE_ASSERT(copy_declaration != NULL);
19780 copy_declaration->
set_scope(targetScope);
19792 ROSE_ASSERT(copy_node != NULL);
19801 ROSE_ASSERT(copy_definingDeclaration != NULL);
19803 ROSE_ASSERT( *i != NULL );
19804 ROSE_ASSERT(copy_definingDeclaration != NULL);
19807 if (copy_definingDeclaration->
get_parent() == NULL)
19809 copy_definingDeclaration->
set_parent(targetScope);
19811 ROSE_ASSERT(copy_definingDeclaration->
get_parent() != NULL);
19814 printf (
"DONE: Copying declaration: original scope = %p copied to scope = %p \n",(*i)->get_scope(),copy_definingDeclaration->
get_scope());
19824 ROSE_ASSERT(copy_definingDeclaration->
get_parent() == NULL);
19831 printf (
"copy_definingDeclaration = %p \n",copy_definingDeclaration);
19832 printf (
"copy_definingDeclaration->get_firstNondefiningDeclaration() == NULL \n");
19833 printf (
"copy_definingDeclaration->get_definingDeclaration() = %p \n",copy_definingDeclaration->
get_definingDeclaration());
19838 if ((*i)->get_firstNondefiningDeclaration() != NULL)
19846 copiesOfDependentDeclarations.push_back(copy_definingDeclaration);
19850 printf (
"****************************************************** \n");
19851 printf (
"*** DONE: Make all copies of dependentDeclarations *** \n");
19852 printf (
"****************************************************** \n");
19853 printf (
"copiesOfDependentDeclarations.size() = %" PRIuPTR
" \n",copiesOfDependentDeclarations.size());
19859 ROSE_ASSERT(copiesOfDependentDeclarations.size() <= dependentDeclarations.size());
19861 return copiesOfDependentDeclarations;
19866declarationContainsDependentDeclarations(
SgDeclarationStatement* decl, vector<SgDeclarationStatement*> & dependentDeclarationList )
19869 bool returnValue =
false;
19872 printf (
"\n\n********************************************************** \n");
19873 printf (
" Inside of declarationContainsDependentDeclarations(decl = %p = %s) \n",decl,decl->
class_name().c_str());
19874 printf (
"********************************************************** \n");
19882 for (
size_t i = 0; i < locallyDependentDeclarationList.size(); i++)
19888 vector<SgDeclarationStatement*>::iterator j = find(dependentDeclarationList.begin(),dependentDeclarationList.end(),d);
19889 if (j != dependentDeclarationList.end())
19894 printf (
"Found a dependent declaration buried in the class definition: locallyDependentDeclarationList[%" PRIuPTR
"] = %p = %s = %s \n",i,d,d->
class_name().c_str(),
SageInterface::get_name(d).c_str());
19896 returnValue =
true;
19901 printf (
"**************************************************************************** \n");
19902 printf (
" LEAVING: Inside of declarationContainsDependentDeclarations(decl = %p = %s) returnValue = %s \n",decl,decl->
class_name().c_str(),returnValue ?
"true" :
"false");
19903 printf (
"**************************************************************************** \n");
19906 return returnValue;
19911 ROSE_ASSERT (new_exp != NULL);
19912 ROSE_ASSERT (anchor_exp != NULL);
19913 ROSE_ASSERT (new_exp != anchor_exp);
19916 ROSE_ASSERT (parent != NULL);
19920 ROSE_ASSERT (result != NULL);
19932 ROSE_ASSERT (new_exp != NULL);
19933 ROSE_ASSERT (anchor_exp != NULL);
19934 ROSE_ASSERT (new_exp != anchor_exp);
19937 ROSE_ASSERT (parent != NULL);
19941 ROSE_ASSERT (t != NULL);
19943 ROSE_ASSERT (enclosing_stmt != NULL);
19950 ROSE_ASSERT (temp_sym != NULL);
19952 *temp_decl = t_decl;
19957 * temp_ref = first_ref;
19970 string fileName =
"separate-outlined-file";
19990 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): decl = %p \n",decl);
19991 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): decl->get_parent() = %p \n",decl->
get_parent());
19992 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): decl->get_scope() = %p \n",decl->
get_scope());
19993 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): original_statement = %p \n",original_statement);
19994 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): file (decl) = %s \n",TransformationSupport::getSourceFile(decl)->getFileName().c_str());
19995 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): decl->get_firstNondefiningDeclaration() = %p \n",decl->
get_firstNondefiningDeclaration());
19997 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): file (first non-defining) = %s \n",TransformationSupport::getSourceFile(decl->
get_firstNondefiningDeclaration())->
getFileName().c_str());
19998 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): decl->get_definingDeclaration() = %p \n",decl->
get_definingDeclaration());
20000 printf (
"***** In SageInterface::appendStatementWithDependentDeclaration(): file (first non-defining) = %s \n",TransformationSupport::getSourceFile(decl->
get_definingDeclaration())->
getFileName().c_str());
20003#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
20035 vector<SgDeclarationStatement*> dependentDeclarationList_inOriginalFile;
20042 vector<SgDeclarationStatement*> dependentDeclarationList = generateCopiesOfDependentDeclarations(dependentDeclarationList_inOriginalFile,scope);
20043 ROSE_ASSERT(dependentDeclarationList.size() <= dependentDeclarationList_inOriginalFile.size());
20053 std::map<SgNode*, SgNode*> replacementMap;
20058 SgCopyHelp::copiedNodeMapType copyNodeMap = collectDependentDeclarationsCopyType.get_copiedNodeMap();
20059 SgCopyHelp::copiedNodeMapType::iterator copyNodeMapItrator = copyNodeMap.begin();
20060 while (copyNodeMapItrator != copyNodeMap.end())
20065 SgNode* first =
const_cast<SgNode*
>(copyNodeMapItrator->first);
20066 SgNode* second = copyNodeMapItrator->second;
20068 printf (
"copyNodeMapItrator.first = %p = %s second = %p = %s \n",first,first->
class_name().c_str(),second,second->
class_name().c_str());
20071 if (isSgSymbol(first) != NULL)
20076 replacementMap.insert(pair<SgNode*,SgNode*>(first,second));
20079 copyNodeMapItrator++;
20083 printf (
"Exiting after test of new functionality \n");
20089 SgSourceFile* sourceFile = TransformationSupport::getSourceFile(original_statement);
20090 vector<PreprocessingInfo*> requiredDirectivesList = collectCppDirectives(sourceFile);
20093 ROSE_ASSERT(outlinedFunctionDeclaration != NULL);
20094 SgGlobal* originalFileGlobalScope = TransformationSupport::getGlobalScope(original_statement);
20095 ROSE_ASSERT(originalFileGlobalScope != NULL);
20097 printf (
"WARNING: In SageInterface::appendStatementWithDependentDeclaration(): I think this is the wrong lookup symbol function that is being used here! \n");
20101 SgFunctionSymbol* outlinedFunctionSymbolFromOriginalFile = isSgFunctionSymbol(originalFileGlobalScope->lookup_symbol(outlinedFunctionDeclaration->get_name(),NULL,NULL));
20107 printf (
"outlinedFunctionSymbolFromOriginalFile = %p outlinedFunctionSymbolFromOutlinedFile = %p \n",outlinedFunctionSymbolFromOriginalFile,outlinedFunctionSymbolFromOutlinedFile);
20109 printf (
"TransformationSupport::getSourceFile(decl)->getFileName() = %s \n",TransformationSupport::getSourceFile(decl)->getFileName().c_str());
20110 printf (
"TransformationSupport::getSourceFile(decl->get_firstNondefiningDeclaration())->getFileName() = %s \n",TransformationSupport::getSourceFile(decl->
get_firstNondefiningDeclaration())->
getFileName().c_str());
20111 printf (
"TransformationSupport::getSourceFile(original_statement)->getFileName() = %s \n",TransformationSupport::getSourceFile(original_statement)->getFileName().c_str());
20114 ROSE_ASSERT(outlinedFunctionSymbolFromOriginalFile != NULL);
20115 ROSE_ASSERT(outlinedFunctionSymbolFromOutlinedFile != NULL);
20118 ROSE_ASSERT(outlinedFunctionSymbolFromOriginalFile == outlinedFunctionSymbolFromOutlinedFile);
20121 replacementMap.insert(pair<SgNode*,SgNode*>(originalFileGlobalScope,scope));
20124 SgFunctionDeclaration* outlinedNondefiningFunctionDeclarationFromOriginalFile = isSgFunctionDeclaration(outlinedFunctionSymbolFromOriginalFile->get_declaration());
20126 ROSE_ASSERT(outlinedNondefiningFunctionDeclarationFromOriginalFile != NULL);
20127 ROSE_ASSERT(outlinedNondefiningFunctionDeclarationFromOutlinedFile != NULL);
20128 replacementMap.insert(pair<SgNode*,SgNode*>(outlinedNondefiningFunctionDeclarationFromOriginalFile,outlinedNondefiningFunctionDeclarationFromOutlinedFile));
20137 for (
size_t i = 0; i < dependentDeclarationList.size(); i++)
20143 printf (
"originalDeclaration = %p \n",originalDeclaration);
20145 d->
get_file_info()->display(
"SageInterface::appendStatementWithDependentDeclaration()");
20153 ROSE_ASSERT(decl->
get_scope() == scope);
20159 printf (
"Add the required symbol information to the symbol table: scope = %p = %s \n",scope,scope->
class_name().c_str());
20166 case V_SgClassDeclaration:
20168 if ( declarationContainsDependentDeclarations(d,dependentDeclarationList) ==
true )
20169 printf (
"Warning: This class contains dependent declarations (not implemented) \n");
20173 case V_SgMemberFunctionDeclaration:
20174 printf (
"Sorry, support for dependent member function declarations not implemented! \n");
20177 case V_SgTemplateInstantiationDecl:
20178 printf (
"Sorry, not implemented: case SgTemplateInstantiationDecl not handled as dependent declaration \n");
20179 d->
get_file_info()->display(
"Sorry, not implemented: case SgTemplateInstantiationDecl not handled as dependent declaration");
20181 printf (
"Case of SgTemplateInstantiationDecl not implemented. \n");
20184 case V_SgNamespaceDeclarationStatement:
20185 if (declarationContainsDependentDeclarations(d,dependentDeclarationList) ==
true )
20186 printf (
"Warning: This namespace contains dependent declarations (not supported) \n");
20189 case V_SgFunctionDeclaration:
20190 case V_SgTypedefDeclaration:
20191 case V_SgEnumDeclaration:
20195 printf (
"default case in SageInterface::appendStatementWithDependentDeclaration() (handling dependentDeclarationList) d = %p = %s \n",d,d->
class_name().c_str());
20201 vector<PreprocessingInfo*> cppDirectivesAlreadyAttachedToDependentDeclarations = collectCppDirectives(d);
20204 printf (
"directives BEFORE excluding those already present in dependent declarations \n");
20205 outputPreprocessingInfoList(requiredDirectivesList);
20207 printf (
"directives already attached to dependent declarations \n");
20208 outputPreprocessingInfoList(cppDirectivesAlreadyAttachedToDependentDeclarations);
20212 vector<PreprocessingInfo*>::iterator j = cppDirectivesAlreadyAttachedToDependentDeclarations.begin();
20213 while ( j != cppDirectivesAlreadyAttachedToDependentDeclarations.end() )
20216 vector<PreprocessingInfo*>::iterator entry = find(requiredDirectivesList.begin(),requiredDirectivesList.end(),*j);
20217 ROSE_ASSERT(entry != requiredDirectivesList.end());
20219 requiredDirectivesList.erase(entry);
20225 printf (
"directives AFTER excluding those already present in dependent declarations \n");
20226 outputPreprocessingInfoList(requiredDirectivesList);
20235 if (dependentDeclarationList.empty() ==
true)
20237 firstStatmentInFile = decl;
20241 firstStatmentInFile = dependentDeclarationList[0];
20244 ROSE_ASSERT(firstStatmentInFile != NULL);
20252 if (excludeHeaderFiles ==
false)
20255 vector<PreprocessingInfo*>::reverse_iterator j = requiredDirectivesList.rbegin();
20256 while ( j != requiredDirectivesList.rend() )
20275 SgSourceFile* outlinedFile = TransformationSupport::getSourceFile(scope);
20276 ROSE_ASSERT(outlinedFile != NULL);
20282 printf (
"\n\n************************************************************\n");
20283 printf (
"Calling Utils::edgePointerReplacement() \n");
20289 printf (
"Calling Utils::edgePointerReplacement(): DONE \n");
20290 printf (
"************************************************************\n\n");
20292 printf (
"\n\n After replacementMapTraversal(): intermediateDeleteSet: \n");
20293 displaySet(intermediateDeleteSet,
"After Utils::edgePointerReplacement");
20297 ROSE_ASSERT(dependentDeclarationList.size() <= dependentDeclarationList_inOriginalFile.size());
20305 printf (
"replacementMap.size() = %" PRIuPTR
" dependentDeclarationList.size() = %" PRIuPTR
" \n",replacementMap.size(),dependentDeclarationList.size());
20321 int SgVariableSymbol_count;
20322 int SgFunctionSymbol_count;
20323 int SgClassDeclaration_count;
20324 int SgTypedefSymbol_count;
20325 int SgMemFuncSymbol_count;
20326 int SgTemplateSymbol_count;
20327 int SgEnumFieldSymbol_count;
20345 SgVariableSymbol_count = 0;
20346 SgVariableSymbolPtr = symbol;
20347 SgFunctionSymbolPtr =NULL;
20348 SgClassSymbolPtr =NULL;
20349 SgTypedefPtr = NULL;
20350 SgMemFuncSymbolPtr =NULL;
20351 class_defining = NULL;
20353 typedef_defining =NULL;
20354 function_decl = NULL;
20355 SgTemplateSymbolPtr = NULL;
20356 template_defining = NULL;
20357 SgEnumFieldSymbolPtr = NULL;
20358 templateInstantiate_defining =NULL;
20362 SgFunctionSymbol_count = 0;
20363 SgFunctionSymbolPtr = symbol;
20366 SgMemFuncSymbol_count =0;
20368 SgVariableSymbolPtr = NULL;
20369 SgClassSymbolPtr =NULL;
20370 SgTypedefPtr = NULL;
20371 SgMemFuncSymbolPtr =NULL;
20372 class_defining = NULL;
20374 typedef_defining =NULL;
20375 function_decl = NULL;
20376 SgTemplateSymbolPtr = NULL;
20377 template_defining = NULL;
20378 SgEnumFieldSymbolPtr = NULL;
20379 templateInstantiate_defining =NULL;
20383 SgClassDeclaration_count = 0;
20384 SgClassSymbolPtr = symbol;
20385 SgFunctionSymbolPtr = NULL;
20386 SgVariableSymbolPtr = NULL;
20387 SgTypedefPtr = NULL;
20388 SgMemFuncSymbolPtr =NULL;
20389 class_defining = NULL;
20391 typedef_defining =NULL;
20392 function_decl = NULL;
20393 SgTemplateSymbolPtr = NULL;
20394 template_defining = NULL;
20395 SgEnumFieldSymbolPtr = NULL;
20396 templateInstantiate_defining =NULL;
20400 SgTypedefSymbol_count =0;
20401 SgTypedefPtr = symbol;
20402 SgClassSymbolPtr = NULL;
20403 SgFunctionSymbolPtr = NULL;
20404 SgVariableSymbolPtr = NULL;
20405 SgMemFuncSymbolPtr =NULL;
20406 class_defining = NULL;
20408 typedef_defining =NULL;
20409 function_decl = NULL;
20410 SgTemplateSymbolPtr = NULL;
20411 template_defining = NULL;
20412 SgEnumFieldSymbolPtr = NULL;
20413 templateInstantiate_defining =NULL;
20417 SgMemFuncSymbolPtr = symbol;
20418 SgMemFuncSymbol_count =0;
20419 SgTypedefPtr = NULL;
20420 SgClassSymbolPtr = NULL;
20421 SgFunctionSymbolPtr = NULL;
20422 SgVariableSymbolPtr = NULL;
20423 class_defining = NULL;
20425 typedef_defining =NULL;
20426 function_decl = NULL;
20427 SgTemplateSymbolPtr = NULL;
20428 template_defining = NULL;
20429 SgEnumFieldSymbolPtr = NULL;
20430 templateInstantiate_defining =NULL;
20434 SgTemplateSymbolPtr = symbol;
20435 SgTemplateSymbol_count =0;
20436 SgMemFuncSymbolPtr = NULL;
20437 SgTypedefPtr = NULL;
20438 SgClassSymbolPtr = NULL;
20439 SgFunctionSymbolPtr = NULL;
20440 SgVariableSymbolPtr = NULL;
20441 class_defining = NULL;
20443 typedef_defining =NULL;
20444 function_decl = NULL;
20445 template_defining = NULL;
20446 SgEnumFieldSymbolPtr = NULL;
20447 templateInstantiate_defining =NULL;
20451 SgEnumFieldSymbolPtr = symbol;
20452 SgEnumFieldSymbol_count =0;
20453 SgTemplateSymbolPtr = NULL;
20454 SgMemFuncSymbolPtr = NULL;
20455 SgTypedefPtr = NULL;
20456 SgClassSymbolPtr = NULL;
20457 SgFunctionSymbolPtr = NULL;
20458 SgVariableSymbolPtr = NULL;
20459 class_defining = NULL;
20461 typedef_defining =NULL;
20462 function_decl = NULL;
20463 template_defining = NULL;
20464 templateInstantiate_defining =NULL;
20469 class_defining = node;
20470 SgMemFuncSymbolPtr = NULL;
20471 SgTypedefPtr = NULL;
20472 SgClassSymbolPtr = NULL;
20473 SgFunctionSymbolPtr = NULL;
20474 SgVariableSymbolPtr = NULL;
20476 typedef_defining =NULL;
20477 function_decl = NULL;
20478 SgTemplateSymbolPtr = NULL;
20479 template_defining = NULL;
20480 SgEnumFieldSymbolPtr = NULL;
20481 templateInstantiate_defining =NULL;
20485 template_defining = node;
20486 class_defining = NULL;
20487 SgMemFuncSymbolPtr = NULL;
20488 SgTypedefPtr = NULL;
20489 SgClassSymbolPtr = NULL;
20490 SgFunctionSymbolPtr = NULL;
20491 SgVariableSymbolPtr = NULL;
20493 typedef_defining =NULL;
20494 function_decl = NULL;
20495 SgTemplateSymbolPtr = NULL;
20496 SgEnumFieldSymbolPtr = NULL;
20497 templateInstantiate_defining =NULL;
20500 function_decl =node;
20501 class_defining = NULL;
20502 SgMemFuncSymbolPtr = NULL;
20503 SgTypedefPtr = NULL;
20504 SgClassSymbolPtr = NULL;
20505 SgFunctionSymbolPtr = NULL;
20506 SgVariableSymbolPtr = NULL;
20508 typedef_defining =NULL;
20509 SgTemplateSymbolPtr = NULL;
20510 template_defining = NULL;
20511 SgEnumFieldSymbolPtr = NULL;
20512 templateInstantiate_defining =NULL;
20517 function_decl =NULL;
20518 class_defining = NULL;
20519 SgMemFuncSymbolPtr = NULL;
20520 SgTypedefPtr = NULL;
20521 SgClassSymbolPtr = NULL;
20522 SgFunctionSymbolPtr = NULL;
20523 SgVariableSymbolPtr = NULL;
20524 typedef_defining =NULL;
20525 SgTemplateSymbolPtr = NULL;
20526 template_defining = NULL;
20527 SgEnumFieldSymbolPtr = NULL;
20528 templateInstantiate_defining =NULL;
20532 typedef_defining = node;
20534 function_decl =NULL;
20535 class_defining = NULL;
20536 SgMemFuncSymbolPtr = NULL;
20537 SgTypedefPtr = NULL;
20538 SgClassSymbolPtr = NULL;
20539 SgFunctionSymbolPtr = NULL;
20540 SgVariableSymbolPtr = NULL;
20541 SgTemplateSymbolPtr = NULL;
20542 template_defining = NULL;
20543 SgEnumFieldSymbolPtr = NULL;
20544 templateInstantiate_defining =NULL;
20548 templateInstantiate_defining =node;
20549 typedef_defining = NULL;
20551 function_decl =NULL;
20552 class_defining = NULL;
20553 SgMemFuncSymbolPtr = NULL;
20554 SgTypedefPtr = NULL;
20555 SgClassSymbolPtr = NULL;
20556 SgFunctionSymbolPtr = NULL;
20557 SgVariableSymbolPtr = NULL;
20558 SgTemplateSymbolPtr = NULL;
20559 template_defining = NULL;
20560 SgEnumFieldSymbolPtr = NULL;
20567 if(SgVariableSymbolPtr !=NULL)
20569 if(node->get_scope()!=NULL)
20575 if (isSgVariableSymbol(s) == SgVariableSymbolPtr) SgVariableSymbol_count++;
20580 if(SgEnumFieldSymbolPtr !=NULL)
20582 if(node->get_scope()!=NULL)
20588 if (isSgEnumFieldSymbol(s) == SgEnumFieldSymbolPtr) SgEnumFieldSymbol_count++;
20596 if(SgVariableSymbolPtr !=NULL){
20598 if (s == SgVariableSymbolPtr) SgVariableSymbol_count++;
20602 int get_num_variable_pointers(){
return SgVariableSymbol_count;}
20604 int get_num_EnumField_pointers(){
return SgEnumFieldSymbol_count;}
20609 if(SgFunctionSymbolPtr !=NULL){
20615 if ((
SgFunctionSymbol *)s == SgFunctionSymbolPtr) SgFunctionSymbol_count++;
20620 if(function_decl!=NULL){
20624 if(node!=function_decl && (define==function_decl || first_nondefine==function_decl))
delete node;
20633 printf (
"In visit(SgFunctionRefExp* node): SgFunctionSymbolPtr = %p \n",SgFunctionSymbolPtr);
20635 if (SgFunctionSymbolPtr !=NULL)
20638 if (isSgFunctionSymbol(s) == SgFunctionSymbolPtr)
20640 SgFunctionSymbol_count++;
20642 printf (
"Increment SgFunctionSymbol_count = %d \n",SgFunctionSymbol_count);
20652 printf (
"In visit(SgMemberFunctionRefExp* node): SgFunctionSymbolPtr = %p \n",SgFunctionSymbolPtr);
20654 if (SgFunctionSymbolPtr !=NULL)
20657 if (isSgFunctionSymbol(s) == SgFunctionSymbolPtr)
20659 SgFunctionSymbol_count++;
20661 printf (
"Increment SgFunctionSymbol_count = %d \n",SgFunctionSymbol_count);
20669 if (SgFunctionSymbolPtr !=NULL){
20671 if (isSgFunctionSymbol(s) == SgFunctionSymbolPtr) SgFunctionSymbol_count++;
20675 int get_num_Function_pointers(){
return SgFunctionSymbol_count;}
20680 if(SgClassSymbolPtr !=NULL){
20685 if (isSgClassSymbol(s) == SgClassSymbolPtr) SgClassDeclaration_count++;
20690 if(class_defining!=NULL) {
20694 if((class_decl==class_defining||class_decl1==class_defining) && node!=class_defining )
20702 if(SgClassSymbolPtr !=NULL){
20707 if (isSgClassSymbol(s) == SgClassSymbolPtr) SgClassDeclaration_count++;
20712 if(templateInstantiate_defining!=NULL) {
20719 if((template_decl==templateInstantiate_defining||template_decl1==templateInstantiate_defining) && node!=templateInstantiate_defining){
20739 if (SgClassSymbolPtr !=NULL){
20740 SgSymbol* s = node->get_class_symbol();
20741 if (s == SgClassSymbolPtr) SgClassDeclaration_count++;
20747 if (SgClassSymbolPtr !=NULL){
20749 if (isSgClassSymbol(s) == SgClassSymbolPtr) SgClassDeclaration_count++;
20754 int get_num_Class_pointers(){
return SgClassDeclaration_count;}
20760 if(memFunc !=NULL){
20762 if(func == memFunc){
20771 if (SgMemFuncSymbolPtr !=NULL){
20776 if(symbol == SgMemFuncSymbolPtr){
20777 SgMemFuncSymbol_count++;
20786 if (SgMemFuncSymbolPtr !=NULL){
20791 if(symbol == SgMemFuncSymbolPtr){
20792 SgMemFuncSymbol_count++;
20801 int get_num_memFunc_pointers(){
return SgMemFuncSymbol_count;}
20807 if(SgTypedefPtr!=NULL){
20816 if(typedef_defining!=NULL){
20818 if(typedef_define == typedef_defining && node != typedef_defining ) {
20824 int get_num_Typedef_pointers(){
return SgTypedefSymbol_count;}
20830 if (SgTemplateSymbolPtr !=NULL){
20835 if(symbol == SgTemplateSymbolPtr){
20836 SgTemplateSymbol_count++;
20842 if(template_defining !=NULL) {
20849 if((template_decl==template_defining||template_decl1==template_defining) && node!=template_defining) {
20859 int get_num_Template_pointers(){
return SgTemplateSymbol_count;}
20869 void visit (
SgNode* node)
20876 printf (
"In DeleteAST::visit(): node = %p = %s \n",node,node->
class_name().c_str());
20881 if (isSgScopeStatement(node) !=NULL)
20885 printf (
"Deleting the scopes type table: scope->get_type_table() = %p \n",scope->get_type_table());
20887 delete scope->get_type_table();
20893 if (isSgTypeTable(node) !=NULL)
20897 printf (
"Deleting the type table (SgSymbolTable): typeTable->get_type_table() = %p \n",typeTable->get_type_table());
20899 delete typeTable->get_type_table();
20902 if(isSgInitializedName(node) !=NULL){
20906 if(isSgVariableDefinition(var_def) !=NULL){
20913 if(isSgInitializedName(node)->get_scope()!=NULL){
20917 if(isSgVariableSymbol(symbol) !=NULL){
20919 traverseMemoryPoolVisitorPattern(visitor);
20920 if(visitor.get_num_variable_pointers()==1){
20927 if(isSgEnumFieldSymbol(symbol) !=NULL){
20929 traverseMemoryPoolVisitorPattern(visitor);
20930 if(visitor.get_num_EnumField_pointers()==1){
20941 if(isSgVarRefExp(node) !=NULL){
20943 ClassicVisitor visitor(symbol);
20944 traverseMemoryPoolVisitorPattern(visitor);
20945 if(visitor.get_num_variable_pointers()==1){
20957 SgFunctionDeclaration* funcDecl = isSgFunctionDeclaration(node);
20958 if (funcDecl != NULL){
20959 if (isSgMemberFunctionDeclaration(node) == NULL) {
20960 if (funcDecl->get_scope() != NULL) {
20961 if (funcDecl->get_scope()->get_symbol_table() != NULL) {
20962 SgSymbol* symbol = ((SgFunctionDeclaration*)node)->get_symbol_from_symbol_table();
20963 ClassicVisitor visitor((SgFunctionSymbol *)symbol);
20964 traverseMemoryPoolVisitorPattern(visitor);
20965 if (visitor.get_num_Function_pointers()==1) { //only one reference to this FunctionSymbol => safe to delete
20966 ((SgFunctionDeclaration*)node)->get_scope()->get_symbol_table()->remove(symbol);
20968 //printf("A SgFunctionSymbol was deleted\n");
20970 ClassicVisitor visitor1((SgFunctionDeclaration *)node);
20971 traverseMemoryPoolVisitorPattern(visitor1);
20978 if(isSgFunctionRefExp(node) !=NULL)
20981 SgFunctionRefExp* functionRefExp = isSgFunctionRefExp(node);
20982 ROSE_ASSERT(functionRefExp->get_symbol_i() != NULL);
20983 printf ("In DeleteAST::visit(): functionRefExp->get_symbol_i() = %p = %s \n",functionRefExp->get_symbol_i(),functionRefExp->get_symbol_i()->class_name().c_str());
20985 SgFunctionSymbol *symbol = ((SgFunctionRefExp*)node)->get_symbol_i();
20986 ClassicVisitor visitor(symbol);
20987 traverseMemoryPoolVisitorPattern(visitor);
20988 if(visitor.get_num_Function_pointers()==1)
20990 // only one reference to this FunctionSymbol => safe to delete
20991 //((SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
20993 //printf("A SgFunctionSymbol was deleted\n");
20998 if(isSgUserDefinedBinaryOp(node) !=NULL){
20999 SgFunctionSymbol *symbol = ((SgUserDefinedBinaryOp*)node)->get_symbol();
21000 ClassicVisitor visitor(symbol);
21001 traverseMemoryPoolVisitorPattern(visitor);
21002 if(visitor.get_num_Function_pointers()==1){ //only one reference to this FunctionSymbol => safe to delete
21003 ((SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21005 //printf("A SgFunctionSymbol was deleted\n");
21013 if(isSgTypedefDeclaration(node) !=NULL){
21018 if(isSgTypedefSymbol(symbol)){
21020 traverseMemoryPoolVisitorPattern(visitor);
21021 if(visitor.get_num_Typedef_pointers()==1){
21032 traverseMemoryPoolVisitorPattern(visitor1);
21040 if(isSgNamespaceDeclarationStatement(node) !=NULL){
21041 if(((SgNamespaceDeclarationStatement*)node)->get_scope()!=NULL){
21042 if(((SgNamespaceDeclarationStatement*)node)->get_scope()->get_symbol_table()!=NULL)
21044 SgSymbol* symbol = ((SgNamespaceDeclarationStatement*)node)->get_symbol_from_symbol_table();
21045 if(isSgNamespaceSymbol(symbol)){
21046 ((SgNamespaceDeclarationStatement*)node)->get_scope()->get_symbol_table()->remove(symbol);
21048 //printf("A SgNamespaceSymbol was deleted\n");
21055 if(isSgNamespaceAliasDeclarationStatement(node) !=NULL){
21056 if(((SgNamespaceAliasDeclarationStatement*)node)->get_scope()!=NULL){
21057 if(((SgNamespaceAliasDeclarationStatement*)node)->get_scope()->get_symbol_table()!=NULL)
21059 SgSymbol* symbol = ((SgNamespaceAliasDeclarationStatement*)node)->get_symbol_from_symbol_table();
21060 if(isSgNamespaceSymbol(symbol)){
21061 ((SgNamespaceAliasDeclarationStatement*)node)->get_scope()->get_symbol_table()->remove(symbol);
21063 //printf("A SgNamespaceSymbol was deleted\n");
21074 if(isSgLabelStatement(node) !=NULL){
21079 if(isSgLabelSymbol(symbol)){
21088 if(isSgLabelRefExp(node) !=NULL){
21100 if(isSgEnumDeclaration(node) !=NULL){
21101 if(((SgEnumDeclaration*)node)->get_scope()!=NULL){
21102 if(((SgEnumDeclaration*)node)->get_scope()->get_symbol_table()!=NULL)
21104 SgSymbol* symbol = ((SgEnumDeclaration*)node)->get_symbol_from_symbol_table();
21105 if(isSgEnumSymbol(symbol) !=NULL){
21106 ((SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21108 //printf("A SgEnumSymbol was deleted\n");
21112 SgEnumType* type= ((SgEnumDeclaration*)node)->get_type();
21115 //printf("A SgEnumType was deleted\n");
21124 if(isSgClassDeclaration(node) !=NULL && isSgTemplateInstantiationDecl(node) ==NULL){
21129 if(isSgClassSymbol(symbol) !=NULL){
21131 traverseMemoryPoolVisitorPattern(visitor);
21132 if(visitor.get_num_Class_pointers()==1){
21142 traverseMemoryPoolVisitorPattern(visitor);
21151 if(isSgThisExp(node) !=NULL){
21154 traverseMemoryPoolVisitorPattern(visitor);
21155 if(visitor.get_num_Class_pointers()==1){
21156 ((
SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21163 if(isSgClassNameRefExp(node) !=NULL){
21165 if(isSgClassSymbol(symbol) !=NULL)
21168 traverseMemoryPoolVisitorPattern(visitor);
21169 if(visitor.get_num_Class_pointers()==1){
21170 ((
SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21182 if(isSgMemberFunctionDeclaration(node) !=NULL){
21183 if(((SgMemberFunctionDeclaration*)node)->get_scope()!=NULL){
21184 if(((SgMemberFunctionDeclaration*)node)->get_scope()->get_symbol_table()!=NULL)
21186 SgSymbol* symbol = ((SgMemberFunctionDeclaration*)node)->get_symbol_from_symbol_table();
21187 if(isSgMemberFunctionSymbol(symbol)){
21188 ClassicVisitor visitor((SgMemberFunctionSymbol*)symbol);
21189 traverseMemoryPoolVisitorPattern(visitor);
21190 if(visitor.get_num_memFunc_pointers()==1){
21191 ((SgMemberFunctionDeclaration*)node)->get_scope()->get_symbol_table()->remove(symbol);
21193 //printf("A SgMemberFunctionSymbol was deleted\n");
21198 ClassicVisitor visitor((SgMemberFunctionDeclaration*) node);
21199 traverseMemoryPoolVisitorPattern(visitor);
21202//Tan: I have no idea why the codes below cannot work. Perhaps it conflicts with some prior works
21204 if(isSgMemberFunctionRefExp(node) !=NULL){
21205 SgMemberFunctionSymbol* symbol = ((SgMemberFunctionRefExp*)node)->get_symbol_i();
21206 ClassicVisitor visitor(symbol);
21207 traverseMemoryPoolVisitorPattern(visitor);
21208 if(visitor.get_num_memFunc_pointers()==1){ //only one reference to this symbol => safe to delete
21209 ((SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21211 //printf("A SgClassSymbol was deleted\n");
21216 if(isSgFunctionType(node) !=NULL){
21217 SgSymbol* symbol = ((SgFunctionType*)node)->get_symbol_from_symbol_table();
21218 if(isSgFunctionTypeSymbol(symbol)){
21219 ((SgSymbol*)symbol)->get_scope()->get_symbol_table()->remove(symbol);
21221 //printf("A SgFunctionTypeSymbol was deleted\n");
21230 if(isSgInterfaceStatement(node) !=NULL){
21235 if(isSgInterfaceSymbol(symbol)){
21246 if(isSgModuleStatement(node) !=NULL){
21251 if(isSgModuleSymbol(symbol)){
21264 if(isSgTemplateInstantiationMemberFunctionDecl(node) !=NULL){
21269 if(isSgMemberFunctionSymbol(symbol)){
21271 traverseMemoryPoolVisitorPattern(visitor);
21272 if(visitor.get_num_memFunc_pointers()==1){
21281 traverseMemoryPoolVisitorPattern(visitor);
21284 if(isSgTemplateDeclaration(node) !=NULL){
21290 traverseMemoryPoolVisitorPattern(visitor);
21291 if(visitor.get_num_Template_pointers()==1){
21294 printf(
"A SgTemplateSymbol was deleted\n");
21300 traverseMemoryPoolVisitorPattern(visitor1);
21305 if(isSgInterfaceStatement(node) !=NULL){
21310 if(isSgInterfaceSymbol(symbol)){
21321 if(isSgModuleStatement(node) !=NULL){
21326 if(isSgModuleSymbol(symbol)){
21336 if(isSgTemplateInstantiationDecl(node) !=NULL){
21341 if(isSgClassSymbol(symbol)){
21343 traverseMemoryPoolVisitorPattern(visitor);
21344 if(visitor.get_num_Class_pointers()==1){
21363 printf(
"SgTemplateArg in normal traversal\n");
21365 printf(
"SgTemplateInstantiationDecl in normal traversal\n");
21368 traverseMemoryPoolVisitorPattern(visitor);
21378 printf (
"After delete node: node = %p = %s \n",node,node->
class_name().c_str());
21384 DeleteAST deleteTree;
21387 deleteTree.traverse(n,postorder);
21390 printf (
"Leaving SageInterface::deleteAST(): n = %p = %s \n",n,n->
class_name().c_str());
21417 virtual void visit(
SgNode* n)
21420 if (expression != NULL)
21422 Visitor().traverse(expression->get_originalExpressionTree(), postorder);
21429 Visitor().traverse(root, postorder);
21441 SgSymbol* symbol = s_table->find(iname);
21442 ASSERT_not_null(symbol);
21447 ASSERT_not_null(sourceBlock);
21448 ASSERT_not_null(targetBlock);
21463 SgSymbol* symbol = s_table->find(iname);
21464 ASSERT_not_null(symbol);
21471 ASSERT_not_null(symbol);
21482 ASSERT_require(stmt->
get_parent() == targetBlock);
21497 func->set_scope(targetBlock);
21500 SgFunctionDeclaration* nondef_decl= isSgFunctionDeclaration(func->get_firstNondefiningDeclaration());
21501 if (func != nondef_decl)
21503 ASSERT_not_null(nondef_decl);
21510 else if (
auto labelStmt = isSgLabelStatement(stmt))
21512 if (labelStmt->get_scope() == sourceBlock) {
21513 labelStmt->set_scope(targetBlock);
21518 else if (isSgJovialTableStatement(stmt) || isSgTypedefDeclaration(stmt) || isSgEnumDeclaration(stmt))
21526 mlog[Rose::Diagnostics::WARN] <<
"test failing stmt->get_scope() == targetBlock in SageInterface::moveStatementsBetweenBlocks(): class: "
21533 if (declaration !=
nullptr)
21540 case V_SgVariableDeclaration:
21545 for (SgInitializedNamePtrList::iterator ii = l.begin(); ii != l.end(); ii++)
21555 SgType* var_type = init_name->get_type();
21558 var_type = mod_type->get_base_type();
21565 if (isSgEnumType(var_type))
21567 SgEnumType* enum_type = isSgEnumType(var_type);
21582 enumerator->set_scope(targetBlock);
21586 else if (isSgJovialTableType(var_type))
21602 SgVariableSymbol* var_sym = isSgVariableSymbol(init_name -> search_for_symbol_from_symbol_table ()) ;
21603 ASSERT_not_null(var_sym);
21606 if (old_scope != sourceBlock)
21608 old_scope->remove_symbol (var_sym);
21609 sourceBlock ->
insert_symbol(init_name->get_name(), var_sym);
21612 init_name->set_scope(targetBlock);
21613 initname_vec.push_back(init_name);
21617 case V_SgFunctionDeclaration:
21620 ASSERT_not_null(funcDecl);
21627 if (old_scope != sourceBlock)
21629 old_scope->remove_symbol (func_sym);
21637 case V_SgProgramHeaderStatement:
21638 case V_SgProcedureHeaderStatement:
21639 case V_SgClassDeclaration:
21640 case V_SgEnumDeclaration:
21643 ASSERT_not_null(nondef_decl);
21657 if (
auto proc = isSgProcedureHeaderStatement(nondef_decl)) {
21658 for (
auto arg : proc->get_parameterList()->get_args()) {
21659 if (arg->get_scope() != proc->get_scope()) {
21663 arg->set_scope(proc->get_scope());
21675 name->set_scope(targetBlock);
21680 case V_SgJovialTableStatement:
21684 ROSE_ASSERT (table);
21693 case V_SgTypedefDeclaration:
21697 ASSERT_not_null(typedef_decl);
21702 case V_SgAttributeSpecificationStatement:
21703 case V_SgEmptyDeclaration:
21704 case V_SgFortranIncludeLine:
21705 case V_SgImplicitStatement:
21706 case V_SgJovialDefineDeclaration:
21707 case V_SgJovialDirectiveStatement:
21708 case V_SgJovialLabelDeclaration:
21709 case V_SgJovialOverlayDeclaration:
21710 case V_SgPragmaDeclaration:
21711 case V_SgAdaAttributeClause:
21715 printf (
"Moving this declaration = %p = %s = %s between blocks is not yet supported \n",declaration,declaration->
class_name().c_str(),
SageInterface::get_name(declaration).c_str());
21724template <
class T1,
class T2>
21725void moveDeclarationsBetweenScopes( T1* sourceBlock, T2* targetBlock)
21729 ROSE_ASSERT (sourceBlock && targetBlock);
21730 ROSE_ASSERT (sourceBlock->containsOnlyDeclarations() && targetBlock->containsOnlyDeclarations());
21731 if ((
void*)sourceBlock == (
void*)targetBlock)
21733 cerr<<
"warning: SageInterface::moveStatementsBetweenScopes() is skipped, "<<endl;
21734 cerr<<
" since program is trying to move statements from and to the identical scoped block. "<<endl;
21738 SgDeclarationStatementPtrList& srcStmts = sourceBlock->get_declarations ();
21739 std::vector <SgInitializedName*> initname_vec;
21741 for (
auto stmt : srcStmts)
21743 moveOneStatement(sourceBlock, targetBlock, stmt, initname_vec);
21748 ROSE_ASSERT(srcStmts.empty() ==
true);
21749 ROSE_ASSERT(sourceBlock->get_declarations().empty() ==
true);
21752 moveSymbolTableBetweenBlocks(sourceBlock, targetBlock, initname_vec);
21765template <
class T1,
class T2>
21766void moveStatementsBetweenScopes( T1* sourceBlock, T2* targetBlock)
21769 ROSE_ASSERT (sourceBlock && targetBlock);
21770 if ((
void*)sourceBlock == (
void*)targetBlock)
21772 cerr<<
"warning: SageInterface::moveStatementsBetweenScopes() is skipped, "<<endl;
21773 cerr<<
" since program is trying to move statements from and to the identical scoped block. "<<endl;
21777 SgStatementPtrList & srcStmts = sourceBlock->get_statements();
21778 std::vector <SgInitializedName*> initname_vec;
21782 moveOneStatement(sourceBlock, targetBlock, stmt, initname_vec);
21787 ROSE_ASSERT(srcStmts.empty() ==
true);
21788 ROSE_ASSERT(sourceBlock->get_statements().empty() ==
true);
21791 moveSymbolTableBetweenBlocks(sourceBlock, targetBlock, initname_vec);
21805 ASSERT_not_null(decl);
21809 ASSERT_require(local_def && global_def && (local_def!=global_def));
21811 for (
auto symbol : local_def->get_symbol_table()->get_symbols())
21813 SgSymbol *orig_sym = isSgSymbol(symbol);
21814 ASSERT_not_null(orig_sym);
21823 moveDeclarationsBetweenScopes(sourceBlock, targetBlock);
21825 createAliasSymbols(isSgNamespaceDeclarationStatement(targetBlock->
get_parent()));
21830 moveStatementsBetweenScopes(sourceBlock, targetBlock);
21832 createAliasSymbols(isSgNamespaceDeclarationStatement(targetBlock->
get_parent()));
21837 moveDeclarationsBetweenScopes(sourceBlock, targetBlock);
21843 moveStatementsBetweenScopes (sourceBlock, targetBlock);
21851 ROSE_ASSERT (func != NULL);
21853 ROSE_ASSERT (p != NULL);
21855 if (le && le->get_lambda_function() == func)
21868 #pragma message ("WARNING: MSVC does not handle isLambdaCapturedVariable() properly.")
21870 ROSE_ASSERT (varRef!= NULL);
21874 SgThisExp* te = isSgThisExp(p->get_lhs_operand_i());
21878 ROSE_ASSERT (csym!= NULL);
21881 ROSE_ASSERT (xdecl != NULL);
21885 if (le->get_lambda_closure_class() == xdecl )
21901 ROSE_ASSERT(current != NULL);
21903 if (isSgInitializedName(current))
21905 name = isSgInitializedName(current);
21907 else if (isSgPntrArrRefExp(current) != NULL)
21911 ROSE_ASSERT(exp != NULL);
21913 ROSE_ASSERT(suc ==
true);
21917 else if (isSgVarRefExp(current) != NULL)
21923 if (isSgDotExp(parent))
21925 if (isSgDotExp(parent)->get_rhs_operand() == current)
21931 if (isSgArrowExp(parent)->get_rhs_operand() == current)
21935 name = isSgVarRefExp(current)->get_symbol()->get_declaration();
21937 else if (isSgFunctionRefExp(current) != NULL ||
21938 isSgTemplateFunctionRefExp(current) != NULL ||
21939 isSgMemberFunctionRefExp(current) != NULL ||
21940 isSgTemplateMemberFunctionRefExp(current) != NULL)
21945 else if (isSgNonrealRefExp(current) != NULL)
21950 else if (isSgDotExp(current))
21957 ROSE_ASSERT(child);
21961 else if (isSgArrowExp(current))
21982 ROSE_ASSERT(child);
21987 else if (isSgThisExp(current))
21992 else if (isSgPointerDerefExp(current))
21996 else if(isSgUnaryOp(current)) {
21999 else if (isSgCastExp(current))
22005 else if (isSgAddOp(current))
22010 else if (isSgSubtractOp(current))
22021 else if (isSgIntVal(current))
22031 if (!isSgConstructorInitializer(current))
22033 mlog[Sawyer::Message::Common::WARN] <<
22034 "convertRefToInitializedName: " <<
22037 cerr<<
"In SageInterface::convertRefToInitializedName(): unhandled reference type:"<<current->
class_name()<<endl;
22048#ifdef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
22049 printf (
"AbstractHandle support is disabled for ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT \n");
22055 size_t pos = input_string.find(
"SourceFile<");
22056 ROSE_ASSERT (pos != string::npos);
22057 string trimed_string = input_string.substr(pos);
22061 if (handle->getNode()!=NULL)
22066#pragma message ("WARNING: covariant return type for get_node() not supported in MSVC.")
22067 printf (
"ERROR: covariant return type for get_node() not supported in MSVC. \n");
22090 ROSE_ASSERT(node != NULL);
22093 cout<<
"///////////// begin of SageInterface::dumpInfo() ///////////////"<<endl;
22094 cout<<
"--------------base info. for SgNode---------------"<<endl;
22100 cout<<
"--------------source location info. for SgNode---------------"<<endl;
22108 cout<<
"--------------preprocessing info. for SgNode---------------"<<endl;
22109 AttachedPreprocessingInfoType::iterator i;
22110 cout<<
"Total attached preprocessingInfo count="<<comments->size()<<endl;
22111 for (i = comments->begin (); i != comments->end (); i++)
22114 pinfo->display(
"");
22117 cout<<
"--------------name info. for SgNode---------------"<<endl;
22121 cout<<
"\tqualified name="<<decl->get_qualified_name().getString()<<endl;
22124 cout<<
"\treferenced variable name= "<<varRef->get_symbol()->
get_name().getString()<<endl;
22131 cout<<
"///////////// end of SageInterface::dumpInfo() ///////////////"<<endl;
22142 bool retVal =
true;
22144 ROSE_ASSERT(stmt !=NULL);
22146#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
22153 if (funcDecl != NULL)
22156 if (funcDecl == NULL)
22158 cerr<<
"In collectReadWriteRefs(): cannot proceed without a function body!"<<endl;
22161 stmt = funcDecl->get_definition()->
get_body();
22169 ROSE_ASSERT(funcDef != NULL);
22171 ROSE_ASSERT(funcBody!= NULL);
22174 AstInterfaceImpl faImpl(funcBody);
22175 AstInterface fa(&faImpl);
22176 ArrayAnnotation* annot = ArrayAnnotation::get_inst();
22177 if( useCachedDefUse ){
22178 ArrayInterface* array_interface = ArrayInterface::get_inst(*annot, fa, funcDef, AstNodePtrImpl(funcDef));
22179 LoopTransformInterface::set_arrayInfo(array_interface);
22181 ArrayInterface array_interface(*annot);
22184 array_interface.observe(fa);
22185 LoopTransformInterface::set_arrayInfo(&array_interface);
22187 LoopTransformInterface::set_astInterface(fa);
22189 LoopTransformInterface::set_sideEffectInfo(annot);
22192 DoublyLinkedListWrap<AstNodePtr> rRef1, wRef1;
22193 CollectDoublyLinkedList<AstNodePtr> crRef1(rRef1),cwRef1(wRef1);
22194 AstNodePtr s1 = AstNodePtrImpl(stmt);
22197 if (!AnalyzeStmtRefs(fa, s1, cwRef1, crRef1))
22202 mlog[Sawyer::Message::Common::DEBUG] <<
"Function: " << funcDef->get_declaration()->get_qualified_name() <<
" calls at least one function that has not been annotated." << endl;
22207 for (DoublyLinkedEntryWrap<AstNodePtr>* p = rRef1.First(); p != 0; )
22209 DoublyLinkedEntryWrap<AstNodePtr>* p1 = p;
22211 AstNodePtr cur = p1->GetEntry();
22212 SgNode* sgRef = AstNodePtrImpl(cur).get_ptr();
22213 ROSE_ASSERT(sgRef != NULL);
22214 readRefs.push_back(sgRef);
22219 for (DoublyLinkedEntryWrap<AstNodePtr>* p = wRef1.First(); p != 0; )
22221 DoublyLinkedEntryWrap<AstNodePtr>* p1 = p;
22223 AstNodePtr cur = p1->GetEntry();
22224 SgNode* sgRef = AstNodePtrImpl(cur).get_ptr();
22225 ROSE_ASSERT(sgRef != NULL);
22226 writeRefs.push_back(sgRef);
22239static bool skipSomeRefs(
SgNode* n)
22242 return (isSgThisExp(n)||isSgArrowExp(n)||isSgDotExp(n));
22248 ROSE_ASSERT(stmt != NULL);
22249 vector <SgNode* > readRefs, writeRefs;
22253 vector<SgNode*>::iterator iter = readRefs.begin();
22254 for (; iter!=readRefs.end();iter++)
22256 SgNode* current = *iter;
22259 ROSE_ASSERT (current != NULL);
22262 if (!name)
continue;
22265 readVars.insert(name);
22268 vector<SgNode*>::iterator iterw = writeRefs.begin();
22269 for (; iterw!=writeRefs.end();iterw++)
22271 SgNode* current = *iterw;
22272 ROSE_ASSERT (current != NULL);
22274 if (!name)
continue;
22278 writeVars.insert(name);
22286 ROSE_ASSERT(stmt != NULL);
22287 set<SgInitializedName*> readVars, writeVars;
22292 set_difference(readVars.begin(), readVars.end(),
22293 writeVars.begin(), writeVars.end(),
22294 std::inserter(readOnlyVars, readOnlyVars.begin()));
22304 readOnlyVars.insert (v_ref->get_symbol()->get_declaration());
22314 set<SgInitializedName*> temp;
22317 for (set<SgInitializedName*>::const_iterator iter = temp.begin();
22318 iter!=temp.end(); iter++)
22320 SgSymbol* symbol = (*iter)->get_symbol_from_symbol_table () ;
22321 ROSE_ASSERT(symbol != NULL );
22322 ROSE_ASSERT(isSgVariableSymbol(symbol));
22323 readOnlySymbols.insert(isSgVariableSymbol(symbol));
22331 bool result =
false;
22332 ROSE_ASSERT(ref != NULL);
22344 ROSE_ASSERT(grandparent);
22345 if (isSgFunctionCallExp(grandparent))
22351 size_t param_index = 0;
22353 SgExpressionPtrList expList = isSgExprListExp(ref->
get_parent())->get_expressions();
22354 Rose_STL_Container<SgExpression*>::const_iterator iter= expList.begin();
22355 for (; iter!=expList.end(); iter++)
22363 SgExpression* func_exp = isSgFunctionCallExp(grandparent)->get_function();
22364 ROSE_ASSERT (func_exp);
22369 SgInitializedNamePtrList nameList = funcDecl->get_args();
22374 if (param_index >= nameList.size() ||isSgTypeEllipse(nameList[param_index]->get_type()) )
22376 if (isSgReferenceType(ref))
22380 if (isSgReferenceType(nameList[param_index]->get_type()))
22385 else if (isSgDotExp (func_exp) || isSgArrowExp(func_exp))
22388 ROSE_ASSERT (binOp);
22390 ROSE_ASSERT (mfuncRef);
22392 ROSE_ASSERT (mfuncDecl);
22393 SgInitializedNamePtrList nameList = mfuncDecl->get_args();
22395 if (isSgReferenceType(nameList[param_index]->get_type()))
22410 Rose_STL_Container <SgNode*> var_refs = NodeQuery::querySubTree (
const_cast<SgStatement *
> (s), V_SgVarRefExp);
22412 Rose_STL_Container<SgNode*>::iterator iter = var_refs.begin();
22413 for (; iter!=var_refs.end(); iter++)
22416 ROSE_ASSERT(ref != NULL);
22423 varSetB.insert(ref);
22429 ROSE_ASSERT(grandparent);
22430 if (isSgFunctionCallExp(grandparent))
22433 int param_index =0;
22434 SgExpressionPtrList expList = isSgExprListExp(ref->
get_parent())->get_expressions();
22435 Rose_STL_Container<SgExpression*>::const_iterator iter= expList.begin();
22436 for (; iter!=expList.end(); iter++)
22444 SgFunctionRefExp * funcRef = isSgFunctionRefExp(isSgFunctionCallExp(grandparent)->get_function());
22446 SgInitializedNamePtrList nameList = funcDecl->get_args();
22448 if (isSgReferenceType(nameList[param_index]->get_type()))
22450 varSetB.insert(ref);
22456 varSetB.insert(ref);
22460#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
22465 static LivenessAnalysis* liv = NULL;
22469 static DFAnalysis * defuse = NULL;
22473 ROSE_ASSERT(project != NULL);
22474 defuse =
new DefUseAnalysis(project);
22477 ROSE_ASSERT(defuse != NULL);
22478 defuse->run(debug);
22481 defuse->dfaToDOT();
22484 liv =
new LivenessAnalysis(debug,(DefUseAnalysis*)defuse);
22485 ROSE_ASSERT(liv != NULL);
22487 std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
22488 NodeQuerySynthesizedAttributeType vars =
22489 NodeQuery::querySubTree(project, V_SgFunctionDefinition);
22490 NodeQuerySynthesizedAttributeType::const_iterator i;
22491 bool abortme=
false;
22493 for (i= vars.begin(); i!=vars.end();++i)
22496 ROSE_ASSERT(func != NULL);
22500 string funcName = func->get_declaration()->get_qualified_name().str();
22501 cout<<
" .. running liveness analysis for function: " << funcName << endl;
22503 FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
22505 liv->fixupStatementsINOUT(func);
22506 if (rem_source.getNode()!=NULL)
22507 dfaFunctions.push_back(rem_source);
22513 cout <<
"Writing out liveness analysis results into var.dot... " << endl;
22514 std::ofstream f2(
"var.dot");
22515 dfaToDot(f2,
string(
"var"), dfaFunctions, (DefUseAnalysis*)defuse, liv);
22519 cerr<<
"Error: Liveness analysis is ABORTING ." << endl;
22527#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
22531 ROSE_ASSERT(liv != NULL);
22532 ROSE_ASSERT(loop != NULL);
22534 std::vector<SgInitializedName*> liveIns0, liveOuts0;
22544 CFGNode cfgnode(forstmt,2);
22545 FilteredCFGNode<IsDFAFilter> filternode= FilteredCFGNode<IsDFAFilter> (cfgnode);
22549 ROSE_ASSERT(filternode.getNode()==forstmt);
22552 vector<FilteredCFGEdge < IsDFAFilter > > out_edges = filternode.outEdges();
22553 ROSE_ASSERT(out_edges.size()==2);
22554 vector<FilteredCFGEdge < IsDFAFilter > >::iterator iter= out_edges.begin();
22556 for (; iter!=out_edges.end();iter++)
22558 FilteredCFGEdge < IsDFAFilter > edge= *iter;
22562 if (edge.condition()==eckTrue)
22564 SgNode* firstnode= edge.target().getNode();
22565 liveIns0 = liv->getIn(firstnode);
22567 for (std::vector<SgInitializedName*>::iterator iter = liveIns0.begin();
22568 iter!=liveIns0.end(); iter++)
22571 liveIns.insert(*iter);
22576 else if (edge.condition()==eckFalse)
22578 SgNode* firstnode= edge.target().getNode();
22579 liveOuts0 = liv->getIn(firstnode);
22581 for (std::vector<SgInitializedName*>::iterator iter = liveOuts0.begin();
22582 iter!=liveOuts0.end(); iter++)
22586 liveOuts.insert(*iter);
22591 cerr<<
"Unexpected CFG out edge type for SgForStmt!"<<endl;
22600static bool isAssignReduction (
SgVarRefExp* ref_exp1,
SgVarRefExp* ref_exp2, OmpSupport::omp_construct_enum& optype)
22602 bool isReduction =
false;
22604 ROSE_ASSERT (ref_exp1!= NULL);
22605 ROSE_ASSERT (ref_exp2!= NULL);
22606 ROSE_ASSERT (ref_exp1-> get_symbol() == ref_exp2-> get_symbol());
22612 if (stmt != stmt2)
return false;
22619 if (exp_stmt && isSgAssignOp(exp_stmt->get_expression()))
22622 assign_lhs = isSgAssignOp(exp_stmt->get_expression())->
get_lhs_operand();
22623 assign_rhs = isSgAssignOp(exp_stmt->get_expression())->
get_rhs_operand();
22624 ROSE_ASSERT(assign_lhs && assign_rhs);
22632 SgBinaryOp * binop = isSgBinaryOp(assign_rhs);
22638 if( !((op_lhs==ref_exp1)||(op_lhs==ref_exp2))
22639 && !((op_rhs==ref_exp1)||(op_rhs==ref_exp2)))
22642 bool isOnLeft =
false;
22643 if ((op_lhs==ref_exp1)||
22644 (op_lhs==ref_exp2))
22650 optype = OmpSupport::e_reduction_plus;
22651 isReduction =
true;
22654 case V_SgMultiplyOp:
22656 optype = OmpSupport::e_reduction_mul;
22657 isReduction =
true;
22660 case V_SgSubtractOp:
22662 optype = OmpSupport::e_reduction_minus;
22665 isReduction =
true;
22671 optype = OmpSupport::e_reduction_bitand ;
22672 isReduction =
true;
22677 optype = OmpSupport::e_reduction_bitxor;
22678 isReduction =
true;
22683 optype = OmpSupport::e_reduction_bitor;
22684 isReduction =
true;
22689 optype = OmpSupport::e_reduction_logand;
22690 isReduction =
true;
22695 optype = OmpSupport::e_reduction_logor;
22696 isReduction =
true;
22705 return isReduction;
22714 bool matchStmt1 =
false;
22715 bool matchStmt2 =
false;
22722 ROSE_ASSERT (ref1 != NULL);
22723 ROSE_ASSERT (ref2 != NULL);
22724 ROSE_ASSERT (ref1-> get_symbol() == ref2-> get_symbol());
22732 if (stmt1 == stmt2)
return false;
22755 bool matchBody =
false;
22756 bool matchCondition=
false;
22757 if (
SgIfStmt * if_stmt = isSgIfStmt (if_cond_stmt->get_parent()) )
22759 if (
SgStatement* body = if_stmt->get_true_body())
22764 ROSE_ASSERT(stmt2 != NULL);
22765 if ( ((block->get_statements()).size() == 1) && stmt2->
get_scope() == block )
22776 if (
SgExprStatement* cond_exp_stmt = isSgExprStatement (if_stmt->get_conditional()) )
22778 SgExpression* cond_exp = cond_exp_stmt->get_expression();
22779 if (
SgBinaryOp * binop = isSgBinaryOp (cond_exp))
22784 if (isSgLessThanOp (binop))
22786 optype = OmpSupport::e_reduction_max;
22787 matchCondition=
true;
22789 else if (isSgGreaterThanOp(binop))
22791 optype = OmpSupport::e_reduction_min;
22792 matchCondition=
true;
22798 if (isSgLessThanOp (binop))
22800 optype = OmpSupport::e_reduction_min;
22801 matchCondition=
true;
22803 else if (isSgGreaterThanOp(binop))
22805 optype = OmpSupport::e_reduction_max;
22806 matchCondition=
true;
22813 matchStmt1 = matchBody && matchCondition;
22817 return (matchStmt2 && matchStmt1);
22824static bool isSingleAppearanceReduction(
SgVarRefExp* ref1, OmpSupport::omp_construct_enum& optype )
22826 bool isReduction =
false;
22828 ROSE_ASSERT (ref1 != NULL);
22834 if (isSgExprStatement(stmt))
22836 SgExpression* exp = isSgExprStatement(stmt)->get_expression();
22838 if (isSgPlusPlusOp(exp))
22841 optype = OmpSupport::e_reduction_plus;
22842 isReduction =
true;
22844 else if (isSgMinusMinusOp(exp))
22846 optype = OmpSupport::e_reduction_minus;
22847 isReduction =
true;
22858 case V_SgPlusAssignOp:
22860 optype = OmpSupport::e_reduction_plus;
22861 isReduction =
true;
22864 case V_SgMultAssignOp:
22866 optype = OmpSupport::e_reduction_mul;
22867 isReduction =
true;
22870 case V_SgMinusAssignOp:
22872 optype = OmpSupport::e_reduction_minus;
22873 isReduction =
true;
22876 case V_SgAndAssignOp:
22878 optype = OmpSupport::e_reduction_bitand;
22879 isReduction =
true;
22882 case V_SgXorAssignOp:
22884 optype = OmpSupport::e_reduction_bitxor;
22885 isReduction =
true;
22888 case V_SgIorAssignOp:
22890 optype = OmpSupport::e_reduction_bitor;
22891 isReduction =
true;
22900 return isReduction;
22932 std::set<SgInitializedName*> candidateVars;
22934 std::map <SgInitializedName*, vector<SgVarRefExp* > > var_references;
22936 Rose_STL_Container<SgNode*> reflist = NodeQuery::querySubTree(loop, V_SgVarRefExp);
22938 ROSE_ASSERT(lbody != NULL);
22939 Rose_STL_Container<SgNode*>::iterator iter = reflist.begin();
22940 for (; iter!=reflist.end(); iter++)
22949 ROSE_ASSERT(var_scope != NULL);
22950 if ((
isScalarType(initname->get_type())) &&(initname !=loopindex)
22953 candidateVars.insert(initname);
22954 var_references[initname].push_back(ref_exp);
22959 std::set<SgInitializedName*>::iterator niter=candidateVars.begin();
22960 for (; niter!=candidateVars.end(); niter++)
22963 bool isReduction =
false;
22964 OmpSupport::omp_construct_enum optype;
22966 if (var_references[initname].size()==1)
22968 mlog[Sawyer::Message::Common::DEBUG] <<
"Debug: SageInterface::ReductionRecognition() A candidate used once:"<<initname->get_name().getString()<<endl;
22969 SgVarRefExp* ref_exp = *(var_references[initname].begin());
22970 if (isSingleAppearanceReduction (ref_exp, optype))
22971 isReduction =
true;
22974 else if (var_references[initname].size()==2)
22976 mlog[Sawyer::Message::Common::DEBUG] <<
"Debug: A candidate used twice:"<<initname->get_name().getString()<<endl;
22977 SgVarRefExp* ref_exp1 = *(var_references[initname].begin());
22978 SgVarRefExp* ref_exp2 = *(++var_references[initname].begin());
22981 if (isAssignReduction (ref_exp1, ref_exp2, optype) || isIfReduction (ref_exp1, ref_exp2, optype) )
22983 isReduction =
true;
22989 results.insert(make_pair(initname,optype));
22996 ROSE_ASSERT(r!=NULL);
22997#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
22998 ConstantFolding::constantFoldingOptimization(r,
false);
23008 virtual void visit (
SgNode * n)
23015 ROSE_ASSERT (name_attribute != NULL);
23023 exampleTraversal.
traverse(project, preorder);
23055 const SgInitializedNamePtrList& orig_decls = params.
get_args();
23057 std::transform( orig_decls.begin(), orig_decls.end(), sg::sage_inserter(copy), sg::InitNameCloner(copy, fundef) );
23071 sg::swap_child(ll, rr, &SgFunctionDeclaration::get_definition, &SgFunctionDeclaration::set_definition);
23072 sg::swap_child(ll, rr, &SgFunctionDeclaration::get_parameterList, &SgFunctionDeclaration::set_parameterList);
23082 std::pair<SgStatement*, SgInitializedName*>
23096 SgType* result_type = definingDeclaration.get_type()->get_return_type();
23101 SgFunctionDeclaration* wrapperfn = SB::buildDefiningFunctionDeclaration(newName, result_type, ¶m_list, containing_scope);
23104 ROSE_ASSERT(wrapperdef);
23107 wrapperfn->set_exceptionSpecification(definingDeclaration.get_exceptionSpecification());
23111 swapDefiningElements(definingDeclaration, *wrapperfn);
23116 SgInitializedNamePtrList& param_decls = param_list.
get_args();
23118 std::transform( param_decls.begin(), param_decls.end(), sg::sage_inserter(*args), sg::VarRefBuilder(*wrapperdef) );
23120 SgFunctionCallExp* callWrapped = SB::buildFunctionCallExp( newName, result_type, args, body );
23125 if (!isSgTypeVoid(result_type))
23128 SgVariableDeclaration* res = SB::buildVariableDeclaration(
"res", result_type, SB::buildAssignInitializer(callWrapped), body );
23135 callStatement = res;
23142 callStatement = SB::buildExprStatement(callWrapped);
23146 ROSE_ASSERT(callStatement);
23150 SgFunctionDeclaration* wrapperfn_proto = SB::buildNondefiningFunctionDeclaration(wrapperfn, containing_scope, decorator_proto);
23156 return std::make_pair(callStatement, resultName);
23164 struct VarrefBuilder
23183 template <
class AstNode>
23184 struct VarrefCreator : VarrefBuilder
23189 VarrefCreator(AstNode& orig)
23193 SgVarRefExp*
get()
const {
return VarrefBuilder::build(origin); }
23196 template <
class AstNode>
23197 VarrefCreator<AstNode>
23198 varrefCreator(AstNode& n)
23200 return VarrefCreator<AstNode>(n);
23210 return SB::buildMultiplyOp(lhs, SI::deepCopy(rhs));
23213 std::pair<std::vector<SgExpression*>,
SgType*>
23214 get_C_array_dimensions_aux(
const SgArrayType& arr_type)
23220 std::vector<SgExpression*> indices;
23221 SgType* undertype = NULL;
23225 if (arrtype->get_index() == NULL)
23227 indices.push_back(SB::buildNullExpression());
23228 undertype = arrtype->get_base_type();
23229 arrtype = isSgArrayType(undertype);
23235 ROSE_ASSERT(indexexpr);
23237 indices.push_back(SI::deepCopy(indexexpr));
23238 undertype = arrtype->get_base_type();
23239 arrtype = isSgArrayType(undertype);
23242 ROSE_ASSERT((!indices.empty()) && undertype);
23243 return std::make_pair(indices, undertype);
23247 std::vector<SgExpression*>
23248 get_C_array_dimensions_aux(
const SgArrayType& arrtype,
const VarrefBuilder& varrefBuilder)
23252 std::pair<std::vector<SgExpression*>,
SgType*> res = get_C_array_dimensions_aux(arrtype);
23253 const std::vector<SgExpression*>::iterator first = res.first.begin();
23256 if (isSgNullExpression(*first))
23264 const std::vector<SgExpression*>::iterator aa = first+1;
23265 const std::vector<SgExpression*>::iterator zz = res.first.end();
23267 SgExpression* sz_undertype = SB::buildSizeOfOp(res.second);
23268 SgExpression* denominator = std::accumulate(aa, zz, sz_undertype, create_mulop);
23269 SgSizeOfOp* sz_var = SB::buildSizeOfOp(varrefBuilder.get());
23270 SgExpression* sz = SB::buildDivideOp(sz_var, denominator);
23272 std::swap(*first, sz);
23280 std::vector<SgExpression*>
23283 return get_C_array_dimensions_aux(arrtype).first;
23286 std::vector<SgExpression*>
23289 return get_C_array_dimensions_aux(arrtype, varrefCreator(varref));
23292 std::vector<SgExpression*>
23295 return get_C_array_dimensions_aux(arrtype, varrefCreator(initname));
23302 set<unsigned int> sourceSequenceSet;
23304 void visit (
SgNode* astNode );
23312 if (fileInfo != NULL)
23314 unsigned int source_sequence_number = fileInfo->get_source_sequence_number();
23316 printf (
"In CollectSourceSequenceNumbers::visit(): source_sequence_number = %" PRIuPTR
" \n",source_sequence_number);
23318 sourceSequenceSet.insert(source_sequence_number);
23328 traversal.
traverse(astNode,preorder);
23330 return traversal.sourceSequenceSet;
23417#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
23419 if (collapsing_factor <= 1)
23432 ROSE_ASSERT (global_scope != NULL);
23441 bool *isPlus =
new bool[collapsing_factor];
23445 std::vector<SgForStatement* > loops= SageInterface::querySubTree<SgForStatement>(target_loop,V_SgForStatement);
23446 ROSE_ASSERT(loops.size()>=collapsing_factor);
23462 ROSE_ASSERT(
getScope(target_loop)->get_parent()!= NULL);
23466 while(scope == NULL)
23468 parent = isSgStatement(parent->
get_parent());
23469 scope = isSgScopeStatement(parent);
23473 if (insert_target != NULL)
23478 ROSE_ASSERT(scope != NULL);
23481 for(
size_t i = 0; i < collapsing_factor; i ++)
23483 temp_target_loop = loops[i];
23488 if (!
isCanonicalForLoop(temp_target_loop, &ivar[i], &lb[i], &ub[i], &step[i], &orig_body[i], &isPlus[i]))
23490 cerr<<
"Error in SageInterface::loopCollapsing(): target loop is not canonical."<<endl;
23498 delete[] orig_body;
23499 delete[] total_iters;
23506 ROSE_ASSERT(ivar[i]&& lb[i] && ub[i] && step[i]);
23510 if(isPlus[i] ==
true)
23524 string iter_var_name=
"_total_iters";
23545 new_var_list->append_expression(isSgVarRefExp(ub_exp));
23548 for(
unsigned int i = 0; i < collapsing_factor; i++)
23551 for(
unsigned int j = collapsing_factor - 1; j > i; j--)
23560 new_var_list->append_expression(isSgVarRefExp(interval[i]));
23570 ROSE_ASSERT(insert_target != NULL);
23575 new_var_list->append_expression(clps_index_ref);
23581 ROSE_ASSERT(body != NULL);
23584 std::vector<SgStatement*> new_stmt_list;
23595 for(
unsigned int i = 0; i < collapsing_factor - 1; i ++)
23597 if(isPlus[i] ==
true)
23603 new_stmt_list.push_back(assign_stmt);
23606 if(i != collapsing_factor - 2){
23607 string remain_var_name=
"_remainder";
23608 remain_var_name =
"__"+ ivar[i]->get_name().getString() + remain_var_name;
23611 new_stmt_list.push_back(loop_index_decl);
23617 if(isPlus[collapsing_factor - 1] ==
true)
23621 new_stmt_list.push_back(assign_stmt);
23633 ROSE_ASSERT(cond_stmt != NULL);
23640 target_loop = new_loop;
23642 ConstantFolding::constantFoldingOptimization(scope->
get_parent(),
false);
23648 delete [] orig_body;
23649 delete [] total_iters;
23650 delete [] interval;
23655 return new_var_list;
23674 RoseAst ast_of_original(tree2);
23683 while (i_copy != ast_of_copy.
end())
23686 printf (
"*i_copy = %p = %s \n",*i_copy,(*i_copy)->class_name().c_str());
23687 printf (
"*i_original = %p = %s \n",*i_original,(*i_original)->class_name().c_str());
23691 if ((*i_copy)->variantT() != (*i_original)->variantT())
23694 printf (
"ERROR: return from SageInterface::isStructurallyEquivalentAST(): (*i_copy)->variantT() != (*i_original)->variantT() \n");
23697 printf (
"Making this an error! \n");
23707 ROSE_ASSERT(i_original != ast_of_original.
end());
23712 ROSE_ASSERT(i_copy == ast_of_copy.
end() && i_original == ast_of_original.
end());
23732 lower_bound = NULL;
23733 upper_bound = NULL;
23737 const std::vector<SgStatement *> & init_stmts = for_init_stmt->
get_init_stmt();
23738 assert(init_stmts.size() == 1);
23740 assert(init_stmt != NULL);
23743 SgAssignOp * assign_init = isSgAssignOp(init);
23744 assert(assign_init != NULL);
23746 assert(iterator_init_ref != NULL);
23747 iterator = iterator_init_ref->get_symbol();
23748 assert(iterator != NULL);
23751 SgExprStatement * test_stmt = isSgExprStatement(for_loop->get_test());
23752 assert(test_stmt != NULL);
23758 while (isSgCastExp(lhs_exp)) lhs_exp = ((
SgCastExp *)lhs_exp)->get_operand_i();
23759 SgVarRefExp * lhs_var_ref = isSgVarRefExp(lhs_exp);
23760 bool lhs_it = (lhs_var_ref != NULL) && (lhs_var_ref->get_symbol() == iterator);
23763 while (isSgCastExp(rhs_exp)) rhs_exp = ((
SgCastExp *)rhs_exp)->get_operand_i();
23764 SgVarRefExp * rhs_var_ref = isSgVarRefExp(rhs_exp);
23766 bool rhs_it = (rhs_var_ref != NULL) && (rhs_var_ref->get_symbol() == iterator);
23774 assert(lhs_it != rhs_it);
23783 case V_SgGreaterOrEqualOp:
23784 inclusive = lhs_it;
23787 case V_SgGreaterThanOp:
23788 inclusive = !lhs_it;
23791 case V_SgLessOrEqualOp:
23792 inclusive = lhs_it;
23793 reversed = !lhs_it;
23795 case V_SgLessThanOp:
23796 inclusive = !lhs_it;
23797 reversed = !lhs_it;
23799 case V_SgEqualityOp:
23800 case V_SgNotEqualOp:
23806 switch (increment->variantT()) {
23807 case V_SgPlusPlusOp:
23811 case V_SgMinusMinusOp:
23815 case V_SgPlusAssignOp:
23820 assert(var_ref_lhs != NULL && var_ref_lhs->get_symbol() == iterator);
23825 case V_SgMinusAssignOp:
23830 assert(var_ref_lhs != NULL && var_ref_lhs->get_symbol() == iterator);
23840 assert(inc_assign_lhs != NULL && inc_assign_lhs->get_symbol() == iterator);
23843 assert(inc_assign_rhs != NULL);
23845 if (inc_assign_rhs_lhs != NULL && inc_assign_rhs_lhs->get_symbol() == iterator)
23848 if (inc_assign_rhs_rhs != NULL && inc_assign_rhs_rhs->get_symbol() == iterator)
23869#ifdef ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
23876 jstring temp_directory = (jstring) Rose::Frontend::Java::Ecj::currentEnvironment -> CallObjectMethod(::currentJavaTraversalClass, Rose::Frontend::Java::Ecj::getTempDirectoryMethod);
23878 const char *utf8 = Rose::Frontend::Java::Ecj::currentEnvironment -> GetStringUTFChars(temp_directory, NULL);
23880 string directory_name = utf8;
23881 Rose::Frontend::Java::Ecj::currentEnvironment -> ReleaseStringUTFChars(temp_directory, utf8);
23883 list<string> sourcepath = project -> get_Java_sourcepath();
23884 sourcepath.push_back(directory_name);
23885 project -> set_Java_sourcepath(sourcepath);
23887 return directory_name;
23895 string command = string(
"rm -fr ") + directory_name;
23896 int status = system(command.c_str());
23897 ROSE_ASSERT(status == 0);
23908 project -> get_sourceFileNameList().push_back(filename);
23909 Rose_STL_Container<std::string> arg_list = project -> get_originalCommandLineArgumentList();
23910 arg_list.push_back(filename);
23913 int error_code = 0;
23914 SgFile *file = determineFileType(arg_list, error_code, project);
23916 ROSE_ASSERT(sourcefile);
23917 sourcefile -> set_parent(project);
23922 project -> get_fileList_ptr() -> get_listOfFiles().push_back(sourcefile);
23923 ROSE_ASSERT(sourcefile == isSgSourceFile((*project)[filename]));
23925 sourcefile -> build_Java_AST(arg_list, project -> get_originalCommandLineArgumentList());
23928 project -> get_fileList_ptr() -> get_listOfFiles().pop_back();
23929 ROSE_ASSERT(sourcefile != isSgSourceFile((*project)[filename]));
23933 ROSE_ASSERT(file->get_preprocessorDirectivesAndCommentsList() != NULL);
23944 string command =
"package " + package_name +
";";
23949 jstring temp_file = (jstring) Rose::Frontend::Java::Ecj::currentEnvironment -> CallObjectMethod(Rose::Frontend::Java::Ecj::currentJavaTraversalClass,
23950 Rose::Frontend::Java::Ecj::createTempFileMethod,
23951 Rose::Frontend::Java::Ecj::currentEnvironment -> NewStringUTF(command.c_str()));
23953 const char *utf8 = Rose::Frontend::Java::Ecj::currentEnvironment -> GetStringUTFChars(temp_file, NULL);
23955 string filename = (string) utf8;
23956 Rose::Frontend::Java::Ecj::currentEnvironment -> ReleaseStringUTFChars(temp_file, utf8);
23960 return package_name;
23969 string command =
"import " + import_string +
";";
23974 jstring temp_file = (jstring) Rose::Frontend::Java::Ecj::currentEnvironment -> CallObjectMethod(Rose::Frontend::Java::Ecj::currentJavaTraversalClass,
23975 Rose::Frontend::Java::Ecj::createTempFileMethod,
23976 Rose::Frontend::Java::Ecj::currentEnvironment -> NewStringUTF(command.c_str()));
23978 const char *utf8 = Rose::Frontend::Java::Ecj::currentEnvironment -> GetStringUTFChars(temp_file, NULL);
23980 string filename = (string) utf8;
23981 Rose::Frontend::Java::Ecj::currentEnvironment -> ReleaseStringUTFChars(temp_file, utf8);
23985 return import_string;
23997 jstring temp_file = (jstring) Rose::Frontend::Java::Ecj::currentEnvironment -> CallObjectMethod(Rose::Frontend::Java::Ecj::currentJavaTraversalClass,
23998 Rose::Frontend::Java::Ecj::createTempNamedFileMethod,
23999 Rose::Frontend::Java::Ecj::currentEnvironment -> NewStringUTF(file_name.c_str()),
24000 Rose::Frontend::Java::Ecj::currentEnvironment -> NewStringUTF(file_content.c_str()));
24002 const char *utf8 = Rose::Frontend::Java::Ecj::currentEnvironment -> GetStringUTFChars(temp_file, NULL);
24004 string filename = (string) utf8;
24005 Rose::Frontend::Java::Ecj::currentEnvironment -> ReleaseStringUTFChars(temp_file, utf8);
24015 ROSE_ASSERT(scope);
24017 for (
int index = 0, length = package_name.size(); index < length; index++) {
24019 for (n = index; n < length; n++) {
24020 if (package_name[n] ==
'.') {
24024 string name = package_name.substr(index, n - index);
24026 SgClassSymbol *package_symbol = scope -> lookup_class_symbol(name);
24027 if (package_symbol == NULL) {
24031 SgJavaPackageDeclaration *package_declaration = isSgJavaPackageDeclaration(package_symbol -> get_declaration() -> get_definingDeclaration());
24032 ROSE_ASSERT(package_declaration);
24033 package_definition = package_declaration -> get_definition();
24034 ROSE_ASSERT(package_definition);
24035 scope = package_definition;
24040 return package_definition;
24048 SgGlobal *global_scope = project -> get_globalScopeAcrossFiles();
24050 if (package_definition == NULL) {
24056 if (create_directory) {
24057 Rose::Frontend::Java::Ecj::currentEnvironment -> CallObjectMethod(Rose::Frontend::Java::Ecj::currentJavaTraversalClass,
24058 Rose::Frontend::Java::Ecj::createTempNamedDirectoryMethod,
24059 Rose::Frontend::Java::Ecj::currentEnvironment -> NewStringUTF(package_name.c_str()));
24065 return package_definition;
24072 ROSE_ASSERT(package_definition);
24073 SgClassSymbol *class_symbol = package_definition -> lookup_class_symbol(class_name);
24076 : isSgClassDeclaration(class_symbol -> get_declaration() -> get_definingDeclaration()));
24077 if ((! class_declaration) || (! class_declaration -> attributeExists(
"complete"))) {
24078 string qualified_name = package_definition -> get_qualified_name().getString() +
"." + class_name;
24080 class_symbol = package_definition -> lookup_class_symbol(class_name);
24083 class_declaration = (class_symbol == NULL
24085 : isSgClassDeclaration(class_symbol -> get_declaration() -> get_definingDeclaration()));
24087 return class_declaration;
24103 SgClassDeclaration *class_declaration = isSgClassDeclaration(class_type -> get_declaration() -> get_definingDeclaration());
24104 ROSE_ASSERT(class_declaration);
24105 SgClassDefinition *scope = isSgClassDefinition(class_declaration -> get_scope());
24106 while (scope && (! isSgJavaPackageDeclaration(scope -> get_parent()))) {
24107 class_declaration = isSgClassDeclaration(scope -> get_parent());
24108 ROSE_ASSERT(class_declaration);
24109 scope = isSgClassDefinition(class_declaration -> get_scope());
24116 string class_name = class_declaration ->
get_name().getString();
24125 ROSE_ASSERT(class_definition);
24127 ROSE_ASSERT(type_list);
24129 ROSE_ASSERT(string_array_type);
24130 type_list -> append_argument(string_array_type);
24136 SgFunctionSymbol *method_symbol = class_definition -> lookup_function_symbol(
"main", member_function_type);
24138 return (method_symbol == NULL ? NULL : isSgMemberFunctionDeclaration(method_symbol -> get_declaration()));
24146 SgClassDeclaration *class_declaration = isSgClassDeclaration(class_type -> get_declaration() -> get_definingDeclaration());
24147 ROSE_ASSERT(class_declaration);
24160 ROSE_ASSERT (old_sym != NULL);
24161 ROSE_ASSERT (new_sym != NULL);
24162 ROSE_ASSERT (old_sym != new_sym);
24163 ROSE_ASSERT (scope != NULL);
24165 Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(scope, V_SgVarRefExp);
24166 for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
24169 if (vRef->get_symbol() == old_sym)
24170 vRef->set_symbol(new_sym);
24183 bool result =
true;
24185 bool includingSelf =
false;
24188 if (sourceFile == NULL)
24190 printf (
"In SageInterface::statementCanBeTransformed(): sourceFile not found \n");
24194 ROSE_ASSERT(sourceFile != NULL);
24196 if (sourceFile != NULL && sourceFile->get_unparse_tokens() ==
true && sourceFile->get_unparseHeaderFiles() ==
true)
24200 string source_filename = stmt->getFilenameString();
24202 printf (
"In SageInterface::statementCanBeTransformed(): source_filename = %s \n",source_filename.c_str());
24203 printf (
" --- Rose::includeFileMapForUnparsing.size() = %zu \n",Rose::includeFileMapForUnparsing.size());
24207 if (EDG_ROSE_Translation::edg_include_file_map.find(source_filename) != EDG_ROSE_Translation::edg_include_file_map.end())
24209 SgIncludeFile* include_file = EDG_ROSE_Translation::edg_include_file_map[source_filename];
24210 ROSE_ASSERT(include_file != NULL);
24212 printf (
"include_file->get_can_be_supported_using_token_based_unparsing() = %s \n",include_file->get_can_be_supported_using_token_based_unparsing() ?
"true" :
"false");
24214 if (include_file->get_can_be_supported_using_token_based_unparsing() ==
false)
24217 printf (
"NOTE: Transformations of this statement cannot be supported using the header file unparsing with token unparsing options! \n");
24227 printf (
"Not found in Rose::includeFileMapForUnparsing: source_filename = %s \n",source_filename.c_str());
24230 printf (
"Exiting as a test! \n");
24236 printf (
"Error: In statementCanBeTransformed(): this might be an issue! \n");
24249 ROSE_ASSERT (decl!= NULL);
24250 ROSE_ASSERT (target_scope != NULL);
24251 ROSE_ASSERT (target_scope != decl->
get_scope());
24258 if (isSgIfStmt (target_scope))
24261 if (target_scope == )
24271 case V_SgBasicBlock:
24283 case V_SgForStatement:
24287 ROSE_ASSERT(stmt != NULL);
24288 SgStatementPtrList& stmt_list = stmt->get_init_stmt();
24292 if (stmt_list.size() !=1)
24294 cerr<<
"Error in moveVariableDeclaration(): only single init statement is handled for SgForStatement now."<<endl;
24295 ROSE_ASSERT (stmt_list.size() ==1);
24298 ROSE_ASSERT (exp_stmt != NULL);
24299 SgAssignOp* assign_op = isSgAssignOp(exp_stmt->get_expression());
24300 ROSE_ASSERT (assign_op != NULL);
24310 if (init_name->get_initptr() != NULL)
24312 init_name->set_initptr(initor);
24315 stmt_list.insert (stmt_list.begin(), decl );
24321 cerr<<
"Error. Unhandled target scope type:"<<target_scope->
class_name()<<endl;
24322 ROSE_ASSERT (
false);
24328 ROSE_ASSERT(sym != NULL);
24330 if (orig_scope != target_scope)
24335 init_name->set_scope(target_scope);
24337 orig_scope->remove_symbol(sym);
24342 ROSE_ASSERT (target_scope->symbol_exists(sym));
24352 subtreeVal.hasValue_ =
true;
24354 if (isSgIntVal(valExp)) {
24355 subtreeVal.value_ = isSgIntVal(valExp)->get_value();
24356 }
else if (isSgLongIntVal(valExp)) {
24357 subtreeVal.value_ = isSgLongIntVal(valExp)->get_value();
24358 }
else if (isSgLongLongIntVal(valExp)) {
24359 subtreeVal.value_ = isSgLongLongIntVal(valExp)->get_value();
24360 }
else if (isSgShortVal(valExp)) {
24361 subtreeVal.value_ = isSgShortVal(valExp)->get_value();
24362 }
else if (isSgUnsignedIntVal(valExp)) {
24363 subtreeVal.value_ = isSgUnsignedIntVal(valExp)->get_value();
24364 }
else if (isSgUnsignedLongVal(valExp)) {
24365 subtreeVal.value_ = isSgUnsignedLongVal(valExp)->get_value();
24366 }
else if (isSgUnsignedLongLongIntVal(valExp)) {
24367 subtreeVal.value_ = isSgUnsignedLongLongIntVal(valExp)->get_value();
24368 }
else if (isSgUnsignedShortVal(valExp)) {
24369 subtreeVal.value_ = isSgUnsignedShortVal(valExp)->get_value();
24375 if (isSgModifierType(vRef->get_type()) == NULL) {
24378 val.hasValue_ =
false;
24381 if (isSgModifierType(vRef->get_type())->
get_typeModifier().get_constVolatileModifier().isConst()) {
24387 if (isSgAssignInitializer(ini)) {
24392 return variableEval.
traverse(rhs);
24396 val.hasValue_ =
false;
24402 if (isSgExpression(node) != NULL) {
24404 if (valueExp != NULL) {
24405 return this->getValueExpressionValue(valueExp);
24409 if (varRefExp != NULL) {
24411 return evaluateVariableReference(varRefExp);
24414 if (isSgAssignInitializer(node)) {
24415 if(synList.at(0).hasValue_){
24416 return synList.at(0);
24420 val.hasValue_ =
false;
24425 evaluatedValue.hasValue_ =
false;
24426 evaluatedValue.value_ = -1;
24428 if(synList.size() != 2){
24429 for(SynthesizedAttributesList::iterator it = synList.begin(); it != synList.end(); ++it){
24430 std::cout <<
"Node: " << node->unparseToString() <<
"\n" << (*it).value_ << std::endl;
24431 std::cout <<
"Parent: " << node->get_parent()->unparseToString() << std::endl;
24432 std::cout <<
"Parent, Parent: " << node->get_parent()->get_parent()->unparseToString() << std::endl;
24436 for (SynthesizedAttributesList::iterator it = synList.begin(); it != synList.end(); ++it) {
24437 if((*it).hasValue_){
24438 if (isSgAddOp(node)) {
24439 assert(synList.size() == 2);
24440 evaluatedValue.value_ = synList[0].value_ + synList[1].value_ ;
24441 evaluatedValue.hasValue_ =
true;
24442 }
else if (isSgSubtractOp(node)) {
24443 assert(synList.size() == 2);
24444 evaluatedValue.value_ = synList[0].value_ - synList[1].value_ ;
24445 evaluatedValue.hasValue_ =
true;
24446 }
else if (isSgMultiplyOp(node)) {
24447 assert(synList.size() == 2);
24448 evaluatedValue.value_ = synList[0].value_ * synList[1].value_ ;
24449 evaluatedValue.hasValue_ =
true;
24450 }
else if (isSgDivideOp(node)) {
24451 assert(synList.size() == 2);
24452 evaluatedValue.value_ = synList[0].value_ / synList[1].value_ ;
24453 evaluatedValue.hasValue_ =
true;
24454 }
else if (isSgModOp(node)) {
24455 assert(synList.size() == 2);
24456 evaluatedValue.value_ = synList[0].value_ % synList[1].value_ ;
24457 evaluatedValue.hasValue_ =
true;
24460 std::cerr <<
"Expression is not evaluatable" << std::endl;
24461 evaluatedValue.hasValue_ =
false;
24462 evaluatedValue.value_ = -1;
24463 return evaluatedValue;
24466 evaluatedValue.hasValue_ =
true;
24467 return evaluatedValue;
24470 evaluatedValue.hasValue_ =
false;
24471 evaluatedValue.value_ = -1;
24472 return evaluatedValue;
24485 class TypeEquivalenceChecker {
24487 TypeEquivalenceChecker(
bool profile,
bool useSemanticEquivalence)
24488 : profile_(profile), useSemanticEquivalence_(useSemanticEquivalence),
24489 namedType_(0), pointerType_(0), arrayType_(0), functionType_(0)
24495 if (isSgTypedefType(t)) {
24497 node = isSgTypedefType(t)->
stripType(SgType::STRIP_TYPEDEF_TYPE);
24499 if(useSemanticEquivalence_){
24500 if(isSgModifierType(t)){
24502 ROSE_ASSERT(modType != NULL);
24509 std::cout <<
"Hit volatile type, stripping of modifier type" << std::endl;
24510 node = modType->get_base_type();
24514 std::cout <<
"Hit restrict type, stripping of modifier type" << std::endl;
24515 node = modType->get_base_type();
24519 ROSE_ASSERT(node != NULL);
24524 bool equal =
false;
24525 if(t1 == NULL || t2 == NULL){
24526 std::string wasNull;
24532 std::cerr <<
"ERROR: " << wasNull <<
" was NULL" << std::endl;
24545 i != subT1.
end() && j != subT2.
end(); ++i, ++j) {
24550 nodeT1 = getBasetypeIfApplicable(nodeT1);
24551 nodeT2 = getBasetypeIfApplicable(nodeT2);
24555 if(isSgModifierType(nodeT1)){
24559 if(modT1.get_constVolatileModifier().isConst() != modT2.get_constVolatileModifier().isConst()){
24562 if(modT1.get_constVolatileModifier().isVolatile() != modT2.get_constVolatileModifier().isVolatile()){
24565 }
else if (isSgNamedType(nodeT1)) {
24569 i.skipChildrenOnForward();
24570 j.skipChildrenOnForward();
24576 if(!c1->get_autonomous_declaration()){
24579 if (!c2->get_autonomous_declaration()){
24588 }
else if (isSgPointerType(nodeT1)) {
24595 return typesAreEqual(t1->get_base_type(), t2->get_base_type());
24597 }
else if(isSgReferenceType(nodeT1)){
24601 return typesAreEqual(t1->get_base_type(), t2->get_base_type());
24602 }
else if (isSgArrayType(nodeT1)) {
24609 bool arrayBaseIsEqual = typesAreEqual(a1->get_base_type(), a2->get_base_type());
24613 bool arrayIndexExpressionIsEquivalent =
false;
24614 if(t1Index.hasValue_ && t2Index.hasValue_){
24615 if(t1Index.value_ == t2Index.value_){
24616 arrayIndexExpressionIsEquivalent =
true;
24619 bool arraysAreEqual = (arrayBaseIsEqual && arrayIndexExpressionIsEquivalent);
24620 return arraysAreEqual;
24621 }
else if (isSgFunctionType(nodeT1)) {
24629 if(typesAreEqual(funcTypeA->get_return_type(), funcTypeB->get_return_type())) {
24639 for(SgTypePtrList::const_iterator ii = funcTypeA->
get_arguments().begin(),
24646 if(!typesAreEqual((*ii), (*jj))) {
24666 std::cerr <<
"This feature for now is available with autotools only!" << std::endl;
24671int getNamedTypeCount() {
24675int getPointerTypeCount() {
24676 return pointerType_;
24679int getArrayTypeCount() {
24683int getFunctionTypeCount() {
24684 return functionType_;
24688 bool profile_, useSemanticEquivalence_;
24689 int namedType_, pointerType_, arrayType_, functionType_;
24692TypeEquivalenceChecker tec(
false,
false);
24693return tec.typesAreEqual(typeA, typeB);
24697std::set<SgStatement*>
24706 StatementTraversal() : count (0) {}
24707 void visit (
SgNode* node)
24712 returnset.insert(statement);
24718 std::set<SgStatement*> returnset;
24722 StatementTraversal traversal;
24723 traversal.traverse(node, preorder);
24725 return traversal.returnset;
24728std::set<SgStatement*>
24735 printf (
"In collectModifiedStatements(): node = %p = %s \n",node,node->
class_name().c_str());
24741 StatementTraversal() : count (0) {}
24742 void visit (
SgNode* node)
24747 returnset.insert(statement);
24753 std::set<SgStatement*> returnset;
24757 StatementTraversal traversal;
24758 traversal.traverse(node, preorder);
24760 return traversal.returnset;
24770 printf (
"In outputFileIds(): node = %p = %s \n",node,node->
class_name().c_str());
24776 LocatedNodeTraversal() {}
24777 void visit (
SgNode* node)
24780 if (locatedNode != NULL)
24783 printf (
"In outputFileIds(): isModified() == %s: locatedNode = %p = %s \n",locatedNode->
get_isModified() ?
"true" :
"false",locatedNode,locatedNode->
class_name().c_str());
24784 printf (
" --- file id = %d physical_file_id = %d \n",node->
get_file_info()->get_file_id(),node->
get_file_info()->get_physical_file_id());
24790 if (initializedName != NULL)
24792 printf (
"In outputFileIds(): isModified() == %s: initializedName = %p = %s \n",initializedName->
get_isModified() ?
"true" :
"false",initializedName,initializedName->
class_name().c_str());
24793 printf (
" --- file id = %d physical_file_id = %d \n",initializedName->
get_file_info()->get_file_id(),initializedName->
get_file_info()->get_physical_file_id());
24800 LocatedNodeTraversal traversal;
24801 traversal.traverse(node, preorder);
24804 printf (
"Exiting as a test! \n");
24810std::set<SgLocatedNode*>
24817 printf (
"In collectModifiedLocatedNodes(): node = %p = %s \n",node,node->
class_name().c_str());
24823 LocatedNodeTraversal() : count (0) {}
24824 void visit (
SgNode* node)
24827 if (locatedNode != NULL && locatedNode->
get_isModified() ==
true)
24830 printf (
"In collectModifiedLocatedNodes(): isModified() == true: locatedNode = %p = %s \n",locatedNode,locatedNode->
class_name().c_str());
24832 returnset.insert(locatedNode);
24838 std::set<SgLocatedNode*> returnset;
24842 LocatedNodeTraversal traversal;
24843 traversal.traverse(node, preorder);
24845 return traversal.returnset;
24856 printf (
"In resetModifiedLocatedNodes(): modifiedNodeSet.size() = %zu \n",modifiedNodeSet.size());
24859 std::set<SgLocatedNode*>::const_iterator i = modifiedNodeSet.begin();
24860 while (i != modifiedNodeSet.end())
24864 printf (
"Marking node = %p = %s as modified \n",node,node->
class_name().c_str());
24879 printf (
"\n\n##################################################### \n");
24880 printf (
"Report on modified statements: label = %s \n",label.c_str());
24883 if (sourceFile != NULL)
24885 printf (
" --- (SgSourceFile) filename = %s \n",sourceFile->
getFileName().c_str());
24889 SgGlobal* globalScope = isSgGlobal(node);
24890 if (globalScope != NULL)
24892 sourceFile = isSgSourceFile(globalScope->
get_parent());
24893 printf (
" --- (SgGlobal) filename = %s \n",sourceFile->
getFileName().c_str());
24897 ROSE_ASSERT(node != NULL);
24901 printf (
"In reportModifiedStatements(): collection.size() = %zu \n",collection.size());
24904 std::set<SgStatement*>::iterator i = collection.begin();
24905 while (i != collection.end())
24908 string filename = (*i)->get_file_info()->get_filename();
24911 if (filename ==
"transformation")
24914 printf (
" --- filename == transformation: sourceFile = %p using physical filename \n",sourceFile);
24917 SgSourceFile* sourceFile = TransformationSupport::getSourceFile(*i);
24918 if (sourceFile != NULL)
24924 printf (
" --- filename = %s modified statement = %p = %s \n",filename.c_str(),(*i),(*i)->class_name().c_str());
24932 printf (
"########################################################## \n");
24933 printf (
"reportModifiedStatements(): Called using label = %s \n",label.c_str());
24935 printf (
"########################################################## \n\n\n");
24938 printf (
"Exiting as a test! \n");
24939 ROSE_ASSERT(
false);
24951 printf (
"\n\n##################################################### \n");
24952 printf (
"Report on modified locatedNodes: label = %s \n",label.c_str());
24955 if (sourceFile != NULL)
24957 printf (
" --- (SgSourceFile) filename = %s \n",sourceFile->
getFileName().c_str());
24961 SgGlobal* globalScope = isSgGlobal(node);
24962 if (globalScope != NULL)
24964 sourceFile = isSgSourceFile(globalScope->
get_parent());
24965 printf (
" --- (SgGlobal) filename = %s \n",sourceFile->
getFileName().c_str());
24969 ROSE_ASSERT(node != NULL);
24973 printf (
"In reportModifiedLocatedNode(): collection.size() = %zu \n",collection.size());
24976 std::set<SgLocatedNode*>::iterator i = collection.begin();
24977 while (i != collection.end())
24980 string filename = (*i)->get_file_info()->get_filename();
24983 if (filename ==
"transformation")
24986 printf (
" --- filename == transformation: sourceFile = %p using physical filename \n",sourceFile);
24989 SgSourceFile* sourceFile = TransformationSupport::getSourceFile(*i);
24990 if (sourceFile != NULL)
24996 printf (
" --- filename = %s modified locatedNode = %p = %s \n",filename.c_str(),(*i),(*i)->class_name().c_str());
25004 printf (
"########################################################## \n");
25005 printf (
"reportModifiedLocatedNodes(): Called using label = %s \n",label.c_str());
25007 printf (
"########################################################## \n\n\n");
25010 printf (
"Exiting as a test! \n");
25011 ROSE_ASSERT(
false);
25025 ROSE_ASSERT(locatedNode != NULL);
25029 curprint (
"/* Inside of printOutComments() */");
25032 if (comments != NULL)
25035 printf (
"Found attached comments (at %p of type: %s): \n",locatedNode,locatedNode->
class_name().c_str());
25036 curprint (
"/* Inside of printOutComments(): comments != NULL */");
25039 AttachedPreprocessingInfoType::iterator i;
25040 for (i = comments->begin(); i != comments->end(); i++)
25042 ROSE_ASSERT ( (*i) != NULL );
25043 printf (
" Attached Comment (relativePosition=%s): %s \n",
25046 PreprocessingInfo::relativePositionName((*i)->getRelativePosition()).c_str(),
25047 (*i)->getString().c_str());
25048 printf (
"Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
25052 (*i)->get_file_info()->display(
"comment/directive location");
25059 printf (
"In SageInterface::printOutComments(): No attached comments (at %p of type: %s): \n",locatedNode,locatedNode->
class_name().c_str());
25069 bool returnValue =
false;
25071 ROSE_ASSERT(currentPreprocessingInfo != NULL);
25073 PreprocessingInfo::DirectiveType directive = currentPreprocessingInfo->getTypeOfDirective();
25075 if (directive == PreprocessingInfo::C_StyleComment ||
25076 directive == PreprocessingInfo::CplusplusStyleComment ||
25077 directive == PreprocessingInfo::FortranStyleComment ||
25078 directive == PreprocessingInfo::CpreprocessorBlankLine ||
25079 directive == PreprocessingInfo::ClinkageSpecificationStart ||
25080 directive == PreprocessingInfo::ClinkageSpecificationEnd)
25082 returnValue =
true;
25085 return returnValue;
25088std::vector<SgC_PreprocessorDirectiveStatement*>
25091 std::vector<SgC_PreprocessorDirectiveStatement*> directiveList;
25096 if (comments !=
nullptr)
25098 AttachedPreprocessingInfoType::iterator i;
25099 for (i = comments->begin (); i != comments->end(); i++)
25108 ROSE_ASSERT(directive != NULL);
25109 directiveList.push_back(directive);
25112 printf (
"directiveList.size() = %zu \n",directiveList.size());
25116 return directiveList;
25125 printf (
"In translateScopeToUseCppDeclarations(): declarationsOnly = %s scope = %p = %s \n",declarationsOnly ?
"true" :
"false",scope,scope->
class_name().c_str());
25127 std::map<SgStatement*,std::vector<SgC_PreprocessorDirectiveStatement*> > directiveMap;
25129 if (declarationsOnly ==
true)
25133 SgDeclarationStatementPtrList::iterator i = declarationList.begin();
25134 while (i != declarationList.end())
25137 ROSE_ASSERT(declaration != NULL);
25141 printf (
"attachDirectives.size() = %zu \n",attachDirectives.size());
25143 if (attachDirectives.empty() ==
false)
25145 directiveMap.insert(std::pair<
SgStatement*,std::vector<SgC_PreprocessorDirectiveStatement*> >(declaration,attachDirectives));
25157 SgStatementPtrList::iterator i = statementList.begin();
25158 while (i != statementList.end())
25161 ROSE_ASSERT(statement != NULL);
25165 printf (
"attachDirectives.size() = %zu \n",attachDirectives.size());
25167 if (attachDirectives.empty() ==
false)
25169 directiveMap.insert(std::pair<
SgStatement*,std::vector<SgC_PreprocessorDirectiveStatement*> >(statement,attachDirectives));
25176 printf (
"directiveMap.size() = %zu \n",directiveMap.size());
25178 printf (
"Processing the directiveMap: \n");
25179 std::map<SgStatement*,std::vector<SgC_PreprocessorDirectiveStatement*> >::iterator i = directiveMap.begin();
25180 while (i != directiveMap.end())
25183 std::vector<SgC_PreprocessorDirectiveStatement*> directives = i->second;
25185 printf (
"statement = %p = %s \n",statement,statement->
class_name().c_str());
25186 printf (
"directives.size() = %zu \n",directives.size());
25188 std::vector<SgC_PreprocessorDirectiveStatement*>::iterator j = directives.begin();
25189 while (j != directives.end())
25198 ROSE_ASSERT(comments != NULL);
25200 AttachedPreprocessingInfoType deleteList;
25205 AttachedPreprocessingInfoType::iterator k;
25206 for (k = comments->begin(); k != comments->end(); k++)
25209 ROSE_ASSERT ( (*k) != NULL );
25210 printf (
" Attached Comment (relativePosition=%s): %s\n",
25211 ((*k)->getRelativePosition() == PreprocessingInfo::before) ?
"before" :
"after",
25212 (*k)->getString().c_str());
25213 printf (
"translateScopeToUseCppDeclarations(): Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*k)->getNumberOfLines(),(*k)->getColumnNumberOfEndOfString());
25220 printf (
"Do NOT delete *k = %p = %s \n",*k,(*k)->getString().c_str());
25224 printf (
"DO delete *k = %p = %s \n",*k,(*k)->getString().c_str());
25226 deleteList.push_back(*k);
25232 printf (
"Iterate over the deleteList: deleteList.size() = %zu comments->size() = %zu \n",deleteList.size(),comments->size());
25233 AttachedPreprocessingInfoType::iterator m = deleteList.begin();
25234 while (m != deleteList.end())
25238 comments->erase(std::remove(comments->begin(), comments->end(), *m), comments->end());
25240 printf (
" --- comments->size() = %zu \n",comments->size());
25252 printf (
"Leaving translateScopeToUseCppDeclarations(): scope = %p = %s \n",scope,scope->
class_name().c_str());
25262 CppTranslationTraversal() {}
25263 void visit (
SgNode* node)
25265 printf (
"In CppTranslationTraversal::visit(): node = %p = %s \n",node,node->
class_name().c_str());
25268 SgGlobal* globalScope = isSgGlobal(scope);
25269 if (globalScope != NULL)
25271 printf (
"In CppTranslationTraversal::visit(): processing scope = %p = %s \n",scope,scope->
class_name().c_str());
25278 printf (
"In SageInterface::translateToUseCppDeclarations(): Currently skipping all but global scope! \n");
25285 CppTranslationTraversal traversal;
25287 printf (
"In translateToUseCppDeclarations(): Calling traversal.traverse() \n");
25291 traversal.traverse(n, postorder);
25293 printf (
"Leaving translateToUseCppDeclarations(): DONE: Calling traversal.traverse() \n");
25300 cout<<
"--------------"<<endl;
25304 cout<<
"file info:\t ";
25305 lnode->get_file_info()->display();
25306 cout<<
"\n unparseToString:\t ";
25307 lnode->unparseToString();
25318static void serialize(SgTemplateArgumentPtrList& plist,
string& prefix,
bool hasRemaining, ostringstream& out,
string& edgeLabel)
25321 out<< (hasRemaining?
"|---":
"|___");
25324 out<<
" "<<edgeLabel<<
" ->";
25326 out<<
"@"<<&plist<<
" "<<
"SgTemplateArgumentPtrList ";
25330 int last_non_null_child_idx =-1;
25331 for (
int i = (
int) (plist.size())-1; i>=0; i--)
25335 last_non_null_child_idx = i;
25340 for (
size_t i=0; i< plist.size(); i++ )
25342 bool n_hasRemaining=
false;
25344 if (i+1 < plist.size())
25345 n_hasRemaining=
true;
25347 if ((
int)i< last_non_null_child_idx) n_hasRemaining =
true;
25349 string suffix= hasRemaining?
"| " :
" ";
25350 string n_prefix = prefix+suffix;
25351 string n_edge_label=
"";
25353 serialize (plist[i], n_prefix, n_hasRemaining, out,n_edge_label);
25366 out<< (hasRemaining?
"|---":
"|___");
25368 out<<
" "<<edgeLabel<<
" ->";
25371 out<<
" NULL "<<endl;
25376 out<<
"@"<<node<<
" "<< node->
class_name()<<
" ";
25382 out<< lnode->get_file_info()->get_filename() <<
" "<<lnode->get_file_info()->get_line()<<
":"<<lnode->get_file_info()->get_col();
25384 AttachedPreprocessingInfoType *comments =
25385 lnode->getAttachedPreprocessingInfo ();
25387 if (comments != NULL)
25390 out<<
" AttachedPreprocessingInfoType@"<<comments;
25392 AttachedPreprocessingInfoType::iterator i;
25394 for (i = comments->begin (); i != comments->end (); i++)
25396 if (i!=comments->begin ())
25399 out<<counter++<<
" ";
25408 out<<*i<<
" classification="<<PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective ()). c_str ();
25409 out<<
" string="<<(*i)->getString ().c_str ();
25410 out<<
" relative pos=" ;
25412 if ((*i)->getRelativePosition () == PreprocessingInfo::inside)
25414 else if ((*i)->getRelativePosition () == PreprocessingInfo::before)
25428 out<<
" first nondefining decl@"<< v->get_firstNondefiningDeclaration();
25429 out<<
" defining decl@"<< v->get_definingDeclaration();
25433 out<<
" value="<< f->get_value() <<
" declaration="<<f->get_declaration() <<
" name="<< f->get_name().getString();
25440 out<<
" renamed_function "<< f->get_renamed_function();
25443 out<<
" name="<< f->get_name() <<
" renamed decl "<<f->get_renamed() ;
25455 out<<
" enumType="<< f->get_enumType();
25463 out<<
" is_general_access"<< v->get_is_general_access();
25466 out<<
" is_anonymous:"<< v->get_is_anonymous ();
25471 out<<
" is_protected"<< v->get_is_protected();
25477 out<<
" type@"<< v->get_type();
25478 out<<
" initializer@"<< v->get_initializer();
25479 out<<
" scope@"<< v->get_scope();
25485 out<<
" template class decl@"<< f->get_templateDeclaration();
25488 out<<
" assoc. class decl@"<< f->get_associatedClassDeclaration();
25492 out<<
" member function decl@"<< ctor->get_declaration();
25495 if (
SgIntVal* v= isSgIntVal(node))
25496 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25499 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25502 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25505 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25508 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25511 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25514 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25517 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25520 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25523 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25526 out<<
" value="<< v->get_value() <<
" valueString="<< v->get_valueString();
25529 out<<
" init name@"<< var_ref->get_symbol()->get_declaration() <<
" symbol name="<<var_ref->get_symbol()->get_name();
25532 out<<
" member func decl@"<< func_ref->get_symbol_i()->get_declaration();
25535 out<<
" template member func decl@"<< cnode->get_templateDeclaration();
25540 out<<
" func decl@"<< sym->get_declaration() <<
" func sym name="<<sym->
get_name();
25546 out<<
" ada renaming decl@"<< renaming_decl;
25552 out<<
" base_type@"<< v->get_base_type();
25557 out<<
" base_type@"<< v->get_base_type();
25560 out<<
" base_type@"<< v->get_base_type();
25563 out<<
" type@"<< v->get_type();
25566 out<<
" attribute@"<< v->get_attribute();
25569 out<<
" namespaceDeclaration="<< v->get_namespaceDeclaration();
25575 int total_count = children.size();
25576 int current_index=0;
25579 int last_non_null_child_idx =-1;
25580 for (
int i = (
int) (children.size())-1; i>=0; i--)
25584 last_non_null_child_idx = i;
25592 if (isSgTemplateInstantiationDecl (node))
25599 SgTemplateArgumentPtrList& plist = sn->get_templateArguments();
25600 bool n_hasRemaining=
false;
25601 if (last_non_null_child_idx>-1) n_hasRemaining =
true;
25602 string suffix= hasRemaining?
"| " :
" ";
25603 string n_prefix = prefix+suffix;
25604 string n_edge_label=
"";
25605 serialize_list(plist,
"SgTemplateArgumentPtrList", n_prefix, n_hasRemaining, out, n_edge_label);
25609 SgExpressionPtrList& plist = import_stmt->get_import_list();
25610 bool n_hasRemaining=
false;
25611 if (last_non_null_child_idx>-1) n_hasRemaining =
true;
25612 string suffix= hasRemaining?
"| " :
" ";
25613 string n_prefix = prefix+suffix;
25614 string n_edge_label=
"";
25615 serialize_list(plist,
"SgExpressionPtrList", n_prefix, n_hasRemaining, out, n_edge_label);
25621 for (
size_t i =0; i< children.size(); i++)
25623 bool n_hasRemaining=
false;
25625 if (current_index+1<total_count)
25626 n_hasRemaining=
true;
25629 if ((
int)i<last_non_null_child_idx) n_hasRemaining =
true;
25631 string suffix= hasRemaining?
"| " :
" ";
25632 string n_prefix = prefix+suffix;
25634 serialize (children[i], n_prefix, n_hasRemaining, out, successorNames[i]);
25643 serialize(node, prefix,
false, oss, label);
25664 serialize(node, prefix,
false, oss, label);
25666 textfile.open(filename, ios::out);
25667 textfile<<oss.str();
25672 textfile<<
"Types encountered ...."<<endl;
25673 ostringstream oss2;
25674 VariantVector vv(V_SgType);
25675 Rose_STL_Container<SgNode*> tnodes= NodeQuery::queryMemoryPool(vv);
25676 for (Rose_STL_Container<SgNode*>::const_iterator i = tnodes.begin(); i != tnodes.end(); ++i)
25678 serialize (*i, prefix,
false, oss2, label);
25680 textfile<<oss2.str();
25688 saveToPDF(node,
string(
"temp.pdf.json") );
25694 ROSE_ASSERT(node != NULL);
25701 bool rtval =
false;
25702 ROSE_ASSERT (node != NULL);
25706 string fname = finfo->get_filenameString();
25707 string buildtree_str1 = string(
"include-staging/gcc_HEADERS");
25708 string buildtree_str2 = string(
"include-staging/g++_HEADERS");
25709 string installtree_str1 = string(
"include/edg/gcc_HEADERS");
25710 string installtree_str2 = string(
"include/edg/g++_HEADERS");
25711 string system_headers = string(
"/usr/include");
25713 if ((fname.find (buildtree_str1, 0) != string::npos) ||
25714 (fname.find (buildtree_str2, 0) != string::npos) ||
25715 (fname.find (installtree_str1, 0) != string::npos) ||
25716 (fname.find (installtree_str2, 0) != string::npos) ||
25717 (fname.find (system_headers, 0) != string::npos)
25730 bool returnValue =
false;
25733 ROSE_ASSERT(fileInfo != NULL);
25734 string filename = fileInfo->get_filenameString();
25737 printf (
"In SageInterface::insideHeader(): node = %s line: %d column: %d file: %s \n",node->
class_name().c_str(),fileInfo->
get_line(),fileInfo->
get_col(),filename.c_str());
25742 if (EDG_ROSE_Translation::edg_include_file_map.find(filename) == EDG_ROSE_Translation::edg_include_file_map.end())
25745 printf (
"This is NOT in the EDG_ROSE_Translation::edg_include_file_map \n");
25751 printf (
"This IS in the EDG_ROSE_Translation::edg_include_file_map \n");
25753 returnValue =
true;
25756 return returnValue;
25763 ROSE_ASSERT(return_type != NULL);
25764 ROSE_ASSERT(typeList != NULL);
25766 ROSE_ASSERT(fTable);
25771 SgFunctionType* funcType = isSgFunctionType(fTable->lookup_function_type(typeName));
25781 ROSE_ASSERT (lhs != NULL);
25782 ROSE_ASSERT (rhs != NULL);
25787 SgType* rt1 = lhs->get_return_type();
25788 SgType* rt2 = rhs->get_return_type();
25795 if (f1_arg_types.size() == f2_arg_types.size())
25799 size_t counter = 0;
25802 for (
size_t i=0; i< f1_arg_types.size(); i++)
25810 if (counter == f1_arg_types.size())
25832 ROSE_ASSERT(lhs != NULL);
25833 ROSE_ASSERT(rhs != NULL);
25835 bool isSame =
false;
25838 static int counter = 0;
25840 const SgType & X = *lhs;
25841 const SgType & Y = *rhs;
25849#define DEBUG_TYPE_EQUIVALENCE 0
25851#if DEBUG_TYPE_EQUIVALENCE
25852 printf (
"In SageInterface::isEquivalentType(): evaluation of type equivalence for lhs and rhs: counter = %d \n",counter);
25857#if DEBUG_TYPE_EQUIVALENCE || 0
25860 printf (
"In SageInterface::isEquivalentType(): evaluation of type equivalence for lhs and rhs: counter = %d \n",counter);
25866#if DEBUG_TYPE_EQUIVALENCE || 0
25872 printf (
"Output of type chain for lhs: \n");
25873 for (
size_t i = 0; i < X_typeChain.size(); i++)
25875 SgType* element_type = X_typeChain[i];
25876 printf (
"X_element_type = %p = %s \n",element_type,element_type->
class_name().c_str());
25877 printf (
" --- X_element_type unparseToString: = %s \n",element_type->
unparseToString().c_str());
25879 if (modifierType != NULL)
25883 printf (
" --- type chain modifier: %s \n",s.c_str());
25884 printf (
" --- type chain modifier: unparseToString: %s \n",modifierType->
unparseToString().c_str());
25888 printf (
"Output of type chain for rhs: \n");
25889 for (
size_t i = 0; i < Y_typeChain.size(); i++)
25891 SgType* element_type = Y_typeChain[i];
25892 printf (
"Y_element_type = %p = %s \n",element_type,element_type->
class_name().c_str());
25893 printf (
" --- Y_element_type unparseToString: = %s \n",element_type->
unparseToString().c_str());
25895 if (modifierType != NULL)
25899 printf (
" --- type chain modifier: %s \n",s.c_str());
25900 printf (
" --- type chain modifier: unparseToString: %s \n",modifierType->
unparseToString().c_str());
25911 if (counter >= 280)
25914 printf (
"In SageInterface::isEquivalentType(): counter = %d: type chain X_element_type = %s = %p Y_element_type = %s = %p \n",counter,X.
class_name().c_str(),lhs,Y.
class_name().c_str(),rhs);
25926 printf (
"ERROR: In SageInterface::isEquivalentType(): recursive limit exceeded for : counter = %d \n",counter);
25937 SgReferenceType* X_referenceType = isSgReferenceType(X_element_type);
25938 SgReferenceType* Y_referenceType = isSgReferenceType(Y_element_type);
25940 if (X_referenceType != NULL && Y_referenceType != NULL)
25942 X_element_type = X_referenceType->get_base_type();
25943 Y_element_type = Y_referenceType->get_base_type();
25954 SgPointerType* X_pointerType = isSgPointerType(X_element_type);
25955 SgPointerType* Y_pointerType = isSgPointerType(Y_element_type);
25957 if (X_pointerType != NULL && Y_pointerType != NULL)
25959 X_element_type = X_pointerType->get_base_type();
25960 Y_element_type = Y_pointerType->get_base_type();
25971 SgArrayType* X_arrayType = isSgArrayType(X_element_type);
25972 SgArrayType* Y_arrayType = isSgArrayType(Y_element_type);
25975 if (X_arrayType != NULL && Y_arrayType != NULL)
25977 X_element_type = X_arrayType->get_base_type();
25978 Y_element_type = Y_arrayType->get_base_type();
25980 SgExpression* X_array_index_expression = X_arrayType->get_index();
25981 SgExpression* Y_array_index_expression = Y_arrayType->get_index();
25983 if (X_array_index_expression == Y_array_index_expression)
25985#if DEBUG_TYPE_EQUIVALENCE || 0
25986 printf (
"In SageInterface::isEquivalentType(): counter = %d: Need to check the array size for static equivalence \n",counter);
25997#if DEBUG_TYPE_EQUIVALENCE || 0
25998 printf (
"In SageInterface::isEquivalentType(): counter = %d Need more complex test for expression equivalence \n",counter);
26001 printf (
" --- array index expressions: str1 = %s str2 = %s \n",str1.c_str(),str2.c_str());
26013 SgNonrealType* X_templateType = isSgNonrealType(X_element_type);
26014 SgNonrealType* Y_templateType = isSgNonrealType(Y_element_type);
26017 if (X_templateType != NULL && Y_templateType != NULL)
26019 string X_name = X_templateType->
get_name();
26020 string Y_name = Y_templateType->
get_name();
26022 SgNonrealDecl* X_templateDecl = isSgNonrealDecl(X_templateType->get_declaration());
26023 ROSE_ASSERT(X_templateDecl != NULL);
26024 SgNonrealDecl* Y_templateDecl = isSgNonrealDecl(Y_templateType->get_declaration());
26025 ROSE_ASSERT(Y_templateDecl != NULL);
26027 int X_template_parameter_position = X_templateDecl->get_template_parameter_position();
26028 int Y_template_parameter_position = Y_templateDecl->get_template_parameter_position();
26033#if DEBUG_TYPE_EQUIVALENCE
26036 printf (
"In SageInterface::isEquivalentType(): case SgNonrealType:\n");
26037 printf (
" -- X_name = %s Y_name = %s\n", X_name.c_str(),Y_name.c_str());
26038 printf (
" -- X_template_parameter_position = %d Y_template_parameter_position = %d\n", X_template_parameter_position,Y_template_parameter_position);
26039 printf (
" -- X_parent = %p (%s) Y_parent = %p (%s)\n", X_parent, X_parent ? X_parent->
class_name().c_str() :
"", Y_parent, Y_parent ? Y_parent->
class_name().c_str() :
"");
26040 printf (
" -- X_parent_parent = %p (%s) Y_parent_parent = %p (%s)\n", X_parent_parent, X_parent_parent ? X_parent_parent->
class_name().c_str() :
"", Y_parent_parent, Y_parent_parent ? Y_parent_parent->
class_name().c_str() :
"");
26041 printf (
" -- X_templateDecl->get_mangled_name() = %s\n", X_templateDecl->get_mangled_name().str());
26042 printf (
" -- Y_templateDecl->get_mangled_name() = %s\n", Y_templateDecl->get_mangled_name().str());
26044 bool value = (X_parent == Y_parent);
26046 if (value && X_templateDecl->get_is_template_param() && Y_templateDecl->get_is_template_param()) {
26047 value = (X_template_parameter_position == Y_template_parameter_position);
26048 }
else if (value && X_templateDecl->get_is_class_member() && Y_templateDecl->get_is_class_member()) {
26049 value = (X_name == Y_name);
26061 printf (
"Nothing to do here since we have explored all uniform pairs of intermediate types possible: isSame = %s \n",isSame ?
"true" :
"false");
26067#if DEBUG_TYPE_EQUIVALENCE
26068 printf (
"In SageInterface::isEquivalentType(): loop: Nothing to do here since we have explored all uniform pairs of intermediate types possible: isSame = %s \n",isSame ?
"true" :
"false");
26075 SgModifierType* X_modifierType = isSgModifierType(X_element_type);
26076 SgModifierType* Y_modifierType = isSgModifierType(Y_element_type);
26078#if DEBUG_TYPE_EQUIVALENCE
26079 printf (
"In SageInterface::isEquivalentType(): counter = %d: type chain X_element_type = %p = %s Y_element_type = %p = %s \n",
26080 counter,X_element_type,X_element_type->
class_name().c_str(),Y_element_type,Y_element_type->
class_name().c_str());
26083 if (X_modifierType != NULL && Y_modifierType != NULL)
26086#if DEBUG_TYPE_EQUIVALENCE
26087 printf (
"In SageInterface::isEquivalentType(): loop: these are the both SgModifierType nodes: isSame = %s \n",isSame ?
"true" :
"false");
26089 if (X_modifierType == Y_modifierType)
26092#if DEBUG_TYPE_EQUIVALENCE
26093 printf (
"In SageInterface::isEquivalentType(): loop: these are the same modifier type: isSame = %s \n",isSame ?
"true" :
"false");
26100#if DEBUG_TYPE_EQUIVALENCE
26101 printf (
"In SageInterface::isEquivalentType(): loop: these are equivalent modifiers: check the base type: isSame = %s \n",isSame ?
"true" :
"false");
26105 isSame =
isEquivalentType(X_modifierType->get_base_type(),Y_modifierType->get_base_type());
26109#if DEBUG_TYPE_EQUIVALENCE
26110 printf (
"In SageInterface::isEquivalentType(): loop: these are not equivalent modifier types: check for default settings: isSame = %s \n",isSame ?
"true" :
"false");
26113 bool skippingOverIdentityModifier =
false;
26117#if DEBUG_TYPE_EQUIVALENCE
26118 printf (
"In SageInterface::isEquivalentType(): loop: found self-similar setting for lhs: isSame = %s \n",isSame ?
"true" :
"false");
26120 X_element_type = X_modifierType->get_base_type();
26123 skippingOverIdentityModifier =
true;
26128#if DEBUG_TYPE_EQUIVALENCE
26129 printf (
"In SageInterface::isEquivalentType(): loop: found self-similar setting for rhs: isSame = %s \n",isSame ?
"true" :
"false");
26131 Y_element_type = Y_modifierType->get_base_type();
26134 skippingOverIdentityModifier =
true;
26138#if DEBUG_TYPE_EQUIVALENCE
26139 printf (
"In SageInterface::isEquivalentType(): loop: skippingOverIdentityModifier = %s \n",skippingOverIdentityModifier ?
"true" :
"false");
26144 if (skippingOverIdentityModifier ==
true)
26146#if DEBUG_TYPE_EQUIVALENCE
26147 printf (
"In SageInterface::isEquivalentType(): loop: recursive call on different adjusted modifier types: before recursive call to compare base types: isSame = %s \n",isSame ?
"true" :
"false");
26156#if DEBUG_TYPE_EQUIVALENCE
26157 printf (
"In SageInterface::isEquivalentType(): loop: no progress was made in resolving the base type, so returning isSame set to false: isSame = %s \n",isSame ?
"true" :
"false");
26161#if DEBUG_TYPE_EQUIVALENCE
26162 printf (
"In SageInterface::isEquivalentType(): loop: these are different modifier types: after recursive call to compare base types: isSame = %s \n",isSame ?
"true" :
"false");
26171 if (X_modifierType != NULL || Y_modifierType != NULL)
26173 bool isReduceable =
false;
26175 if (X_modifierType != NULL && X_modifierType->
get_typeModifier().isIdentity() ==
true)
26177#if DEBUG_TYPE_EQUIVALENCE
26178 printf (
"In SageInterface::isEquivalentType(): loop: found default setting for lhs: isSame = %s \n",isSame ?
"true" :
"false");
26180 X_element_type = X_modifierType->get_base_type();
26181 isReduceable =
true;
26184 if (Y_modifierType != NULL && Y_modifierType->
get_typeModifier().isIdentity() ==
true)
26186#if DEBUG_TYPE_EQUIVALENCE
26187 printf (
"In SageInterface::isEquivalentType(): loop: found default setting for rhs: isSame = %s \n",isSame ?
"true" :
"false");
26189 Y_element_type = Y_modifierType->get_base_type();
26190 isReduceable =
true;
26194#if DEBUG_TYPE_EQUIVALENCE
26195 printf (
"In SageInterface::isEquivalentType(): loop: these are different modifier types: after recursive call to compare base types: isReduceable = %s \n",isReduceable ?
"true" :
"false");
26197 if (isReduceable ==
true)
26209#if DEBUG_TYPE_EQUIVALENCE
26210 printf (
"In SageInterface::isEquivalentType(): loop: these are different modifier types: after recursive call to compare base types: isReduceable = %s isSame = %s \n",
26211 isReduceable ?
"true" :
"false",isSame ?
"true" :
"false");
26220 if (X_element_type == Y_element_type)
26223#if DEBUG_TYPE_EQUIVALENCE || 0
26225 printf (
"In SageInterface::isEquivalentType(): resolved to equal types: isSame = %s lhs = %p = %s rhs = %p = %s \n",
26228#if DEBUG_TYPE_EQUIVALENCE || 0
26231 const SgTypedefType* lhs_typedefType = isSgTypedefType(lhs);
26232 const SgTypedefType* rhs_typedefType = isSgTypedefType(rhs);
26234 if (lhs_typedefType != NULL || rhs_typedefType != NULL)
26237 if (lhs_typedefType != NULL)
26239 printf (
"lhs was a typedef: lhs = %p = %s \n",lhs,lhs->
unparseToString().c_str());
26241 if (rhs_typedefType != NULL)
26243 printf (
"rhs was a typedef: rhs = %p = %s \n",rhs,rhs->
unparseToString().c_str());
26246 printf (
" --- one was a typedef: lhs = %p = %s \n",lhs,lhs->
unparseToString().c_str());
26247 printf (
" --- one was a typedef: rhs = %p = %s \n",rhs,rhs->
unparseToString().c_str());
26258 SgReferenceType* X_referenceType = isSgReferenceType(X_element_type);
26259 SgReferenceType* Y_referenceType = isSgReferenceType(Y_element_type);
26261 if (X_referenceType != NULL || Y_referenceType != NULL)
26264 if (X_referenceType != NULL)
26266 X_element_type = X_referenceType->get_base_type();
26270 isReduceable =
false;
26273 if (Y_referenceType != NULL)
26275 Y_element_type = Y_referenceType->get_base_type();
26279 isReduceable =
false;
26282 if (isReduceable ==
true)
26303#if DEBUG_TYPE_EQUIVALENCE
26304 printf (
"In SageInterface::isEquivalentType(): loop: evaluation of inner types: isSame = %s \n",isSame ?
"true" :
"false");
26308 SgPointerType* X_pointerType = isSgPointerType(X_element_type);
26309 SgPointerType* Y_pointerType = isSgPointerType(Y_element_type);
26311 if (X_pointerType != NULL || Y_pointerType != NULL)
26314 if (X_pointerType != NULL)
26316 X_element_type = X_pointerType->get_base_type();
26320 isReduceable =
false;
26323 if (Y_pointerType != NULL)
26325 Y_element_type = Y_pointerType->get_base_type();
26329 isReduceable =
false;
26332 if (isReduceable ==
true)
26353#if DEBUG_TYPE_EQUIVALENCE
26354 printf (
"In SageInterface::isEquivalentType(): loop: evaluation of inner types: isSame = %s \n",isSame ?
"true" :
"false");
26358 SgArrayType* X_arrayType = isSgArrayType(X_element_type);
26359 SgArrayType* Y_arrayType = isSgArrayType(Y_element_type);
26361 if (X_arrayType != NULL || Y_arrayType != NULL)
26364 if (X_arrayType != NULL)
26366 X_element_type = X_arrayType->get_base_type();
26370 isReduceable =
false;
26373 if (Y_arrayType != NULL)
26375 Y_element_type = Y_arrayType->get_base_type();
26379 isReduceable =
false;
26382 if (isReduceable ==
true)
26403#if DEBUG_TYPE_EQUIVALENCE
26404 printf (
"In SageInterface::isEquivalentType(): loop: evaluation of inner types: isSame = %s \n",isSame ?
"true" :
"false");
26408 SgFunctionType* X_functionType = isSgFunctionType(X_element_type);
26409 SgFunctionType* Y_functionType = isSgFunctionType(Y_element_type);
26411 if (X_functionType != NULL || Y_functionType != NULL)
26413 bool value = ( (X_functionType != NULL && Y_functionType != NULL) && (X_functionType == Y_functionType) );
26416#if DEBUG_TYPE_EQUIVALENCE || 0
26417 printf (
"In SageInterface::isEquivalentType(): loop: Process case of SgFunctionType: value = %s \n",value ?
"true" :
"false");
26435 if (X_memberFunctionType != NULL || Y_memberFunctionType != NULL)
26438 printf (
"This should be unreachable code \n");
26442 bool value = ( (X_memberFunctionType != NULL && Y_memberFunctionType != NULL) && (X_memberFunctionType == Y_memberFunctionType) );
26443#if DEBUG_TYPE_EQUIVALENCE || 0
26444 printf (
"In SageInterface::isEquivalentType(): loop: Process case of SgMemberFunctionType: value = %s \n",value ?
"true" :
"false");
26457 bool X_isReduceable =
true;
26458 if (isSgTypeSignedLong(X_element_type) != NULL ||
26459 isSgTypeUnsignedInt(X_element_type) != NULL ||
26460 isSgTypeBool(X_element_type) != NULL ||
26461 isSgTypeInt(X_element_type) != NULL)
26463 X_isReduceable =
false;
26466 bool Y_isReduceable =
true;
26467 if (isSgTypeSignedLong(Y_element_type) != NULL ||
26468 isSgTypeUnsignedInt(Y_element_type) != NULL ||
26469 isSgTypeBool(Y_element_type) != NULL ||
26470 isSgTypeInt(Y_element_type) != NULL)
26472 Y_isReduceable =
false;
26474#if DEBUG_TYPE_EQUIVALENCE || 0
26475 printf (
"In SageInterface::isEquivalentType(): loop: Process default case: X_isReduceable = %s Y_isReduceable = %s \n",
26476 X_isReduceable ?
"true" :
"false",Y_isReduceable ?
"true" :
"false");
26478 if (X_isReduceable ==
true || Y_isReduceable ==
true)
26492#if DEBUG_TYPE_EQUIVALENCE || 0
26493 printf (
"In SageInterface::isEquivalentType(): loop: Process default case: X_element_type = %p = %s Y_element_type = %p = %s \n",
26494 X_element_type,X_element_type->
class_name().c_str(),Y_element_type,Y_element_type->
class_name().c_str());
26499 isSame = (X_element_type == Y_element_type);
26519#if DEBUG_TYPE_EQUIVALENCE || 0
26520 printf (
"In SageInterface::isEquivalentType(): isSame = %s \n",isSame ?
"true" :
"false");
26523#if DEBUG_TYPE_EQUIVALENCE || 0
26524 if (counter == 1 && isSame ==
true)
26526 printf (
"In SageInterface::isEquivalentType(): counter = %d: isSame = %s type chain X_element_type = %s Y_element_type = %s \n",counter,isSame ?
"true" :
"false",X.
class_name().c_str(),Y.
class_name().c_str());
26533 printf (
" --- Output of type chain for lhs: \n");
26534 for (
size_t i = 0; i < X_typeChain.size(); i++)
26536 SgType* element_type = X_typeChain[i];
26537 printf (
" --- --- X_element_type = %p = %s \n",element_type,element_type->
class_name().c_str());
26539 if (modifierType != NULL)
26543 printf (
" --- type chain modifier: %s \n",s.c_str());
26547 printf (
" --- Output of type chain for rhs: \n");
26548 for (
size_t i = 0; i < Y_typeChain.size(); i++)
26550 SgType* element_type = Y_typeChain[i];
26551 printf (
" --- --- Y_element_type = %p = %s \n",element_type,element_type->
class_name().c_str());
26553 if (modifierType != NULL)
26557 printf (
" --- --- type chain modifier: %s \n",s.c_str());
26566 if (isSame ==
true)
26569 printf (
" --- isSame = %s \n",isSame ?
"true" :
"false");
26572 printf (
" --- --- X_element_type = %p = %s = %s \n",X_element_type,X_element_type->
class_name().c_str(),X_element_type->
unparseToString().c_str());
26573 printf (
" --- --- Y_element_type = %p = %s = %s \n",Y_element_type,Y_element_type->
class_name().c_str(),Y_element_type->
unparseToString().c_str());
26578 printf (
" --- isSame = %s \n",isSame ?
"true" :
"false");
26583 printf (
" --- counter = %d \n",counter);
26600 bool retval =
false;
26609 retval = function->get_marked_as_edg_normalization();
26617 if (templateInstantiationFunction != NULL)
26622 if (templateFunctionDeclaration != NULL)
26633 printf (
" --- case of templateInstantiationFunction: retval = %s \n",retval ?
"true" :
"false");
26638 if (templateInstantiationMemberFunction != NULL)
26641 templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(templateInstantiationMemberFunction->
get_firstNondefiningDeclaration());
26643 if (templateMemberFunctionDeclaration != NULL)
26654 printf (
" --- case of templateInstantiationMemberFunction: retval = %s \n",retval ?
"true" :
"false");
26666 printf(
"In detectCycleInType():\n");
26667 printf(
" -- from = %s\n", from.c_str());
26668 printf(
" -- type = %p (%s)\n", type, type->
class_name().c_str());
26670 std::vector<SgType *> seen_types;
26672 while (type != NULL) {
26675 ROSE_ASSERT(type != NULL);
26677 std::vector<SgType *>::const_iterator it = std::find(seen_types.begin(), seen_types.end(), type);
26678 if (it != seen_types.end()) {
26679 printf(
"ERROR: Cycle found in type = %p (%s):\n", type, type->
class_name().c_str());
26681 for (; it != seen_types.end(); it++) {
26682 printf(
" [%zd] %p (%s)\n", i, *it, (*it)->class_name().c_str());
26685 printf(
"-> detectCycleInType() was called from: %s\n", from.c_str());
26688 seen_types.push_back(type);
26698 if (isSgPointerMemberType(type) != NULL)
26705 type = modType->get_base_type();
26706 }
else if ( refType ) {
26707 type = refType->get_base_type();
26708 }
else if ( pointType ) {
26709 type = pointType->get_base_type();
26712 }
else if ( arrayType ) {
26713 type = arrayType->get_base_type();
26714 }
else if ( typedefType ) {
26719 ROSE_ASSERT(type != NULL);
26740 std::vector<SgFunctionDeclaration*> functionList;
26743 string filenameWithPath;
26746 TransformFunctionDefinitionsTraversal(): sourceFile(NULL), sourceFileId(-99) {}
26748 void visit (
SgNode* node)
26751 printf (
"In convertFunctionDefinitionsToFunctionPrototypes visit(): node = %p = %s \n",node,node->
class_name().c_str());
26754 if (temp_sourceFile != NULL)
26756 sourceFile = temp_sourceFile;
26760 filenameWithPath = sourceFile->get_sourceFileNameWithPath();
26762 printf (
"Found source file: id = %d name = %s \n",sourceFileId,sourceFile->get_sourceFileNameWithPath().c_str());
26767 if (functionDeclaration != NULL)
26770 ROSE_ASSERT(sourceFile != NULL);
26773 if (functionDeclaration == definingFunctionDeclaration)
26776 printf (
"Found a defining function declaration: functionDeclaration = %p = %s name = %s \n",
26777 functionDeclaration,functionDeclaration->
class_name().c_str(),functionDeclaration->get_name().str());
26779 printf (
" --- recorded source file: id = %d name = %s \n",sourceFileId,sourceFile->get_sourceFileNameWithPath().c_str());
26780 printf (
" --- source file: file_info: id = %d name = %s \n",
26785 bool isInSourceFile = (filenameWithPath == functionDeclaration->
get_file_info()->get_filenameString());
26787 printf (
" --- isInSourceFile = %s \n",isInSourceFile ?
"true" :
"false");
26791 if (isInSourceFile ==
true && functionDeclarationScope != NULL)
26794 printf (
" --- Found a defining function declaration: functionDeclarationScope = %p = %s \n",
26795 functionDeclarationScope,functionDeclarationScope->
class_name().c_str());
26799 functionList.push_back(functionDeclaration);
26807 TransformFunctionDefinitionsTraversal traversal;
26808 traversal.traverse(node, preorder);
26810 std::vector<SgFunctionDeclaration*> & functionList = traversal.functionList;
26813 printf (
"In convertFunctionDefinitionsToFunctionPrototypes(): functionList.size() = %zu \n",functionList.size());
26816 std::vector<SgFunctionDeclaration*>::iterator i = functionList.begin();
26817 while (i != functionList.end())
26820 ROSE_ASSERT(functionDeclaration != NULL);
26823 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
26826 printf (
" --- Removing function declaration: functionDeclaration = %p = %s name = %s \n",
26827 functionDeclaration,functionDeclaration->
class_name().c_str(),functionDeclaration->get_name().str());
26837 printf (
"In convertFunctionDefinitionsToFunctionPrototypes(): exiting as a test! \n");
26848 ROSE_ASSERT(scope != NULL);
26850 printf (
"Output the statements in scope = %p = %s \n",scope,scope->
class_name().c_str());
26854 for (
size_t i = 0; i < statementList.size(); i++)
26861 printf (
"Exiting as a test at the end of evaluation of global scope! \n");
26874 printf (
"In SageInterface::buildFunctionPrototype(): functionDeclaration = %p = %s name = %s \n",
26875 functionDeclaration,functionDeclaration->
class_name().c_str(),functionDeclaration->get_name().str());
26879 bool isConstructor =
false;
26881 if (tmp_memberFunctionDeclaration != NULL)
26883 isConstructor = tmp_memberFunctionDeclaration->get_specialFunctionModifier().isConstructor();
26886 if (isConstructor ==
true)
26888 printf (
"Skipping case of constructors (in building prototype from defining function declaration) \n");
26898 SgName name = functionDeclaration->get_name();
26899 SgType* return_type = functionDeclaration->get_type()->get_return_type();
26907 printf (
"In SageInterface::buildFunctionPrototype(): functionDeclaration = %p \n",functionDeclaration);
26908 printf (
"In SageInterface::buildFunctionPrototype(): functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->
get_firstNondefiningDeclaration());
26909 printf (
"In SageInterface::buildFunctionPrototype(): functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->
get_definingDeclaration());
26913 for (
size_t i = 0; i < functionDeclaration->get_args().size(); i++)
26917 printf (
"In SageInterface::buildFunctionPrototype(): functionDeclaration->get_args(): (i = %zu) arg = %p = %s isDefaultArgument = %s \n",
26918 i,arg,arg->get_name().str(),arg->
get_file_info()->isDefaultArgument() ?
"true" :
"false");
26919 printf (
" --- arg->get_initializer() = %p \n",arg->get_initializer());
26923 printf (
"NOTE: default argument (i = %zu) not reproduced in function prototype: arg = %p = %s \n",i,arg,arg->get_name().str());
26936 if (templateInstantiationFunctionDecl == NULL)
26943 if (templateInstantiationMemberFunctionDecl == NULL)
26952 bool isTemplateInstantiationMemberFunctionDecl =
false;
26957 bool buildTemplateInstantiation =
false;
26958 SgTemplateArgumentPtrList* templateArgumentsList = NULL;
26963 ROSE_ASSERT(param_list == NULL || param_list->
get_parent() == NULL);
26965 switch (functionDeclaration->
variantT())
26967 case V_SgTemplateMemberFunctionDeclaration:
26970 printf (
"This function to replace the defining declaration with a non-defining declaration does not yet support template member functions \n");
26973 ROSE_ASSERT(original_templateMemberFunctionDeclaration != NULL);
26977 unsigned int functionConstVolatileFlags = 0;
26979 ROSE_ASSERT(original_templateMemberFunctionDeclaration->get_type() != NULL);
26984 SgMemberFunctionType* memberFunctionType = isSgMemberFunctionType(original_templateMemberFunctionDeclaration->get_type());
26985 ROSE_ASSERT(memberFunctionType != NULL);
26987 functionConstVolatileFlags = memberFunctionType->get_mfunc_specifier();
26993 SgTemplateParameterPtrList templateParameterList = original_templateMemberFunctionDeclaration->get_templateParameters();
26996 templateMemberFunctionDeclaration =
26999 printf (
"ERROR: Template functions are not yet supported! \n");
27002 nondefiningFunctionDeclaration = templateMemberFunctionDeclaration;
27004 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
27007 if (isConstructor ==
true)
27009 templateMemberFunctionDeclaration->get_specialFunctionModifier().setConstructor();
27015 case V_SgTemplateFunctionDeclaration:
27018 printf (
"This function to replace the defining declaration with a non-defining declaration does not yet support template functions \n");
27021 ROSE_ASSERT(original_templateFunctionDeclaration != NULL);
27029 SgTemplateParameterPtrList templateParameterList = original_templateFunctionDeclaration->get_templateParameters();
27033 printf (
"ERROR: Template functions are not yet supported! \n");
27036 nondefiningFunctionDeclaration = templateFunctionDeclaration;
27038 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
27044 case V_SgTemplateInstantiationMemberFunctionDecl:
27046 buildTemplateInstantiation =
true;
27048 isTemplateInstantiationMemberFunctionDecl =
true;
27051 ROSE_ASSERT(templateInstantiationMemberFunctionDecl != NULL);
27054 printf (
"name from functionDeclaration->get_name(): name = %s \n",name.str());
27056 printf (
"name from templateInstantiationMemberFunctionDecl->get_templateName(): template_name = %s \n",templateInstantiationMemberFunctionDecl->
get_templateName().str());
27058 if (templateDeclaration != NULL)
27060 printf (
"name from templateInstantiationMemberFunctionDecl->get_template_declaration()->get_name(): template_name = %s \n",templateDeclaration->get_name().str());
27061 printf (
"name from templateInstantiationMemberFunctionDecl->get_template_declaration()->get_template_name(): template_name = %s \n",templateDeclaration->
get_template_name().str());
27068 printf (
"In case V_SgTemplateInstantiationMemberFunctionDecl: using name = %s \n",name.str());
27073 case V_SgMemberFunctionDeclaration:
27076 printf (
"This function to replace the defining declaration with a non-defining declaration does not yet support member functions \n");
27079 ROSE_ASSERT(original_memberFunctionDeclaration != NULL);
27087 unsigned int functionConstVolatileFlags = 0;
27089 ROSE_ASSERT(original_memberFunctionDeclaration->get_type() != NULL);
27098 bool buildPrototype = isTemplateInstantiationMemberFunctionDecl || original_memberFunctionDeclaration->
get_parent() == original_memberFunctionDeclaration->
get_scope();
27100 printf (
"In SageInterface::buildFunctionPrototype(): buildPrototype = %s \n",buildPrototype ?
"true" :
"false");
27102 if (buildPrototype ==
true)
27104 SgMemberFunctionType* memberFunctionType = isSgMemberFunctionType(original_memberFunctionDeclaration->get_type());
27105 ROSE_ASSERT(memberFunctionType != NULL);
27107 printf (
"original_memberFunctionDeclaration->get_parent() == original_memberFunctionDeclaration->get_scope() \n");
27109 functionConstVolatileFlags = memberFunctionType->get_mfunc_specifier();
27111 memberFunctionDeclaration =
27113 ( name, return_type, param_list, scope, python_decoratorList, functionConstVolatileFlags,
27114 buildTemplateInstantiation,templateArgumentsList );
27116 printf (
"ERROR: Member functions are not yet supported! \n");
27120 if (isConstructor ==
true)
27122 memberFunctionDeclaration->get_specialFunctionModifier().setConstructor();
27125 nondefiningFunctionDeclaration = memberFunctionDeclaration;
27127 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
27133 printf (
"NOTE: Member functions defined outside of their class can not be output as member function prototypes (not allowed in C++) \n");
27137 nondefiningFunctionDeclaration = NULL;
27139 nondefiningFunctionDeclaration = NULL;
27141 replaceWithEmptyDeclaration =
true;
27143 ROSE_ASSERT(emptyDeclaration != NULL);
27152 printf (
"Exiting as a test! \n");
27162 case V_SgFunctionDeclaration:
27165 nondefiningFunctionDeclaration =
buildNondefiningFunctionDeclaration (name, return_type, param_list, scope, python_decoratorList, buildTemplateInstantiation,templateArgumentsList);
27166 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
27171 case V_SgTemplateInstantiationFunctionDecl:
27174 buildTemplateInstantiation =
true;
27176 ROSE_ASSERT(templateInstantiationFunctionDecl != NULL);
27179 printf (
"name from functionDeclaration->get_name(): name = %s \n",name.str());
27181 printf (
"name from templateInstantiationFunctionDecl->get_templateName(): template_name = %s \n",templateInstantiationFunctionDecl->
get_templateName().str());
27183 if (templateDeclaration != NULL)
27185 printf (
"name from templateInstantiationFunctionDecl->get_template_declaration()->get_name(): template_name = %s \n",templateDeclaration->get_name().str());
27186 printf (
"name from templateInstantiationFunctionDecl->get_template_declaration()->get_template_name(): template_name = %s \n",templateDeclaration->
get_template_name().str());
27191 printf (
"In case V_SgTemplateInstantiationFunctionDecl: using name = %s \n",name.str());
27193 nondefiningFunctionDeclaration =
buildNondefiningFunctionDeclaration (name, return_type, param_list, scope, python_decoratorList, buildTemplateInstantiation,templateArgumentsList);
27194 ROSE_ASSERT(nondefiningFunctionDeclaration != NULL);
27213 ROSE_ASSERT(param_list == NULL || param_list->
get_parent() != NULL);
27219 if (nondefiningFunctionDeclaration != NULL)
27224 printf (
"Setting the firstNondefiningDeclaration \n");
27232 printf (
"Setting the definingDeclaration \n");
27241 if (nondefiningFunctionDeclaration != NULL)
27251 return nondefiningFunctionDeclaration;
27260 ROSE_ASSERT(functionDeclaration != NULL);
27263 printf (
"****************************************************************** \n");
27264 printf (
"Attached comments and CPP directives: defining functionDeclaration \n");
27266 printf (
"****************************************************************** \n");
27274 if (nondefiningFunctionDeclaration != NULL)
27285 if (templateInstantiationFunctionDecl == NULL)
27287 if (nondefiningFunctionDeclaration != NULL)
27290 nondefiningFunctionDeclaration->get_declarationModifier() = functionDeclaration->get_declarationModifier();
27293 nondefiningFunctionDeclaration->get_functionModifier() = functionDeclaration->get_functionModifier();
27294 nondefiningFunctionDeclaration->get_specialFunctionModifier() = functionDeclaration->get_specialFunctionModifier();
27296 nondefiningFunctionDeclaration->set_linkage( functionDeclaration->get_linkage() );
27297 nondefiningFunctionDeclaration->set_externBrace( functionDeclaration->get_externBrace() );
27299 ROSE_ASSERT(nondefiningFunctionDeclaration->get_forward() ==
true);
27302 int file_id = functionDeclaration->
get_file_info()->get_physical_file_id();
27303 nondefiningFunctionDeclaration->
get_file_info()->set_physical_file_id(file_id);
27319 ROSE_ASSERT(nondefiningFunctionDeclaration->
get_parent() != NULL);
27325 nondefiningFunctionDeclaration = NULL;
27329 if (functionDeclaration->get_declarationModifier().get_storageModifier().
isStatic() ==
true)
27331 ROSE_ASSERT(nondefiningFunctionDeclaration->get_declarationModifier().get_storageModifier().
isStatic() ==
true);
27335 return nondefiningFunctionDeclaration;
27339std::vector<SgFunctionDeclaration*>
27351 std::vector<SgFunctionDeclaration*> functionList;
27352 FunctionDefinitionsTraversal() {}
27354 void visit (
SgNode* node)
27357 if (functionDeclaration != NULL)
27363 if (functionDeclaration == definingFunctionDeclaration)
27367 if (functionDeclarationScope != NULL)
27369 functionList.push_back(functionDeclaration);
27377 FunctionDefinitionsTraversal traversal;
27379 traversal.traverseWithinFile(node, preorder);
27381 std::vector<SgFunctionDeclaration*> & functionList = traversal.functionList;
27383 return functionList;
27390 ROSE_ASSERT(node != NULL);
27393 std::vector<SgFunctionDeclaration*>::iterator i = functionList.begin();
27395 while (i != functionList.end())
27398 ROSE_ASSERT(functionDeclaration != NULL);
27416 ROSE_ASSERT(node !=
nullptr);
27422 void visit (
SgNode* node)
27425 if (variableDeclaration != NULL)
27428 SgExpression* initializer = initializedName->get_initializer();
27430 printf (
"variableDeclaration = %p initializedName = %p = %s initializer = %p \n",
27431 variableDeclaration,initializedName,initializedName->get_name().str(),initializer);
27433 if (initializer != NULL)
27435 printf (
" --- initializer = %s \n",initializer->
class_name().c_str());
27442 CheckInitializerTraversal traversal;
27443 traversal.traverse(node, preorder);
27451 void setResult(
SgType*) { }
27453 void handle(
SgNode& n,
SgNode&) { SG_UNEXPECTED_NODE(n); }
27455 template <
class SageDeclarationStatement>
27461 setResult(n.get_type());
27464 template <
class SageNode>
27465 void handle(SageNode& n)
27478 SgGlobal * gsaf = project->get_globalScopeAcrossFiles();
27479 ROSE_ASSERT(gsaf !=
nullptr);
27481 ROSE_ASSERT(st !=
nullptr);
27483 ROSE_ASSERT(hmm !=
nullptr);
27487 ROSE_ASSERT(st !=
nullptr);
27488 hmm = st->get_table();
27489 ROSE_ASSERT(hmm !=
nullptr);
27493 ROSE_ASSERT(st !=
nullptr);
27494 hmm = st->get_table();
27495 ROSE_ASSERT(hmm !=
nullptr);
27515 int match_count = 0;
27516 ROSE_ASSERT (root);
27520 Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(root, V_SgArrowExp);
27524 boost::unordered::unordered_map <SgNode*, bool> visited;
27527 for (Rose_STL_Container<SgNode *>::reverse_iterator i = nodeList.rbegin(); i != nodeList.rend(); i++)
27530 if (visited.count(*i)==1)
27539 cerr<<
"SageInterface::normalizeArrowExpWithAddressOfLeftOperand() expects SgArrowExp while encountering "<<(*i)->class_name()<<
"@"<<(*i) <<endl;
27540 ROSE_ASSERT (a_exp);
27543 if (transformationGeneratedOnly)
27551 if (
SgVarRefExp* left = isSgVarRefExp(address_op->get_operand()))
27564 return match_count;
27574 Traversal() : found(
false) {}
27575 void visit (
SgNode* node)
27577 SgCastExp* castExpression = isSgCastExp(node);
27578 if (castExpression != NULL)
27582 if (initializer == NULL)
27587 printf (
" --- Found a SgCastExp marked as a transformation: castExpression = %p \n",castExpression);
27590 printf (
"Exiting as a test! \n");
27591 ROSE_ASSERT(
false);
27597 printf (
" --- SgCastExp (but not marked as a transformation) node = %p = %s \n",node,node->
class_name().c_str());
27605 printf (
" --- SgCastExp (but from an initializer) node = %p = %s \n",node,node->
class_name().c_str());
27612 printf (
" --- node = %p = %s \n",node,node->
class_name().c_str());
27619 printf (
"In findFirstSgCastExpMarkedAsTransformation(): s = %s \n",s.c_str());
27623 Traversal traversal;
27624 traversal.traverse(n, preorder);
27627 printf (
"In findFirstSgCastExpMarkedAsTransformation(): s = %s traversal.found = %s \n",s.c_str(),traversal.found ?
"true" :
"false");
27631 if (traversal.found ==
true)
27633 printf (
"In findFirstSgCastExpMarkedAsTransformation(): returning false \n");
27638 return traversal.found;
27649 ROSE_ASSERT (info != NULL);
27650 PreprocessingInfo::DirectiveType dtype= info->getTypeOfDirective();
27651 if (dtype == PreprocessingInfo::CpreprocessorIfdefDeclaration ||
27652 dtype == PreprocessingInfo::CpreprocessorIfndefDeclaration ||
27653 dtype == PreprocessingInfo::CpreprocessorIfDeclaration )
27657 else if (dtype==PreprocessingInfo::CpreprocessorElseDeclaration||
27658 dtype==PreprocessingInfo::CpreprocessorElifDeclaration)
27662 else if (dtype==PreprocessingInfo::CpreprocessorEndifDeclaration)
27671static void moveInofListToNewPlace(AttachedPreprocessingInfoType* infoList,
int cidx, set <AttachedPreprocessingInfoType*>& relatedInfoList,
SgLocatedNode* lnode,
int &retVal)
27676 relatedInfoList.insert (infoList);
27680 info->setRelativePosition(PreprocessingInfo::after);
27687 (*infoList)[cidx]= NULL;
27694 ROSE_ASSERT(lnode);
27700 vector < pair< AttachedPreprocessingInfoType*, int> > empty_entries;
27701 for(;ast_i!=ast.
end();++ast_i) {
27703 if (current ==NULL )
27707 if (infoList == NULL)
continue;
27709 int commentIndex=0;
27710 for (Rose_STL_Container<PreprocessingInfo*>::iterator ci = (*infoList).begin(); ci != (*infoList).end(); ci++)
27716 empty_entries.push_back( make_pair (infoList, commentIndex) );
27722 for (
auto ki = empty_entries.rbegin(); ki != empty_entries.rend(); ki ++)
27724 AttachedPreprocessingInfoType* infoList = (*ki).first;
27725 int cidx= (*ki).second;
27728 ROSE_ASSERT (info==NULL);
27731 AttachedPreprocessingInfoType::iterator k = infoList->begin();
27732 infoList->erase(k+cidx);
27742static std::unordered_map <PreprocessingInfo*, SageInterface::PreprocessingInfoData> infoMap;
27747 if (current == NULL)
27753 vector<PreprocessingInfo*> afterList;
27756 AttachedPreprocessingInfoType* comments = locatedNode->getAttachedPreprocessingInfo();
27758 if (comments !=
nullptr)
27760 AttachedPreprocessingInfoType::iterator i;
27762 for (i = comments->begin (); i != comments->end (); i++)
27768 data.container=comments;
27770 data.depth = depth;
27773 if (info->getRelativePosition () == PreprocessingInfo::before||
27774 info->getRelativePosition () == PreprocessingInfo::inside)
27776 infoList.push_back (info);
27777 infoMap[info] = data;
27779 else if (info->getRelativePosition () == PreprocessingInfo::after)
27781 afterList.push_back (info);
27782 infoMap[info] = data;
27786 cerr<<
"Warning: unhandled relative position value:" <<info->getRelativePosition () <<endl;
27797 for (
auto c: children)
27801 for (
auto fi : afterList)
27802 infoList.push_back(fi);
27816 ROSE_ASSERT(lnode);
27832 vector < pair< AttachedPreprocessingInfoType*, int> > keepers;
27836 unordered_map < PreprocessingInfo * , vector< pair<AttachedPreprocessingInfoType*, int>> > associated_directives;
27841 vector< pair<AttachedPreprocessingInfoType*, int>> associated_erase;
27849 vector<PreprocessingInfo*> candidateInfoList;
27854 for (
auto candidate: candidateInfoList)
27861 if (infoMap[info].depth ==0)
27864 int commentIndex = infoMap[info].index;
27865 AttachedPreprocessingInfoType* infoList = infoMap[info].container;
27868 if ( isBeginDirective(info) == 1)
27870 keepers.push_back(make_pair (infoList,commentIndex));
27873 else if (isBeginDirective(info) == 2)
27878 if (keepers.size()==0)
27879 keepers.push_back(make_pair (infoList, commentIndex));
27880 else if (isBeginDirective( (*(keepers.back().first))[keepers.back().second] )!=1 )
27882 keepers.push_back(make_pair (infoList,commentIndex));
27884 else if(isBeginDirective( (*(keepers.back().first))[keepers.back().second] )==1 )
27886 PreprocessingInfo* begin_info = (*(keepers.back().first))[keepers.back().second];
27888 associated_directives[begin_info].push_back(make_pair (infoList,commentIndex));
27892 else if ( isBeginDirective(info) == -1)
27894 bool neutralized =
false;
27896 if (keepers.size()>0)
27898 AttachedPreprocessingInfoType* comments = keepers.back().first;
27899 int idx = keepers.back().second;
27901 if(isBeginDirective( (*comments)[idx] )==1)
27903 keepers.pop_back();
27904 neutralized =
true;
27909 keepers.push_back(make_pair (infoList,commentIndex));
27917 for(;ast_i!=ast.
end();++ast_i) {
27919 if (current ==NULL )
27923 if (infoList == NULL)
continue;
27925 int commentIndex=0;
27926 for (Rose_STL_Container<PreprocessingInfo*>::iterator ci = (*infoList).begin(); ci != (*infoList).end(); ci++)
27928 ROSE_ASSERT(*ci != NULL);
27934 if ( isBeginDirective(info) == 1)
27936 keepers.push_back(make_pair (infoList,commentIndex));
27939 else if (isBeginDirective(info) == 2)
27944 if (keepers.size()==0)
27945 keepers.push_back(make_pair (infoList,commentIndex));
27946 else if (isBeginDirective( (*(keepers.back().first))[keepers.back().second] )!=1 )
27948 keepers.push_back(make_pair (infoList,commentIndex));
27950 else if(isBeginDirective( (*(keepers.back().first))[keepers.back().second] )==1 )
27952 PreprocessingInfo* begin_info = (*(keepers.back().first))[keepers.back().second];
27954 associated_directives[begin_info].push_back(make_pair (infoList,commentIndex));
27958 else if ( isBeginDirective(info) == -1)
27960 bool neutralized =
false;
27962 if (keepers.size()>0)
27964 AttachedPreprocessingInfoType* comments = keepers.back().first;
27965 int idx = keepers.back().second;
27967 if(isBeginDirective( (*comments)[idx] )==1)
27969 keepers.pop_back();
27970 neutralized =
true;
27975 keepers.push_back(make_pair (infoList,commentIndex));
27982 set <AttachedPreprocessingInfoType*> relatedInfoList;
27985 for (
auto ki = keepers.begin(); ki != keepers.end(); ki ++)
27987 AttachedPreprocessingInfoType* infoList = (*ki).first;
27988 int cidx= (*ki).second;
27990 relatedInfoList.insert (infoList);
27994 info->setRelativePosition(PreprocessingInfo::after);
28001 if (associated_directives.count (info)!=0)
28003 vector<pair<AttachedPreprocessingInfoType*,int>> a_list_vec = associated_directives[info];
28004 for (
auto vec_i = a_list_vec.rbegin(); vec_i != a_list_vec.rend(); vec_i ++ )
28006 AttachedPreprocessingInfoType* a_infoList = (*vec_i).first;
28007 int aidx= (*vec_i).second;
28008 moveInofListToNewPlace (a_infoList, aidx, relatedInfoList, lnode, retVal);
28009 associated_erase.push_back(make_pair (a_infoList, aidx));
28015 (*infoList)[cidx]= NULL;
to specify a construct using a specifier Can be used alone or with parent handles when relative speci...
virtual void * getNode() const
Get the raw IR node associated with the current abstract node.
Base class for all IR node attribute values.
Attribute Evaluator for synthesized attributes.
SynthesizedAttributeType traverse(SgNode *node)
evaluates attributes on the entire AST
Attribute storing an SgNode.
Class for traversing the AST.
void traverse(SgNode *node, Order treeTraversalOrder)
traverse the entire AST. Order defines preorder (preorder) or postorder (postorder) traversal....
void visit(SgNode *astNode)
this method is called at every traversed node.
void visit(SgNode *astNode)
visitor function for each node to collect non-builtin types' declarations
void visit(SgNode *astNode)
this method is called at every traversed node.
For preprocessing information including source comments, include , if, define, etc.
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code.
Interface for iterating over an AST.
iterator begin()
Iterator positioned at root of subtree.
iterator end()
Iterator positioned at the end of the traversal.
const Digest & digest() override
Return the digest.
void insert(const std::string &x)
Insert data into the digest.
uint64_t make64Bits()
Returns the hash as a 64 bit int.
void visit(SgNode *node)
this method is called at every traversed node.
Interface for creating a statement whose computation writes its answer into a given variable.
A persistent attribute to represent a unique name for an expression.
SgName get_name() const override
Access function for getting name from declarations or types internally.
Base class for binary files.
SgAsmGenericHeaderList *const & get_headers() const
Property: List of all headers in file.
SgAsmInterpretationPtrList const & get_interpretations() const
Property: Interpretation list.
Represents an interpretation of a binary container.
This class represents the concept of a C Assembler statement.
This class represents the rhs of a variable declaration which includes an optional assignment (e....
void set_operand(SgExpression *exp)
This sets the rhs expression.
SgExpression * get_operand() const
Returns the rhs.
This class represents the concept of a block (not a basic block from control flow analysis).
const SgStatementPtrList & get_statements() const
Returns a const STL list by reference.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
This class represents the notion of a binary operator. It is derived from a SgExpression because oper...
SgExpression * get_lhs_operand() const
returns SgExpression pointer to the lhs operand associated with this binary operator.
void set_rhs_operand(SgExpression *exp)
This function allows the p_rhs_operand pointer to be set (used internally).
void set_lhs_operand(SgExpression *exp)
This function allows the p_lhs_operand pointer to be set (used internally).
SgExpression * get_rhs_operand_i() const
returns SgExpression pointer to the operand associated with this binary operator.
SgExpression * get_lhs_operand_i() const
returns SgExpression pointer to the operand associated with this binary operator.
virtual VariantT variantT() const override
returns new style SageIII enum values
SgExpression * get_rhs_operand() const
returns SgExpression pointer to the rhs operand associated with this binary operator.
This class represents a boolean value (expression value).
This class represents the notion of a break statement (typically used in a switch statment).
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the concept of a C and C++ case option (used within a switch statement).
SgStatement * get_body() const
Returns pointer to a SgBasicBlock object.
void set_key(SgExpression *key)
Access function for pointer to SgExpression object wrapped by SgExpressionRoot in p_key_root.
void set_body(SgStatement *body)
Access function for p_body.
SgExpression * get_key() const
Returns pointer to a SgExpression object wrapped by SgExpressionRoot in p_key_root.
This class represents a cast of one type to another.
SgType * get_type() const override
unparsing support for pragmas
This class represents the concept of a catch within a try-catch construct used in C++ exception handl...
void set_body(SgStatement *body)
Access function for p_body.
SgStatement * get_body() const
Access function for p_body.
This class represents the concept of a class declaration statement. It includes the concept of an ins...
void set_scope(SgScopeStatement *scope) override
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
virtual std::string class_name() const override
returns a string representing the class name
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
SgScopeStatement * get_scope() const override
Returns scope of current statement.
This class represents the concept of a class definition in C++.
SgClassDeclaration * get_declaration() const
returns the class declaration associated with this class decinition.
const SgDeclarationStatementPtrList & get_members() const
Returns a const list to the data member declarations.
virtual std::string class_name() const override
returns a string representing the class name
This class represents the concept of a C++ expression built from a class name.
SgClassSymbol * get_symbol() const
Returns pointer to SgSymbol.
This class represents the concept of a class name within the compiler.
SgName get_name() const override
Access function for getting name from declarations or types internally.
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
static SgClassType * createType(SgDeclarationStatement *decl=NULL, SgExpression *optional_fortran_type_kind=NULL)
more sophisticated version for more complex types like SgClassType (types whose constructors take par...
This class represents the concept of a C trinary conditional expression (e.g. "test ?...
SgExpression * get_true_exp() const
Access function for p_true_exp.
void set_false_exp(SgExpression *false_exp)
Access function for p_false_exp.
SgExpression * get_conditional_exp() const
Access function for p_conditional_exp.
SgExpression * get_false_exp() const
Access function for p_false_exp.
void set_true_exp(SgExpression *true_exp)
Access function for p_true_exp.
void set_conditional_exp(SgExpression *conditional_exp)
Access function for p_conditional_exp.
This class represents the call of a class constructor to initialize a variable. For example "Foo foo;...
SgType * get_expression_type() const
Access function for p_expression_type, returns pointer to SgType associated with constructor.
This class represents the concept of a C or C++ continue statement.
Supporting class from copy mechanism within ROSE.
This class represents the concept of a contructor initializer list (used in constructor (member funct...
bool isFriend() const
declaration modifier is friend.
This class represents the concept of a declaration statement.
SgSymbol * search_for_symbol_from_symbol_table() const
User interface for retrieving the associated symbol from the declaration.
void set_definingDeclaration(SgDeclarationStatement *definingDeclaration)
This is an access function for the SgDeclarationStatement::p_definingDeclaration data member (see tha...
void set_firstNondefiningDeclaration(SgDeclarationStatement *firstNondefiningDeclaration)
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
SgDeclarationStatement * get_definingDeclaration() const
This is an access function for the SgDeclarationStatement::p_definingDeclaration data member (see tha...
virtual VariantT variantT() const override
returns new style SageIII enum values
virtual std::string class_name() const override
returns a string representing the class name
bool isForward() const
Returns boolean value indicating if this is a forward declaration.
SgDeclarationStatement * get_firstNondefiningDeclaration() const
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
bool hasAssociatedSymbol() const
Returns boolean value true of this type of declaration has an associated sysmbol.
SgName get_template_name() const
This function returns the template name (taken from the template declaration for the class,...
This class represents the concept of a C or C++ default case within a switch statement.
void set_body(SgStatement *body)
Access function for p_body.
SgStatement * get_body() const
Returns pointer to SgBasicBlock.
This class represents a directory within a projects file structure of files and directories.
This class represents the concept of a do-while statement.
SgStatement * get_condition() const
Access function for p_condition.
SgStatement * get_body() const
Access function for p_body.
void set_condition(SgStatement *condition)
Access function for p_condition.
void set_body(SgStatement *body)
Access function for p_body.
This class represents the notion of an value (expression value).
This class represents the concept of an enum declaration.
SgScopeStatement * get_scope() const override
Access function for p_scope.
SgName get_name() const
Access function for p_name.
void set_scope(SgScopeStatement *scope) override
Access function for p_scope.
const SgInitializedNamePtrList & get_enumerators() const
Access function for p_enumerators.
This class represents the concept of a C and C++ expression list.
int replace_expression(SgExpression *o, SgExpression *n) override
This class represents the base class of all the expressions within this grammar.
This class represents the concept of a C or C++ statement which contains a expression.
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
virtual std::string class_name() const override
returns a string representing the class name
void set_need_paren(bool need_paren)
This function allows the p_need_paren flag to be set (used internally).
virtual VariantT variantT() const override
returns new style SageIII enum values
virtual SgType * get_type() const
unparsing support for pragmas
virtual int replace_expression(SgExpression *oldChild, SgExpression *newChild)
This class represents the base class of all the expressions within this grammar.
virtual const char * sage_class_name() const override
virtual Sg_File_Info * get_file_info(void) const override
Interface function to implement original SAGE interface to SgFile_Info objects.
void set_lvalue(bool lvalue)
This function allows the p_lvalue flag to be set (used internally).
bool get_lvalue() const
Returns a bool value if the current expression is assigned to.
This class represents a source file for a project (which may contian many source files and or directo...
std::string getFileName() const
associated filename
Sg_File_Info * get_file_info() const override
Access function calling get_startOfConstruct(), provided to support older interface.
This class represents the notion of an value (expression value).
This class represents the variable declaration or variable initialization withn a for loop.
const SgStatementPtrList & get_init_stmt() const
Returns const reference to a SgStatementPtrList (typedef to a STL list).
This class represents the concept of a for loop.
SgExpression * get_test_expr() const
Access function for p_test_expr_root.
SgForInitStatement * get_for_init_stmt() const
Access function for p_for_init_stmt.
void set_loop_body(SgStatement *loop_body)
Access function for p_loop_body.
SgStatement * get_loop_body() const
Access function for p_loop_body.
void set_for_init_stmt(SgForInitStatement *for_init_stmt)
Access function for p_for_init_stmt.
This class represents the concept of a C++ function call (which is an expression).
SgFunctionSymbol * getAssociatedFunctionSymbol() const
Returns the associated function symbol, if it can be resolved statically.
SgFunctionDeclaration * getAssociatedFunctionDeclaration() const
Returns the associated function declaration, if it can be resolved statically.
virtual std::string class_name() const override
returns a string representing the class name
This class represents the concept of a function declaration statement.
SgScopeStatement * get_scope() const override
Returns scope of current statement.
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
bool isTemplateFunction() const
Determines if function is a template or non-template function.
void set_scope(SgScopeStatement *scope) override
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
virtual std::string class_name() const override
returns a string representing the class name
SgBasicBlock * get_body() const
Access function for p_body.
This class represents the concept of a declaration list.
const SgInitializedNamePtrList & get_args() const
Access function for p_args.
const SgTypePtrList & get_arguments() const
Get a const list of input types (types of the parameters list) to this function type (from a cost fun...
This class represents the function being called and must be assembled in the SgFunctionCall with the ...
SgFunctionDeclaration * getAssociatedFunctionDeclaration() const
Returns the associated function declaration, if it can be resolved statically.
SgName get_name() const override
Access function for getting name from declarations or types internally.
This class represents the function type table (stores all function types so that they can be shared i...
SgSymbolTable * get_function_type_table() const
Returns pointer to SgSymbolTable used for function type symbols only.
This class represents a type for all functions.
virtual std::string class_name() const override
returns a string representing the class name
const SgTypePtrList & get_arguments() const
This is a const convience access function to the STL container of types in the child IR node (SgFunct...
virtual SgName get_mangled(void) const override
Mangled name support for unparser support.
This class represents the concept of a namespace definition.
virtual std::string class_name() const override
returns a string representing the class name
const SgDeclarationStatementPtrList & get_declarations() const
Returns a const list to the global scope declarations.
This class represents the concept of a C or C++ goto statement.
SgLabelStatement * get_label() const
Returns pointer to SgLabelStatement where control flow will be transfered during execution.
void set_label(SgLabelStatement *label)
Access function for p_label.
InheritedAttributeType traverse(SgGraphNode *basenode, SgIncidenceDirectedGraph *g, InheritedAttributeType inheritedValue, InheritedAttributeType nullInherit, SgGraphNode *endnode, bool insep=false, bool pcHk=false)
This is the function that is used by the user directly to start the algorithm.
This class represents the concept of an "if" construct.
void set_false_body(SgStatement *false_body)
Access function for p_false_body.
virtual std::string class_name() const override
returns a string representing the class name
void set_true_body(SgStatement *true_body)
Access function for p_true_body.
SgStatement * get_conditional() const
Access function for p_conditional.
SgStatement * get_true_body() const
Access function for p_true_body.
SgStatement * get_false_body() const
Access function for p_false_body.
void set_conditional(SgStatement *conditional)
Access function for p_conditional.
This class represents the notion of a declared variable.
SgName get_qualified_name() const
Returns the name with appropriate qualified names representing nested scopes.
SgSymbol * get_symbol_from_symbol_table() const
Get the associated SgSymbol from the symbol table located in the scope, without considering possible ...
virtual std::string class_name() const override
returns a string representing the class name
SgDeclarationStatement * get_declaration() const
Equal operator : it checks if all the data members are the same or point to the same objects.
This class represents the notion of an initializer for a variable declaration or expression in a func...
This class represents the concept of a C or C++ label statement.
SgName get_label() const
Returns SgName by value.
SgScopeStatement * get_scope() const override
Returns scope of current statement.
void set_scope(SgScopeStatement *scope) override
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
label_type_enum
Type of label used (fortran only)
SgName get_name() const override
Access function for getting name from declarations or types internally.
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the notion of an expression or statement which has a position within the source...
virtual std::string class_name() const override
returns a string representing the class name
virtual const char * sage_class_name() const override
Sg_File_Info * get_endOfConstruct() const override
New function interface for Sg_File_Info data stores ending location of contruct (typically the closin...
void setTransformation()
Allow IR nodes (mostly SgLocatedNode) to be marked as a transformation.
virtual void addNewAttribute(std::string s, AstAttribute *a) override
Add a new attribute represented by the named string.
void set_endOfConstruct(Sg_File_Info *endOfConstruct)
This function sets the current source location position of the end of the current construct.
Sg_File_Info * get_startOfConstruct() const override
New function interface for Sg_File_Info data stores starting location of contruct (typically the open...
void addToAttachedPreprocessingInfo(PreprocessingInfo *prepInfoPtr, PreprocessingInfo::RelativePositionType locationInList=PreprocessingInfo::after)
This function adds comment or CPP directives to the current IR node.
virtual AstAttribute * getAttribute(std::string s) const override
Returns attribute of name 's'.
void set_startOfConstruct(Sg_File_Info *startOfConstruct)
This function sets the current source location position of the start of the current construct.
bool isCompilerGenerated() const
Simple test for if this is a compiler generated node.
void insertToAttachedPreprocessingInfo(PreprocessingInfo *prepInfoPtr, PreprocessingInfo *anchorInfoPtr, bool insertAfter=true)
Insert prepInfo After (or before if last parameter is false) an anchor info ptr in the list of prepro...
virtual VariantT variantT() const override
returns new style SageIII enum values
void setOutputInCodeGeneration()
Allow IR nodes (mostly SgLocatedNode) to be marked as to when the information was unavilable in the f...
virtual Sg_File_Info * get_file_info() const override
Interface function to implement original SAGE interface to SgFile_Info objects.
bool isTransformation() const
Simple test for if this is a part of a transformation.
AttachedPreprocessingInfoType *& getAttachedPreprocessingInfo(void)
Computes the number of nodes in the defined subtree of the AST.
This class represents the notion of an value (expression value).
This class represents the concept of a member function declaration statement.
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the member function being called and must be assembled in the SgFunctionCall wi...
SgMemberFunctionDeclaration * getAssociatedMemberFunctionDeclaration() const
This is helpful in chasing down the associated declaration to this member function reference.
SgName get_name() const override
Access function for getting name from declarations or types internally.
SgTypeModifier & get_typeModifier()
Access function for modifier.
This class represents strings within the IR nodes.
virtual SgName get_name() const
Gets name of the type (useful for debugging, unparsing, etc.)
SgName get_qualified_name() const
Used for the SgNamedType object (base class for the SgClassType, SgTypedefType and the SgEnumType obj...
This class represents the concept of a C++ namespace alias declaration statement.
SgName get_name() const
Access function for p_name.
SgNamespaceDeclarationStatement * get_namespaceDeclaration() const
Access function for p_namespaceDeclaration.
This class represents the concept of a C++ namespace declaration.
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
SgName get_name() const
Access function for p_name.
SgNamespaceDefinitionStatement * get_definition() const
Returns pointer to SgNamespaceDefinitionStatement.
This class represents the concept of a namespace definition.
This class represents the concept of a namespace name within the compiler.
This class represents the base class for all IR nodes within Sage III.
static SgTypeTable * get_globalTypeTable()
Access function for symbol table specific to non-function types.
virtual std::vector< std::string > get_traversalSuccessorNamesContainer()
container of names of variables or container indices used used in the traversal to access AST success...
SgNode * get_parent() const
Access function for parent node.
void set_isModified(bool isModified)
All nodes in the AST contain a isModified flag used to track changes to the AST.
virtual VariantT variantT() const
returns new style SageIII enum values
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
virtual std::string unparseToString(SgUnparse_Info *info) const
This function unparses the AST node (excluding comments and unnecessary white space)
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
virtual std::string class_name() const
returns a string representing the class name
static std::map< SgNode *, std::string > & get_globalMangledNameMap()
Access function for performance optimizing global mangled name map.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
virtual AstAttribute * getAttribute(std::string s) const
Returns attribute of name 's'.
static SgFunctionTypeTable * get_globalFunctionTypeTable()
Access function for symbol table specific to function types.
virtual Sg_File_Info * get_file_info(void) const
File information containing filename, line number, column number, and if the SgNode is a part of a ne...
virtual bool attributeExists(std::string s) const
Tests if attribute of name 's' is present.
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers() const
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
virtual void addNewAttribute(std::string s, AstAttribute *a)
Add a new attribute represented by the named string.
static std::map< std::string, uint64_t > & get_shortMangledNameCache()
Access function for lower level optimizing of global mangled name map.
bool get_isModified() const
Acess function for isModified flag.
SgName get_name() const override
Support for some classes which have pure virtual function in base classes.
This class represents the concept of a C Assembler statement (untested).
Sg_File_Info * get_startOfConstruct() const override
New function interface for Sg_File_Info data stores starting location of contruct (typically the open...
This class represents a source project, with a list of SgFile objects and global information about th...
std::vector< std::string > getAbsolutePathFileNames() const
This function generates a list of files resolved to absolute paths (symbolic links should not be reso...
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
static int get_verbose(void)
DQ: Modified to accept a value on the command line (no longer a boolean variable) value of 0 means qu...
This class represents a OLD concept of the structure require for qualified names when they were in th...
This class represents the concept of a C Assembler statement (untested).
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
bool supportsDefiningFunctionDeclaration()
Reports if scope can support defining function declarations. Not all scopes permit function declarati...
const SgStatementPtrList generateStatementList() const
Generate s list of statements from either the existing list of statements or the list of declarations...
bool isNamedScope()
Some scopes have associated names for purposed of name qualification. This returns true if the scope ...
SgSymbolTable * get_symbol_table() const
Returns a pointer to the locally strored SgSymbolTable.
virtual const char * sage_class_name() const override
SgDeclarationStatementPtrList & getDeclarationList()
Gets reference to internal STL list of pointers to SgDeclarationStatement objects (only defined for s...
SgStatementPtrList & getStatementList()
Gets reference to internal STL list of pointers to SgStatement objects (only defined for scopes conta...
void append_statement(SgStatement *stmt)
Higher level function to handle statements and declarations is scopes.
void set_symbol_table(SgSymbolTable *symbol_table)
Sets the pointer to the locally strored SgSymbolTable.
virtual std::string class_name() const override
returns a string representing the class name
bool statementExistsInScope(SgStatement *statement)
Test for existence of statement is scope.
bool containsOnlyDeclarations() const
This function is used to indicate if either the getDeclarationList() or getStatementList() can be cal...
void insert_symbol(const SgName &n, SgSymbol *s)
Puts a SgSymbol object into the local symbol table.
virtual VariantT variantT() const override
returns new style SageIII enum values
virtual SgName get_qualified_name() const
Returns SgName (a string) representing the name of the current scope.
This class represents the "sizeof()" operator (applied to any type).
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
This class represents the notion of a statement.
virtual std::string class_name() const override
returns a string representing the class name
void insert_statement(SgStatement *target, SgStatement *newstmt, bool inFront=true)
This function inserts a single statement at the position indicated by target.
virtual std::vector< SgNode * > get_traversalSuccessorContainer() override
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
virtual void set_scope(SgScopeStatement *newScope)
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
virtual bool hasExplicitScope() const
Support for where the scope is explicitly required.
virtual SgSymbol * get_symbol_from_symbol_table() const
Get the associated symbol from the symbol table in the stored scope.
virtual SgScopeStatement * get_scope(void) const
Returns scope of current statement.
void remove_statement(SgStatement *)
This function removes the target statement from the AST.
void replace_statement(SgStatement *target, SgStatement *newstmt)
This function replaces the target statement with a single statement.
virtual VariantT variantT() const override
returns new style SageIII enum values
bool isStatic() const
Storage modifier is static (always false for the SgStorageModifier in the SgInitializedName).
This class represents the base class of a numbr of IR nodes that don't otherwise fit into the existin...
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the concept of a switch.
void set_item_selector(SgStatement *item_selector)
Access function for p_item_selector.
SgStatement * get_body() const
Access function for p_body.
SgStatement * get_item_selector() const
Access function for p_item_selector_root.
void set_body(SgStatement *body)
Access function for p_body.
This class represents the symbol tables used in both SgScopeStatement and the SgFunctionTypeSymbolTab...
std::set< SgNode * > get_symbols() const
Complexity O(n)
void print(std::string label, VariantT nodeType=V_SgSymbol)
Outputs symbol table information (useful for debugging)
int size() const
Computes the number of symbols in the symbol table (forced to count them, I think,...
void remove(const SgSymbol *symbol)
Complexity O(n)
This class represents the concept of a name within the compiler.
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
virtual SgType * get_type() const =0
This function returns the type associated with the named entity.
This class represents template argument within the use of a template to build an instantiation.
SgExpression * get_expression() const
This function returns argumentExpression.
SgType * get_type() const
This function returns argumentType.
SgTemplateArgument::template_argument_enum get_argumentType() const
This function returns argumentType.
@ template_template_argument
@ start_of_pack_expansion_argument
This class represents the concept of a template declaration.
SgName get_string() const
Returns stringified template declaration.
virtual std::string class_name() const override
returns a string representing the class name
SgName get_name() const
Returns name of template declaration.
SgScopeStatement * get_scope() const override
Returns scope of current statement.
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the concept of an instantiated class template.
virtual std::string class_name() const override
returns a string representing the class name
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
SgName get_templateName() const
Returns name of class template, the name excludes template arguments.
SgTemplateClassDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
This class represents the concept of a class definition in C++.
This class represents the concept of a C++ template instantiation directive.
SgDeclarationStatement * get_declaration() const
Returns pointer to SgDeclarationStatement.
This class represents the concept of an instantiation of function template.
virtual std::string class_name() const override
returns a string representing the class name
const SgTemplateArgumentPtrList & get_templateArguments() const
Returns pointer to STL list of pointers to SgTemplateArgument objects.
SgTemplateFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
SgName get_templateName() const
Returns name of instantiated function template, name includes template arguments.
This class represents the concept of an instantiation of member function template or a member functio...
virtual std::string class_name() const override
returns a string representing the class name
const SgTemplateArgumentPtrList & get_templateArguments() const
Returns pointer to STL list of pointers to SgTemplateArgument objects.
SgName get_templateName() const
Returns name of instantiated function template, name includes template arguments.
SgTemplateMemberFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the "this" operator (can be applied to any member data).
Supporting class for "Deep" copies of the AST.
static SgTypeBool * createType(SgExpression *optional_fortran_type_kind=nullptr)
example of type used where construction is particularly simple
static SgTypeInt * createType(int sz=0, SgExpression *optional_fortran_type_kind=NULL)
more sophisticated version for more complex types like SgTypeInt (types whose constructors take param...
static SgTypeUnknown * createType(SgExpression *optional_fortran_type_kind=nullptr)
example of type used where construction is particularly simple
static SgTypeVoid * createType(SgExpression *optional_fortran_type_kind=nullptr)
example of type used where construction is particularly simple
This class represents the base class for all types.
std::vector< SgType * > getInternalTypes() const
Generate a container of types hidden in the input type.
SgType * stripType(unsigned char bit_array=STRIP_MODIFIER_TYPE|STRIP_REFERENCE_TYPE|STRIP_RVALUE_REFERENCE_TYPE|STRIP_POINTER_TYPE|STRIP_ARRAY_TYPE|STRIP_TYPEDEF_TYPE|STRIP_POINTER_MEMBER_TYPE) const
Returns hidden type beneath layers of typedefs, pointers, references, modifiers, array representation...
virtual std::string class_name() const override
returns a string representing the class name
virtual VariantT variantT() const override
returns new style SageIII enum values
This class represents the notion of a typedef declaration.
SgScopeStatement * get_scope() const override
Returns scope of current statement.
virtual SgSymbol * get_symbol_from_symbol_table() const override
FOR INTERNAL USE Get the associated symbol from the symbol table in the stored scope....
SgDeclarationStatement * get_baseTypeDefiningDeclaration() const
Returns the defining declaration if get_typedefBaseTypeContainsDefiningDeclaration() is true,...
void set_scope(SgScopeStatement *scope) override
Support for setting scopes (only meaningful on IR statements that store the scope explicitly).
SgType * get_base_type() const
This is used in the SgTypedefType object (is not associated with a base_type data field)
void set_operand_i(SgExpression *operand_i)
This function allows the p_operand_i pointer to be set (used internally).
SgExpression * get_operand() const
returns SgExpression pointer to the operand associated with this unary operator.
This class represents the concept of a C++ using declaration.
SgDeclarationStatement * get_declaration() const
Access function for p_declaration.
SgInitializedName * get_initializedName() const
Access function for p_initializedName.
This class represents the concept of a C++ using directive.
SgNamespaceDeclarationStatement * get_namespaceDeclaration() const
Access function for p_namespaceDeclaration.
This class represents the notion of an value (expression value).
virtual VariantT variantT() const override
returns new style SageIII enum values
virtual std::string class_name() const override
returns a string representing the class name
This class represents the variable refernece in expressions.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
This class represents the concept of a C or C++ variable declaration.
const SgInitializedNamePtrList & get_variables() const
Access function for p_variables.
SgDeclarationStatement * get_baseTypeDefiningDeclaration() const
Returns the defining declaration if get_variableDeclarationContainsBaseTypeDefiningDeclaration() is t...
bool get_variableDeclarationContainsBaseTypeDefiningDeclaration() const
Access function for p_variableDeclarationContainsBaseTypeDefiningDeclaration.
This class represents the definition (initialization) of a variable.
SgInitializedName * get_vardefn() const
Access function for SgInitializedName stored in p_vardefn.
This class represents the concept of a variable name within the compiler (a shared container for the ...
virtual std::string class_name() const override
returns a string representing the class name
SgName get_name() const override
Access function for getting name from declarations or types internally.
This class represents the concept of a do-while statement.
SgStatement * get_condition() const
Access function for p_condition.
void set_condition(SgStatement *condition)
Access function for p_condition.
SgStatement * get_body() const
Access function for p_body.
void set_body(SgStatement *body)
Access function for p_body.
This class represents the location of the code associated with the IR node in the original source cod...
void setTransformation()
Marks an IR node to be a transformation if it is not one already.
const char * get_filename() const
Returns filename of source code associated with IR node.
bool isOutputInCodeGeneration() const
Returns true only if required to be unparsed in generated code.
int get_line() const
Returns the line number of the associated code for this IR node.
bool isCompilerGenerated() const
Returns true only if compiler generated (either by the front-end or by ROSE).
int get_col() const
Returns the column number of the associated code for this IR node.
static Sg_File_Info * generateDefaultFileInfoForTransformationNode()
Static function to return new Sg_File_Info object set to default values appropriate for transformatio...
bool isTransformation() const
Access function for classification bit field.
bool isShared() const
Returns true only if shared internally (either by the front-end or by ROSE).
static Sg_File_Info * generateDefaultFileInfo()
Static function to return new Sg_File_Info object set to default values.
void setOutputInCodeGeneration()
Marks IR node as compiler generated but required in the generated source (e.g. requied templates).
Hash table support for symbol tables within ROSE.
ROSE_DLL_API abstract_handle * buildAbstractHandle(SgNode *snode)
A default builder function handles all details: file use name, others use numbering
ROSE_DLL_API std::vector< std::string > generateSourceFilenames(std::vector< std::string > argList, bool binaryMode)
Build the list of isolated file names from the command line.
ROSE_UTIL_API void removeAllFileNamesExcept(std::vector< std::string > &argv, std::vector< std::string > filenameList, std::string exceptFilename)
Remove file names specified in filenameList from argv, except for 'exceptFilename'.
void edgePointerReplacement(replacement_map_t const &)
For all nodes in the memory pool, it looks for the edges in the replacement map. If a match is found ...
ROSE_DLL_API std::string toBase62String(uint64_t num)
Converts a 64 bit in to base 62 (All letters and numbers).
ROSE_DLL_API Sawyer::Message::Facility mlog
Diagnostic facility for the ROSE library as a whole.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
ROSE_UTIL_API std::string stripFileSuffixFromFileName(const std::string &fileNameWithSuffix)
Get the file name without the ".suffix".
ROSE_UTIL_API std::string numberToString(long long)
Convert an integer to a string.
ROSE_UTIL_API std::string copyEdit(const std::string &inputString, const std::string &oldToken, const std::string &newToken)
Replace all occurrences of a string with another string.
ROSE_UTIL_API std::string stripPathFromFileName(const std::string &fileNameWithPath)
Returns the last component of a path in a filesystem.
SgStatement * getPreviousStatement(SgStatement *targetStatement, bool climbOutScope=true)
Functions to move to SgStatement object in SAGE III later.
Functions that build an AST.
ROSE_DLL_API SgAddOp * buildAddOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgFunctionDeclaration * buildNondefiningFunctionDeclaration(const SgName &name, SgType *return_type, SgFunctionParameterList *parlist, SgScopeStatement *scope=NULL, SgExprListExp *decoratorList=NULL, bool buildTemplateInstantiation=false, SgTemplateArgumentPtrList *templateArgumentsList=NULL, SgStorageModifier::storage_modifier_enum sm=SgStorageModifier::e_default)
Build a prototype for a function, handle function type, symbol etc transparently.
SourcePositionClassification
intended to be a private member, don't access it directly. could be changed any time
@ e_sourcePosition_last
Specify as source position to be filled in as part of AST construction in the front-end.
@ e_sourcePositionNullPointers
Classify as compiler generated code (e.g. template instantiation).
@ e_sourcePositionCompilerGenerated
Classify as a transformation.
@ e_sourcePositionFrontendConstruction
Set pointers to Sg_File_Info objects to NULL.
@ e_sourcePositionDefault
Error value for enum.
@ e_sourcePositionTransformation
Default source position.
ROSE_DLL_API SgPragma * buildPragma(const std::string &name)
Build SgPragma.
ROSE_DLL_API SourcePositionClassification getSourcePositionClassificationMode()
Get the current source position classification (defines how IR nodes built by the SageBuilder interfa...
ROSE_DLL_API SgEqualityOp * buildEqualityOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgTemplateMemberFunctionDeclaration * buildNondefiningTemplateMemberFunctionDeclaration(const SgName &name, SgType *return_type, SgFunctionParameterList *parlist, SgScopeStatement *scope, SgExprListExp *decoratorList, unsigned int functionConstVolatileFlags, SgTemplateParameterPtrList *templateParameterList)
Build a variable declaration, handle symbol table transparently.
ROSE_DLL_API SgLabelStatement * buildLabelStatement(const SgName &name, SgStatement *stmt=NULL, SgScopeStatement *scope=NULL)
Build a label statement, name is the label's name. Handling label symbol and scope internally.
ROSE_DLL_API SgAddressOfOp * buildAddressOfOp(SgExpression *op=NULL)
ROSE_DLL_API SgTemplateFunctionDeclaration * buildNondefiningTemplateFunctionDeclaration(const SgName &name, SgType *return_type, SgFunctionParameterList *parlist, SgScopeStatement *scope=NULL, SgExprListExp *decoratorList=NULL, SgTemplateParameterPtrList *templateParameterList=NULL)
Build a variable declaration, handle symbol table transparently.
ROSE_DLL_API SgMultiplyOp * buildMultiplyOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgGotoStatement * buildGotoStatement(SgLabelStatement *label=NULL)
Build a goto statement.
ROSE_DLL_API std::string display(SourcePositionClassification &scp)
display function for debugging
ROSE_DLL_API SgLabelRefExp * buildLabelRefExp(SgLabelSymbol *s)
Build a Fortran numeric label ref exp.
ROSE_DLL_API SgLessOrEqualOp * buildLessOrEqualOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgSubtractOp * buildSubtractOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgMemberFunctionType * buildMemberFunctionType(SgType *return_type, SgFunctionParameterTypeList *typeList, SgScopeStatement *struct_name, unsigned int mfunc_specifier)
Built in simple types.
ROSE_DLL_API SgWhileStmt * buildWhileStmt(SgStatement *condition, SgStatement *body, SgStatement *else_body=NULL)
Build while statement.
ROSE_DLL_API SgForStatement * buildForStatement(SgStatement *initialize_stmt, SgStatement *test, SgExpression *increment, SgStatement *loop_body, SgStatement *else_body=NULL)
Build a for statement, assume none of the arguments is NULL.
ROSE_DLL_API SgEmptyDeclaration * buildEmptyDeclaration()
Build an empty declaration (useful for adding precission to comments and CPP handling under token-bas...
ROSE_DLL_API SgConditionalExp * buildConditionalExp(SgExpression *test=NULL, SgExpression *a=NULL, SgExpression *b=NULL)
Build a conditional expression ?:
ROSE_DLL_API SgTypeInt * buildIntType()
Built in simple types.
SourcePositionClassification SourcePositionClassificationMode
C++ SageBuilder namespace specific state for storage of the source code position state (used to contr...
ROSE_DLL_API SgMinusOp * buildMinusOp(SgExpression *op=NULL)
ROSE_DLL_API SgExprListExp * buildExprListExp(SgExpression *expr1=NULL, SgExpression *expr2=NULL, SgExpression *expr3=NULL, SgExpression *expr4=NULL, SgExpression *expr5=NULL, SgExpression *expr6=NULL, SgExpression *expr7=NULL, SgExpression *expr8=NULL, SgExpression *expr9=NULL, SgExpression *expr10=NULL)
Build a SgExprListExp, used for function call parameter list etc.
ROSE_DLL_API SgPlusAssignOp * buildPlusAssignOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgVarRefExp * buildVarRefExp(const SgName &name, SgScopeStatement *scope=NULL)
Build SgVarRefExp based on a variable's Sage name. It will lookup the name in the symbol table intern...
bool symbol_table_case_insensitive_semantics
Support for construction of case sensitive/insensitive symbol table handling in scopes.
ROSE_DLL_API SgDotExp * buildDotExp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgAssignInitializer * buildAssignInitializer(SgExpression *operand_i=NULL, SgType *expression_type=NULL)
Build the rhs of a variable declaration which includes an assignment.
ROSE_DLL_API SgArrayType * getUniqueJavaArrayType(SgType *, int)
Build a SgFile node and attach it to SgProject.
ROSE_DLL_API SgVariableDeclaration * buildVariableDeclaration(const SgName &name, SgType *type, SgInitializer *varInit=NULL, SgScopeStatement *scope=NULL)
Build a variable declaration, handle symbol table transparently.
ROSE_DLL_API SgScopeStatement * topScopeStack()
intended to be a private member, don't access it directly. could be changed any time
ROSE_DLL_API SgNullExpression * buildNullExpression()
Build a null expression, set file info as the default one.
ROSE_DLL_API SgGreaterOrEqualOp * buildGreaterOrEqualOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgReferenceType * buildReferenceType(SgType *base_type=nullptr)
Build a reference type.
ROSE_DLL_API SgExprStatement * buildExprStatement(SgExpression *exp=NULL)
Build a SgExprStatement, set File_Info automatically.
ROSE_DLL_API SgIfStmt * buildIfStmt(SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
Build if statement.
ROSE_DLL_API SgFunctionParameterList * buildFunctionParameterList(SgInitializedName *in1=NULL, SgInitializedName *in2=NULL, SgInitializedName *in3=NULL, SgInitializedName *in4=NULL, SgInitializedName *in5=NULL, SgInitializedName *in6=NULL, SgInitializedName *in7=NULL, SgInitializedName *in8=NULL, SgInitializedName *in9=NULL, SgInitializedName *in10=NULL)
Build an empty SgFunctionParameterList, possibly with some initialized names filled in.
ROSE_DLL_API SgPointerDerefExp * buildPointerDerefExp(SgExpression *op=NULL)
ROSE_DLL_API SgTypeBool * buildBoolType()
Built in simple types.
ROSE_DLL_API SgAssignOp * buildAssignOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgPointerType * buildPointerType(SgType *base_type=nullptr)
Build a pointer type.
ROSE_DLL_API SgBoolValExp * buildBoolValExp(int value=0)
Build a bool value expression, the name convention of SgBoolValExp is little different from others fo...
ROSE_DLL_API SgFunctionParameterTypeList * buildFunctionParameterTypeList(SgFunctionParameterList *paralist)
Build SgFunctionParameterTypeList from SgFunctionParameterList.
ROSE_DLL_API SgLessThanOp * buildLessThanOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgCastExp * buildCastExp(SgExpression *operand_i=NULL, SgType *expression_type=NULL, SgCastExp::cast_type_enum cast_type=SgCastExp::e_C_style_cast)
Build a type casting expression.
ROSE_DLL_API SgMinusAssignOp * buildMinusAssignOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgDivideOp * buildDivideOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgBasicBlock * buildBasicBlock(SgStatement *stmt1=NULL, SgStatement *stmt2=NULL, SgStatement *stmt3=NULL, SgStatement *stmt4=NULL, SgStatement *stmt5=NULL, SgStatement *stmt6=NULL, SgStatement *stmt7=NULL, SgStatement *stmt8=NULL, SgStatement *stmt9=NULL, SgStatement *stmt10=NULL)
Build a SgBasicBlock, setting file info internally.
ROSE_DLL_API SgModOp * buildModOp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgExprStatement * buildAssignStatement(SgExpression *lhs, SgExpression *rhs)
Build an assignment statement from lefthand operand and right hand operand.
ROSE_DLL_API SgMemberFunctionDeclaration * buildNondefiningMemberFunctionDeclaration(const SgName &name, SgType *return_type, SgFunctionParameterList *parlist, SgScopeStatement *scope, SgExprListExp *decoratorList, unsigned int functionConstVolatileFlags, bool buildTemplateInstantiation, SgTemplateArgumentPtrList *templateArgumentsList)
Build a prototype member function declaration.
ROSE_DLL_API SgMemberFunctionDeclaration * buildDefaultConstructor(SgClassType *classType)
Build a variable declaration, handle symbol table transparently.
ROSE_DLL_API SgCommaOpExp * buildCommaOpExp(SgExpression *lhs=NULL, SgExpression *rhs=NULL)
ROSE_DLL_API SgIntVal * buildIntVal(int value=0)
Build an integer value expression.
SgDeclarationStatement * associatedDeclaration(const SgSymbol &n)
returns the associated declaration for symbol n or nullptr if there is none.
Functions that are useful when operating on the AST.
ROSE_DLL_API void checkSgNodePointers()
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool isLastStatement(SgStatement *stmt)
Check if a statement is the last statement within its closed scope.
ROSE_DLL_API bool isUnionDeclaration(SgNode *node)
Check if a SgNode is a declaration for a union.
ROSE_DLL_API void translateScopeToUseCppDeclarations(SgScopeStatement *scope)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
void initializeIfStmt(SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
Support function used for variable declarations in conditionals.
ROSE_DLL_API void deepDelete(SgNode *root)
Deep delete a sub AST tree. It uses postorder traversal to delete each child node....
void annotateExpressionsWithUniqueNames(SgProject *project)
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttri...
ROSE_DLL_API bool hasMultipleInitStatmentsOrExpressions(SgForStatement *for_loop)
Check if a for loop uses C99 style initialization statement with multiple expressions like for (int i...
ROSE_DLL_API void fixNamespaceDeclaration(SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
void serialize(SgNode *node, std::string &prefix, bool hasRemaining, std::ostringstream &out, std::string &edgeLabel)
we have two serialize() functions, one for a single node, the other for a list of pointers
ROSE_DLL_API void deleteExpressionTreeWithOriginalExpressionSubtrees(SgNode *root)
Special purpose function for deleting AST expression tress containing valid original expression trees...
void setSourcePositionAsTransformation(SgNode *node)
DQ (5/1/2012): New function with improved name.
ROSE_DLL_API void insertStatementList(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts, bool insertBefore=true)
Insert a list of statements before or after the target statement within the.
void whereAmI(SgNode *node)
Diagnostic function for tracing back through the parent list to understand at runtime where in the AS...
ROSE_DLL_API SgStatement * getLastStatement(SgScopeStatement *scope)
get the last statement within a scope, return NULL if it does not exit
ROSE_DLL_API void addStepToLoopBody(SgScopeStatement *loopStmt, SgStatement *step)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API bool is_UPC_dynamic_threads()
ROSE_DLL_API SgFunctionDeclaration * getFunctionDeclaration(SgFunctionCallExp *functionCallExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool is_mixed_Fortran_and_C_language()
ROSE_DLL_API void addTextForUnparser(SgNode *astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation)
Add a string to be unparsed to support code generation for back-end specific tools or compilers.
ROSE_DLL_API std::string getTempDirectory(SgProject *project)
Create a temporary directory if it does not yet exist and return its name.
ROSE_DLL_API void displayScope(SgScopeStatement *scope)
Find a node by type using upward traversal.
ROSE_DLL_API bool is_Jovial_language()
ROSE_DLL_API SgMemberFunctionDeclaration * findJavaMain(SgClassDefinition *)
Find a main method in a Java class.
ROSE_DLL_API bool is_Cxx_language()
void resetScopeNumbers(SgFunctionDefinition *functionDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
ROSE_DLL_API SgFunctionDeclaration * replaceDefiningFunctionDeclarationWithFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool hasSameGlobalScope(SgStatement *statement_1, SgStatement *statement_2)
This is supporting the recognition of functions in header files from two different ASTs.
SgCommaOpExp * insertBeforeUsingCommaOp(SgExpression *new_exp, SgExpression *anchor_exp)
Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects,...
ROSE_DLL_API void fixFunctionDeclaration(SgFunctionDeclaration *stmt, SgScopeStatement *scope)
Fix the symbol table and set scope (only if scope in declaration is not already set).
ROSE_DLL_API std::string preprocessImport(SgProject *, std::string)
Using the import_string parameter, create a file with the relevant import statement; translate the fi...
ROSE_DLL_API bool collectReadWriteRefs(SgStatement *stmt, std::vector< SgNode * > &readRefs, std::vector< SgNode * > &writeRefs, bool useCachedDefUse=false)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void prependStatementList(const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
prepend a list of statements to the beginning of the current scope, handling side effects as appropri...
ROSE_DLL_API SgInitializer * getInitializerOfExpression(SgExpression *n)
Get the initializer containing an expression if it is within an initializer.
ROSE_DLL_API std::vector< SgInitializedName * > getInParameters(const SgInitializedNamePtrList ¶ms)
Get a vector of Jovial input parameters from the function parameter list (may work for Fortran in the...
ROSE_DLL_API bool language_may_contain_nondeclarations_in_scope()
ROSE_DLL_API std::set< SgStatement * > collectTransformedStatements(SgNode *node)
This collects the statements that are marked as transformed (useful in debugging).
ROSE_DLL_API void cleanupNontransformedBasicBlockNode()
Remove unused basic block IR nodes added as part of normalization.
ROSE_DLL_API bool skipTranslateToUseCppDeclaration(PreprocessingInfo *currentPreprocessingInfo)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API AbstractHandle::abstract_handle * buildAbstractHandle(SgNode *)
Build an abstract handle from an AST node, reuse previously built handle when possible.
ROSE_DLL_API void insertStatementListBefore(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts)
Insert a list of statements before a target statement.
ROSE_DLL_API void fixStructDeclaration(SgClassDeclaration *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
void recursivePrintCurrentAndParent(SgNode *n)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API void appendExpressionList(SgExprListExp *, const std::vector< SgExpression * > &)
Append an expression list to a SgExprListExp, set the parent pointers also.
ROSE_DLL_API void collectReadOnlySymbols(SgStatement *stmt, std::set< SgVariableSymbol * > &readOnlySymbols, bool coarseGrain=true)
Collect read only variable symbols within a statement. The statement can be either of a function,...
bool isOverloaded(SgFunctionDeclaration *functionDeclaration)
Return true if function is overloaded.
ROSE_DLL_API int set_name(SgInitializedName *initializedNameNode, SgName new_name)
set_name of symbol in symbol table.
ROSE_DLL_API SgClassDefinition * findOrInsertJavaPackage(SgProject *, std::string, bool create_directory=false)
Process a qualified package name, if needed, and return its package definition.
ROSE_DLL_API SgClassDeclaration * findOrImportJavaClass(SgProject *, SgClassDefinition *package_definition, std::string)
If the class_name already exists in the scope, return it.
ROSE_DLL_API SgVariableSymbol * getFirstVarSym(SgVariableDeclaration *decl)
Get the variable symbol for the first initialized name of a declaration stmt.
ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument *arg1, SgTemplateArgument *arg2)
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declara...
ROSE_DLL_API SgFunctionDeclaration * findFirstDefiningFunctionDecl(SgScopeStatement *scope)
Find the first defining function declaration statement in a scope.
ROSE_DLL_API bool is_Jvm_language()
void addMessageStatement(SgStatement *stmt, std::string message)
Function to add "C" style comment to statement.
ROSE_DLL_API bool isLoopIndexVariable(SgInitializedName *ivar, SgNode *subtree_root)
Check if a SgInitializedName is used as a loop index within a AST subtree This function will use a bo...
SgInitializedName & getFirstVariable(SgVariableDeclaration &vardecl)
convenience function that returns the first initialized name in a list of variable declarations.
void initializeSwitchStatement(SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body)
Support function used for variable declarations in conditionals.
SgExprListExp * loopCollapsing(SgForStatement *target_loop, size_t collapsing_factor)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API void fixStatement(SgStatement *stmt, SgScopeStatement *scope)
A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(),...
ROSE_DLL_API SgStatement * copyStatement(SgStatement *s)
Deep copy a statement.
ROSE_DLL_API int eraseNullPreprocessingInfo(SgLocatedNode *lnode)
Dumps a located node's preprocessing information.
ROSE_DLL_API bool isCanonicalDoLoop(SgFortranDo *loop, SgInitializedName **ivar, SgExpression **lb, SgExpression **ub, SgExpression **step, SgStatement **body, bool *hasIncrementalIterationSpace, bool *isInclusiveUpperBound)
Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1.
SgCommaOpExp * insertAfterUsingCommaOp(SgExpression *new_exp, SgExpression *anchor_exp, SgStatement **temp_decl=NULL, SgVarRefExp **temp_ref=NULL)
Insert an expression (new_exp ) after another expression (anchor_exp) has possible side effects,...
ROSE_DLL_API SgTemplateVariableSymbol * lookupTemplateVariableSymbolInParentScopes(const SgName &name, SgTemplateParameterPtrList *tplparams, SgTemplateArgumentPtrList *tplargs, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API void moveUpPreprocessingInfo(SgStatement *stmt_dst, SgStatement *stmt_src, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false)
Identical to movePreprocessingInfo(), except for the stale name and confusing order of parameters....
ROSE_DLL_API SgStatement * lastStatementOfScopeWithTokenInfo(SgScopeStatement *scope, std::map< SgNode *, TokenStreamSequenceToNodeMapping * > &tokenStreamSequenceMap)
Used to support token unparsing (when the output the trailing token sequence).
ROSE_DLL_API void cutPreprocessingInfo(SgLocatedNode *src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &save_buf)
Cut preprocessing information from a source node and save it into a buffer. Used in combination of pa...
ROSE_DLL_API bool normalizeForLoopTest(SgForStatement *loop)
Normalize a for loop's test expression i<x is normalized to i<= (x-1) and i>x is normalized to i>= (x...
bool declarationPreceedsDefinition(SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration)
Check if a defining declaration comes before of after the non-defining declaration.
ROSE_DLL_API bool isSameFunction(SgFunctionDeclaration *func1, SgFunctionDeclaration *func2)
Check if two function declarations refer to the same one. Two function declarations are the same when...
std::vector< SgVariableSymbol * > getSymbolsUsedInExpression(SgExpression *expr)
Find referenced symbols within an expression.
ROSE_DLL_API bool isStructDeclaration(SgNode *node)
Check if a SgNode is a declaration for a structure.
ROSE_DLL_API void moveVariableDeclaration(SgVariableDeclaration *decl, SgScopeStatement *target_scope)
Move a variable declaration to a new scope, handle symbol, special scopes like For loop,...
ROSE_DLL_API std::string preprocessPackage(SgProject *, std::string)
Using the package_name, create a file with a package statement, translate it in order to load the pac...
ROSE_DLL_API void setOneSourcePositionForTransformation(SgNode *root)
Set current node's source position as transformation generated.
NodeType * deepCopy(const NodeType *subtree)
A template function for deep copying a subtree. It is also used to create deepcopy functions with spe...
void clearMangledNameCache(SgGlobal *globalScope)
Support for faster mangled name generation (caching avoids recomputation).
std::vector< SgStatement * > getSwitchCases(SgSwitchStatement *sw)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
ROSE_DLL_API bool isScalarType(SgType *t)
Is this a scalar type?
ROSE_DLL_API void changeBreakStatementsToGotos(SgStatement *loopOrSwitch)
If the given statement contains any break statements in its body, add a new label below the statement...
ROSE_DLL_API SgFunctionDefinition * getEnclosingFunctionDefinition(SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
ROSE_DLL_API bool is_CAF_language()
ROSE_DLL_API void printOutComments(SgLocatedNode *locatedNode)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void ReductionRecognition(SgForStatement *loop, std::set< std::pair< SgInitializedName *, OmpSupport::omp_construct_enum > > &results)
Recognize and collect reduction variables and operations within a C/C++ loop, following OpenMP 3....
ROSE_DLL_API bool loopUnrolling(SgForStatement *loop, size_t unrolling_factor)
Unroll a target loop with a specified unrolling factor. It handles steps larger than 1 and adds a fri...
ROSE_DLL_API void setLoopCondition(SgScopeStatement *loop, SgStatement *cond)
Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop.
bool ROSE_DLL_API isStatic(SgDeclarationStatement *stmt)
Check if a declaration has a "static' modifier.
PreprocessingInfo * attachComment(SgSourceFile *source_file, const std::string &content, PreprocessingInfo::DirectiveType directive_type=PreprocessingInfo::C_StyleComment, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before)
Build and attach comment onto the global scope of a source file.
ROSE_DLL_API SgClassDefinition * getEnclosingClassDefinition(SgNode *astnode, const bool includingSelf=false)
Get the closest class definition enclosing the specified AST node,.
ROSE_DLL_API bool mergeDeclarationAndAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt, bool removeAssignStmt=true)
Merge a variable assignment statement into a matching variable declaration statement....
ROSE_DLL_API void checkAccessPermissions(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API std::vector< SgFunctionDeclaration * > generateFunctionDefinitionsList(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API void replaceMacroCallsWithExpandedStrings(SgPragmaDeclaration *target)
Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the p...
std::string generateUniqueNameForUseAsIdentifier(SgDeclarationStatement *declaration)
Generate a useful name to support construction of identifiers from declarations.
ROSE_DLL_API bool isRestrictType(SgType *t)
Is this a restrict type?
ROSE_DLL_API std::string generateProjectName(const SgProject *project, bool supressSuffix=false)
Added mechanism to generate project name from list of file names.
ROSE_DLL_API void resetInternalMapsForTargetStatement(SgStatement *sourceStatement)
Reset internal data structures used for token-based unparsing and macro summaries based on modificati...
ROSE_DLL_API bool is_Cuda_language()
ROSE_DLL_API bool isLambdaCapturedVariable(SgVarRefExp *varRef)
check if a variable reference is this->a[i] inside of a lambda function
ROSE_DLL_API int instrumentEndOfFunction(SgFunctionDeclaration *func, SgStatement *s)
Instrument(Add a statement, often a function call) into a function right before the return points,...
ROSE_DLL_API SgInitializedName * getFirstInitializedName(SgVariableDeclaration *decl)
Get the first initialized name of a declaration statement.
void setSourcePositionPointersToNull(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfDoWhile(SgDoWhileStmt *ws)
Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API void reportModifiedStatements(const std::string &label, SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API std::vector< SgInitializedName * > getOutParameters(const SgInitializedNamePtrList ¶ms)
Get a vector of Jovial output parameters from the function parameter list (may work for Fortran in th...
ROSE_DLL_API void setSourcePositionForTransformation(SgNode *root)
Recursively set source position info(Sg_File_Info) as transformation generated.
ROSE_DLL_API SgGlobal * getGlobalScope(const SgNode *astNode)
Traverse back through a node's parents to find the enclosing global scope.
ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt)
Insert a list of statements after a target statement.
ROSE_DLL_API bool isMain(const SgNode *node)
Check if a SgNode is a main() function declaration.
std::map< std::string, int > local_name_collision_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration *classDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API int collectVariableReferencesInArrayTypes(SgLocatedNode *root, Rose_STL_Container< SgNode * > ¤tVarRefList)
Collect variable references in array types. The default NodeQuery::querySubTree() will miss variables...
SgBasicBlock * ensureBasicBlockAsBodyOfCaseOption(SgCaseOptionStmt *cs)
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.
void checkForInitializers(SgNode *node)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void removeUnusedLabels(SgNode *top, bool keepChild=false)
Remove labels which are not targets of any goto statements: its child statement is also removed by de...
ROSE_DLL_API SgProject * getProject()
Get the current SgProject IR Node.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfUpcForAll(SgUpcForAllStatement *fs)
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API SgClassDeclaration * getEnclosingClassDeclaration(SgNode *astNode)
Get the closest class declaration enclosing the specified AST node,.
ROSE_DLL_API void insertStatement(SgStatement *targetStmt, SgStatement *newStmt, bool insertBefore=true, bool autoMovePreprocessingInfo=true)
Insert a statement before or after the target statement within the target's scope....
ROSE_DLL_API void listHeaderFiles(SgIncludeFile *includeFile)
return path prefix for subtree of include files.
ROSE_DLL_API void markSubtreeToBeUnparsedTreeTraversal(SgNode *root, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
void saveToPDF(SgNode *node, std::string filename)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API bool normalizeForLoopInitDeclaration(SgForStatement *loop)
Normalize loop init stmt by promoting the single variable declaration statement outside of the for lo...
void detectCycleInType(SgType *type, const std::string &from)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void deleteAST(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool statementCanBeTransformed(SgStatement *stmt)
If header file unparsing and token-based unparsing are used, then some statements in header files use...
ROSE_DLL_API SgStatement * getNextStatement(SgStatement *currentStmt)
Get next statement within the same scope of current statement.
ROSE_DLL_API std::set< SgLabelStatement * > findUnusedLabels(SgNode *top)
Find unused labels which are not targets of any goto statements.
ROSE_DLL_API void setExtern(SgDeclarationStatement *stmt)
Set a declaration as extern.
ROSE_DLL_API void deleteAllNodes()
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList &list1, const SgTemplateArgumentPtrList &list2)
Verify that 2 SgTemplateArgumentPtrList are equivalent.
ROSE_DLL_API LivenessAnalysis * call_liveness_analysis(SgProject *project, bool debug=false)
Call liveness analysis on an entire project.
ROSE_DLL_API void reportModifiedLocatedNodes(const std::string &label, SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void fixTemplateDeclaration(SgTemplateDeclaration *stmt, SgScopeStatement *scope)
Fix the symbol table and set scope (only if scope in declaration is not already set).
SgType * getBoolType(SgNode *n)
Get the right bool type according to C or C++ language input.
void clearSharedGlobalScopes(SgProject *project)
Collect all read and write references within stmt, which can be a function, a scope statement,...
void initializeWhileStatement(SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body)
Support function used for variable declarations in conditionals.
ROSE_DLL_API void setSourcePosition(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API void setPragma(SgPragmaDeclaration *decl, SgPragma *pragma)
Set a pragma of a pragma declaration. handle memory release for preexisting pragma,...
ROSE_DLL_API void insertStatementListBeforeFirstNonDeclaration(const std::vector< SgStatement * > &newStmts, SgScopeStatement *scope)
Insert statements before the first non-declaration statement in a scope. If the scope has no non-decl...
ROSE_DLL_API bool isPostfixOperator(SgExpression *exp)
Is an overloaded operator a postfix operator. (e.g. ).
ROSE_DLL_API SgStatement * findSurroundingStatementFromSameFile(SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement)
Supporting function to comment relocation in insertStatement() and removeStatement().
SgNamespaceDefinitionStatement * enclosingNamespaceScope(SgDeclarationStatement *declaration)
Find the enclosing namespace of a declaration.
ROSE_DLL_API SgStatement * getLoopBody(SgScopeStatement *loop)
Routines to get and set the body of a loop.
ROSE_DLL_API bool is_mixed_C_and_Cxx_language()
bool isStructurallyEquivalentAST(SgNode *tree1, SgNode *tree2)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API PreprocessingInfo * insertHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader, bool asLastHeader)
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source f...
void printAST2TextFile(SgNode *node, const char *filename, bool printType=true)
Pretty print AST horizontally, output to a specified text file. If printType is set to false,...
ROSE_DLL_API SgFunctionSymbol * lookupTemplateFunctionSymbolInParentScopes(const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool is_language_case_insensitive()
ROSE_DLL_API void replaceStatement(SgStatement *oldStmt, SgStatement *newStmt, bool movePreprocessinInfo=false)
Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested...
ROSE_DLL_API void recordNormalizations(SgStatement *s)
Record where normalization have been done so that we can preform denormalizations as required for the...
ROSE_DLL_API bool loopInterchange(SgForStatement *loop, size_t depth, size_t lexicoOrder)
Interchange/permutate a n-level perfectly-nested loop rooted at 'loop' using a lexicographical order ...
void printAST(SgNode *node)
Pretty print AST horizontally, output to std output.
ROSE_DLL_API SgFunctionSymbol * lookupTemplateMemberFunctionSymbolInParentScopes(const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool is_PHP_language()
ROSE_DLL_API bool isEqualToIntConst(SgExpression *e, int value)
Check if a SgIntVal node has a given value.
ROSE_DLL_API void insertStatementBeforeFirstNonDeclaration(SgStatement *newStmt, SgScopeStatement *scope, bool movePreprocessingInfo=true)
Insert a statement before the first non-declaration statement in a scope. If the scope has no non-dec...
ROSE_DLL_API SgFunctionSymbol * lookupFunctionSymbolInParentScopes(const SgName &functionName, SgScopeStatement *currentScope=NULL)
look up the first matched function symbol in parent scopes given only a function name,...
ROSE_DLL_API void appendStatementWithDependentDeclaration(SgDeclarationStatement *decl, SgGlobal *scope, SgStatement *original_statement, bool excludeHeaderFiles)
Append a copy ('decl') of a function ('original_statement') into a 'scope', include any referenced de...
ROSE_DLL_API bool insideHeader(SgLocatedNode *node)
Check if a node is from a header file.
ROSE_DLL_API void markSubtreeToBeUnparsed(SgNode *root, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API bool isDataMemberReference(SgVarRefExp *varRefExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool collectReadWriteVariables(SgStatement *stmt, std::set< SgInitializedName * > &readVars, std::set< SgInitializedName * > &writeVars, bool coarseGrain=true)
Collect unique variables which are read or written within a statement. Note that a variable can be bo...
ROSE_DLL_API void constantFolding(SgNode *r)
Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values,...
std::vector< SgBreakStmt * > findBreakStmts(SgStatement *code, const std::string &fortranLabel="")
Find break statements inside a particular statement, stopping at nested loops or switches.
ROSE_DLL_API SgFile * getEnclosingFileNode(SgNode *astNode)
get the SgFile node from current node
ROSE_DLL_API void setStatic(SgDeclarationStatement *stmt)
Set a declaration as static.
ROSE_DLL_API bool doLoopNormalization(SgFortranDo *loop)
Normalize a Fortran Do loop. Make the default increment expression (1) explicit.
ROSE_DLL_API SgFile * preprocessCompilationUnit(SgProject *, std::string, std::string, bool unparse=true)
Using the file_content string, create a file with the content in question; build its AST and add it t...
ROSE_DLL_API void removeLabeledGotos(SgNode *top)
Remove labeled goto statements.
std::map< SgNode *, std::string > local_node_to_name_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
std::vector< SgGotoStatement * > findGotoStmts(SgStatement *scope, SgLabelStatement *l)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
ROSE_DLL_API bool mergeDeclarationWithAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt)
Merge a declaration statement into a matching followed variable assignment. Callers should make sure ...
ROSE_DLL_API bool isAssignmentStatement(SgNode *_s, SgExpression **lhs=NULL, SgExpression **rhs=NULL, bool *readlhs=NULL)
Check if a SgNode _s is an assignment statement (any of =,+=,-=,&=,/=, ^=, etc)
ROSE_DLL_API void outputSharedNodes(SgNode *node)
Find a node by type using upward traversal.
bool ROSE_DLL_API isAncestor(SgNode *node1, SgNode *node2)
check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor)
ROSE_DLL_API SgScopeStatement * getEnclosingScope(SgNode *n, const bool includingSelf=false)
Get the enclosing scope from a node n.
ROSE_DLL_API SgNonrealSymbol * lookupNonrealSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API SgSwitchStatement * findEnclosingSwitch(SgStatement *s)
Find the closest switch outside a given statement (normally used for case and default statements)
ROSE_DLL_API void removeAllOriginalExpressionTrees(SgNode *top)
Set original expression trees to NULL for SgValueExp or SgCastExp expressions, so you can change the ...
ROSE_DLL_API std::vector< SgNode * > astIntersection(SgNode *original, SgNode *copy, SgCopyHelp *help=NULL)
Compute the intersection set for two ASTs.
ROSE_DLL_API bool isPrefixOperator(SgExpression *exp)
Is an overloaded operator a prefix operator (e.g. address operator X * operator&(),...
ROSE_DLL_API void setLhsOperand(SgExpression *target, SgExpression *lhs)
set left hand operand for binary expressions, transparently downcasting target expressions when neces...
ROSE_DLL_API std::vector< SgC_PreprocessorDirectiveStatement * > translateStatementToUseCppDeclarations(SgStatement *statement, SgScopeStatement *scope)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API int suggestNextNumericLabel(SgFunctionDefinition *func_def)
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope.
ROSE_DLL_API std::set< SgStatement * > collectModifiedStatements(SgNode *node)
This collects the statements that are marked as modified (a flag automatically set by all set_* gener...
ROSE_DLL_API SgFunctionDeclaration * getEnclosingFunctionDeclaration(SgNode *astNode, const bool includingSelf=false)
Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStat...
SgFunctionDeclaration * findFunctionDeclaration(SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining)
Topdown traverse a subtree from root to find the first function declaration matching the given name,...
ROSE_DLL_API bool isPrefixOperatorName(const SgName &functionName)
Check for proper names of possible prefix operators (used in isPrefixOperator()).
ROSE_DLL_API void setLoopStride(SgNode *loop, SgExpression *stride)
Set the stride(step) of a loop 's incremental expression, regardless the expression types (i+=s; i= i...
ROSE_DLL_API bool isInSubTree(SgExpression *subtree, SgExpression *exp)
Find a node by type using upward traversal.
ROSE_DLL_API bool forLoopNormalization(SgForStatement *loop, bool foldConstant=true)
Normalize a for loop, return true if successful.
unsigned long long getIntegerConstantValue(SgValueExp *expr)
Get the constant value from a constant integer expression; abort on everything else.
ROSE_DLL_API bool is_UPC_language()
ROSE_DLL_API void checkSymbolTables(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API void updateDefiningNondefiningLinks(SgFunctionDeclaration *func, SgScopeStatement *scope)
Update defining and nondefining links due to a newly introduced function declaration....
ROSE_DLL_API SgNode * deepCopyNode(const SgNode *subtree)
Deep copy an arbitrary subtree.
SgBasicBlock * ensureBasicBlockAsBodyOfDefaultOption(SgDefaultOptionStmt *cs)
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API void getLiveVariables(LivenessAnalysis *liv, SgForStatement *loop, std::set< SgInitializedName * > &liveIns, std::set< SgInitializedName * > &liveOuts)
get liveIn and liveOut variables for a for loop from liveness analysis result liv.
ROSE_DLL_API void resetModifiedLocatedNodes(const std::set< SgLocatedNode * > &modifiedNodeSet)
Use the set of IR nodes and set the isModified flag in each IR node to true.
ROSE_DLL_API SgNode * replaceWithPattern(SgNode *anchor, SgNode *new_pattern)
Replace an anchor node with a specified pattern subtree with optional SgVariantExpression....
ROSE_DLL_API bool ROSE_DLL_API isJovialOutParam(SgInitializedName *name)
True if a parameter name is a Jovial output parameter.
ROSE_DLL_API void moveForStatementIncrementIntoBody(SgForStatement *f)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement *ompbodyStmt)
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool is_Python_language()
ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language()
ROSE_DLL_API SgStatement * getLoopCondition(SgScopeStatement *loop)
Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop.
ROSE_DLL_API SgEnumSymbol * lookupEnumSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
std::pair< SgVariableDeclaration *, SgExpression * > createTempVariableAndReferenceForExpression(SgExpression *expression, SgScopeStatement *scope)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API SgTypedefSymbol * lookupTypedefSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfWhile(SgWhileStmt *ws)
Check if the body of a 'while' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfFor(SgForStatement *fs)
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API PreprocessingInfo * attachArbitraryText(SgLocatedNode *target, const std::string &text, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before)
Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-s...
ROSE_DLL_API void markNodeToBeUnparsed(SgNode *node, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API bool isConstantTrue(SgExpression *e)
Check if a bool or int constant expression evaluates to be a true value.
std::map< std::string, SgNode * > local_name_to_node_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API bool is_binary_executable()
void changeAllBodiesToBlocks(SgNode *top, bool createEmptyBody=true)
Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components....
void dumpPreprocInfo(SgLocatedNode *locatedNode)
Dumps a located node's preprocessing information.
void fixupReferencesToSymbols(const SgScopeStatement *this_scope, SgScopeStatement *copy_scope, SgCopyHelp &help)
All the symbol table references in the copied AST need to be reset after rebuilding the copied scope'...
ROSE_DLL_API void moveDeclarationToAssociatedNamespace(SgDeclarationStatement *declarationStatement)
Relocate the declaration to be explicitly represented in its associated namespace (required for some ...
ROSE_DLL_API bool isCanonicalForLoop(SgNode *loop, SgInitializedName **ivar=NULL, SgExpression **lb=NULL, SgExpression **ub=NULL, SgExpression **step=NULL, SgStatement **body=NULL, bool *hasIncrementalIterationSpace=NULL, bool *isInclusiveUpperBound=NULL)
Check if a for-loop has a canonical form, return loop index, bounds, step, and body if requested.
ROSE_DLL_API bool isArrayReference(SgExpression *ref, SgExpression **arrayNameExp=NULL, std::vector< SgExpression * > **subscripts=NULL)
Check if an expression is an array access (SgPntrArrRefExp). If so, return its name expression and su...
ROSE_DLL_API void insertStatementAfterLastDeclaration(SgStatement *stmt, SgScopeStatement *scope)
Insert a statement after the last declaration within a scope. The statement will be prepended to the ...
ROSE_DLL_API void destroyTempDirectory(std::string)
Use the system command to remove a temporary directory and all its containing files.
void serialize_list(T &plist, std::string T_name, std::string &prefix, bool hasRemaining, std::ostringstream &out, std::string &edgeLabel)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
void resetMangledNameCache(SgGlobal *globalScope)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API SgTemplateInstantiationMemberFunctionDecl * buildForwardFunctionDeclaration(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Generate a non-defining (forward) declaration from a defining function declaration.
ROSE_DLL_API bool is_Fortran_language()
ROSE_DLL_API SgVariableSymbol * lookupVariableSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API void outputFileIds(SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API SgExprStatement * splitVariableDeclaration(SgVariableDeclaration *decl)
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignm...
ROSE_DLL_API SgStatement * getFirstStatement(SgScopeStatement *scope, bool includingCompilerGenerated=false)
Get the first statement within a scope, return NULL if it does not exist. Skip compiler-generated sta...
ROSE_DLL_API SgNamespaceSymbol * lookupNamespaceSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool isExtern(SgDeclarationStatement *stmt)
Check if a declaration has an "extern" modifier.
std::string extractPragmaKeyword(const SgPragmaDeclaration *)
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of...
ROSE_DLL_API SgTemplateClassSymbol * lookupTemplateClassSymbolInParentScopes(const SgName &name, SgTemplateParameterPtrList *templateParameterList, SgTemplateArgumentPtrList *templateArgumentList, SgScopeStatement *cscope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool isEquivalentFunctionType(const SgFunctionType *lhs, const SgFunctionType *rhs)
Test if two types are equivalent SgFunctionType nodes.
ROSE_DLL_API void setLoopLowerBound(SgNode *loop, SgExpression *lb)
Set the lower bound of a loop header for (i=lb; ...)
void guardNode(SgLocatedNode *target, std::string guard)
Add preproccessor guard around a given node.
bool checkTypesAreEqual(SgType *typeA, SgType *typeB)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool isReferenceType(SgType *t)
Is this type a const or non-const reference type? (Handles typedefs correctly)
ROSE_DLL_API void moveCommentsToNewStatement(SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *destinationStatement, bool destinationStatementPreceedsSourceStatement)
Relocate comments and CPP directives from one statement to another.
ROSE_DLL_API SgStatement * getEnclosingStatement(SgNode *n)
Find the closest enclosing statement, including the given node.
ROSE_DLL_API void translateToUseCppDeclarations(SgNode *n)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void changeContinuesToGotos(SgStatement *stmt, SgLabelStatement *label)
Change continue statements in a given block of code to gotos to a label.
void outputGlobalFunctionTypeSymbolTable()
Output function type symbols in global function type symbol table.
ROSE_DLL_API SgScopeStatement * findEnclosingLoop(SgStatement *s, const std::string &fortranLabel="", bool stopOnSwitches=false)
Find the closest loop outside the given statement; if fortranLabel is not empty, the Fortran label of...
std::pair< SgVariableDeclaration *, SgExpression * > createTempVariableForExpression(SgExpression *expression, SgScopeStatement *scope, bool initializeInDeclaration, SgAssignOp **reEvaluate=NULL)
Given an expression, generates a temporary variable whose initializer optionally evaluates that expre...
bool isBodyStatement(SgStatement *s)
Check if a statement is a (true or false) body of a container-like parent, such as For,...
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope(SgFunctionCallExp *functionCall)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API void convertAllForsToWhiles(SgNode *top)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API bool isConstantFalse(SgExpression *e)
Check if a bool or int constant expression evaluates to be a false value.
ROSE_DLL_API void outputLocalSymbolTables(SgNode *node)
Output the local symbol tables.
ROSE_DLL_API void preOrderCollectPreprocessingInfo(SgNode *current, std::vector< PreprocessingInfo * > &infoList, int depth)
Dumps a located node's preprocessing information.
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultDestructor(SgClassDeclaration *classDeclaration)
Get the default destructor from the class declaration.
void collectVarRefs(SgLocatedNode *root, std::vector< SgVarRefExp * > &result)
Collect all variable references in a subtree.
ROSE_DLL_API void setOperand(SgExpression *target, SgExpression *operand)
Set operands for expressions with single operand, such as unary expressions. handle file info,...
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultConstructor(SgClassDeclaration *classDeclaration)
Get the default constructor from the class declaration.
ROSE_DLL_API SgInitializedName * getLoopIndexVariable(SgNode *loop)
Return the loop index variable for a for loop.
ROSE_DLL_API SgAssignInitializer * splitExpression(SgExpression *from, std::string newName="")
Replace an expression with a temporary variable and an assignment statement.
ROSE_DLL_API void replaceVariableReferences(SgVariableSymbol *old_sym, SgVariableSymbol *new_sym, SgScopeStatement *scope)
Replace all variable references to an old symbol in a scope to being references to a new symbol.
ROSE_DLL_API bool is_OpenCL_language()
ROSE_DLL_API bool normalizeForLoopIncrement(SgForStatement *loop)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API SgVariableSymbol * appendArg(SgFunctionParameterList *, SgInitializedName *)
Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for argume...
ROSE_DLL_API bool unnormalizeForLoopInitDeclaration(SgForStatement *loop)
Undo the normalization of for loop's C99 init declaration. Previous record of normalization is used t...
ROSE_DLL_API SgStatement * getPreviousStatement(SgStatement *currentStmt, bool climbOutScope=true)
Get previous statement of the current statement. It may return a previous statement of a parent scope...
ROSE_DLL_API void removeJumpsToNextStatement(SgNode *)
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments.
bool isPrototypeInScope(SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
ROSE_DLL_API int moveUpInnerDanglingIfEndifDirective(SgLocatedNode *lnode)
Extract sequences like " #endif #endif ... #if | #ifdef| #ifndef" buried inside subtree of lnode.
SgDeclarationStatement * getNonInstantiatonDeclarationForClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API bool isConstType(SgType *t)
Is this a const type?
SgFunctionDeclaration * getDeclarationOfNamedFunction(SgExpression *func)
Given a SgExpression that represents a named function (or bound member function), return the mentione...
ROSE_DLL_API bool is_C99_language()
ROSE_DLL_API bool addDefaultConstructorIfRequired(SgClassType *classType, int physical_file_id=Sg_File_Info::TRANSFORMATION_FILE_ID)
Get the default destructor from the class declaration.
ROSE_DLL_API void movePreprocessingInfo(SgStatement *stmt_src, SgStatement *stmt_dst, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false)
Move preprocessing information of stmt_src to stmt_dst, Only move preprocessing information from the ...
ROSE_DLL_API int fixVariableReferences(SgNode *root, bool cleanUnusedSymbol=true)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool isUseByAddressVariableRef(SgVarRefExp *ref)
Check if a variable reference is used by its address: including &a expression and foo(a) when type2 f...
struct const_int_expr_t evaluateConstIntegerExpression(SgExpression *expr)
The function tries to evaluate const integer expressions (such as are used in array dimension sizes)....
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsTrueBodyOfIf(SgIfStmt *ifs)
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API void replaceExpression(SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false)
Replace an expression with another, used for variable reference substitution and others....
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsFalseBodyOfIf(SgIfStmt *ifs, bool createEmptyBody=true)
Check if the false body of a 'if' statement is a SgBasicBlock, create one if not when the flag is tru...
ROSE_DLL_API SgExprListExp * getEnclosingExprListExp(SgNode *astNode, const bool includingSelf=false)
Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions...
ROSE_DLL_API void appendStatement(SgStatement *stmt, SgScopeStatement *scope=NULL)
Append a statement to the end of the current scope, handle side effect of appending statements,...
ROSE_DLL_API SgFunctionDeclaration * buildFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
void addVarRefExpFromArrayDimInfo(SgNode *astNode, Rose_STL_Container< SgNode * > &NodeList_t)
Find all SgPntrArrRefExp under astNode, then add SgVarRefExp (if any) of SgPntrArrRefExp's dim_info i...
ROSE_DLL_API bool loopTiling(SgForStatement *loopNest, size_t targetLevel, size_t tileSize)
Tile the n-level (starting from 1) loop of a perfectly nested loop nest using tiling size s.
std::string generateUniqueName(const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
Generate unique name from C and C++ constructs. The name may contain space.
ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project)
return the first global scope under current project
ROSE_DLL_API void setOneSourcePositionNull(SgNode *node)
Set current node's source position as NULL.
ROSE_DLL_API void setRhsOperand(SgExpression *target, SgExpression *rhs)
set left hand operand for binary expression
std::pair< SgStatement *, SgInitializedName * > wrapFunction(SgFunctionDeclaration &definingDeclaration, SgName newName)
moves the body of a function f to a new function f; f's body is replaced with code that forwards the ...
ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language()
ROSE_DLL_API bool isVolatileType(SgType *t)
Is this a volatile type?
void clearUnusedVariableSymbols(SgNode *root=NULL)
Clear those variable symbols with unknown type (together with initialized names) which are also not r...
ROSE_DLL_API void fixVariableDeclaration(SgVariableDeclaration *varDecl, SgScopeStatement *scope)
Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known.
ROSE_DLL_API SgSymbol * lookupSymbolInParentScopesIgnoringAliasSymbols(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
std::string generateUniqueVariableName(SgScopeStatement *scope, std::string baseName="temp")
Generate a name like temp# that is unique in the current scope and any parent and children scopes.
ROSE_DLL_API int gensym_counter
An internal counter for generating unique SgName.
ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression *expr)
Split long expressions into blocks of statements.
void reset_name_collision_map()
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API SgFunctionDefinition * getEnclosingProcedure(SgNode *n, const bool includingSelf=false)
Find the function definition.
std::vector< SgExpression * > get_C_array_dimensions(const SgArrayType &arrtype)
returns the array dimensions in an array as defined for arrtype
ROSE_DLL_API void replaceSubexpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Similar to replaceExpressionWithStatement, but with more restrictions.
ROSE_DLL_API void wrapAllTemplateInstantiationsInAssociatedNamespaces(SgProject *root)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
ROSE_DLL_API void setLoopUpperBound(SgNode *loop, SgExpression *ub)
Set the upper bound of a loop header,regardless the condition expression type. for (i=lb; i op up,...
ROSE_DLL_API bool isMemberFunctionMemberReference(SgMemberFunctionRefExp *memberFunctionRefExp)
Find a node by type using upward traversal.
ROSE_DLL_API SgClassDefinition * findJavaPackage(SgScopeStatement *, std::string)
Look for a qualified package name in the given scope and return its package definition.
ROSE_DLL_API bool isOmpStatement(SgNode *)
Check if a node is SgOmp*Statement.
ROSE_DLL_API bool is_Ada_language()
std::string addMangledNameToCache(SgNode *astNode, const std::string &mangledName)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API bool is_C_language()
ROSE_DLL_API std::list< SgClassType * > getClassTypeChainForMemberReference(SgExpression *refExp)
Find a node by type using upward traversal.
ROSE_DLL_API void collectUseByAddressVariableRefs(const SgStatement *s, std::set< SgVarRefExp * > &varSetB)
Collect variable references involving use by address: including &a expression and foo(a) when type2 f...
std::vector< SgContinueStmt * > findContinueStmts(SgStatement *code, const std::string &fortranLabel="")
Find all continue statements inside a particular statement, stopping at nested loops.
std::string getMangledNameFromCache(SgNode *astNode)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API std::vector< SgDeclarationStatement * > sortSgNodeListBasedOnAppearanceOrderInSource(const std::vector< SgDeclarationStatement * > &nodevec)
Reorder a list of declaration statements based on their appearance order in source files.
ROSE_DLL_API std::set< SgLocatedNode * > collectModifiedLocatedNodes(SgNode *node)
This collects the SgLocatedNodes that are marked as modified (a flag automatically set by all set_* g...
SgExpression * forallMaskExpression(SgForAllStatement *stmt)
Get the mask expression from the header of a SgForAllStatement.
void clearScopeNumbers(SgFunctionDefinition *functionDefinition)
Clears the cache of scope,integer pairs for the input function.
ROSE_DLL_API SgInitializedName * convertRefToInitializedName(SgNode *current, bool coarseGrain=true)
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName,...
ROSE_DLL_API SgNode * getSgNodeFromAbstractHandleString(const std::string &input_string)
Obtain a matching SgNode from an abstract handle string.
ROSE_DLL_API void moveStatementsBetweenBlocks(SgBasicBlock *sourceBlock, SgBasicBlock *targetBlock)
Move statements in first block to the second block (preserves order and rebuilds the symbol table).
ROSE_DLL_API bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration)
Return true if template definition is in the class, false if outside of class.
ROSE_DLL_API void fixLabelStatement(SgLabelStatement *label_stmt, SgScopeStatement *scope)
Fix symbol table for SgLabelStatement. Used Internally when the label is built without knowing its ta...
ROSE_DLL_API void replaceExpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Replace a given expression with a list of statements produced by a generator.
ROSE_DLL_API void convertForToWhile(SgForStatement *f)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement before a target statement.
ROSE_DLL_API bool findFirstSgCastExpMarkedAsTransformation(SgNode *n, const std::string &s)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API void dumpInfo(SgNode *node, std::string desc="")
Dump information about a SgNode for debugging.
ROSE_DLL_API void convertFunctionDefinitionsToFunctionPrototypes(SgNode *node)
XXX This function operates on the new file used to support outlined function definitions....
ROSE_DLL_API void appendStatementList(const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
Append a list of statements to the end of the current scope, handle side effect of appending statemen...
SgNamedType * getDeclaredType(const SgDeclarationStatement *declaration)
Returns the type introduced by a declaration.
ROSE_DLL_API bool isIndexOperator(SgExpression *exp)
Is an overloaded operator an index operator (also referred to as call or subscript operators)....
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt *cos)
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.
std::vector< SgFile * > generateFileList()
Returns STL vector of SgFile IR node pointers.
ROSE_DLL_API int normalizeArrowExpWithAddressOfLeftOperand(SgNode *root, bool transformationGeneratedOnly=true)
Convert all code within root matching the patern of (&left)->right, and translate them into left....
bool hasTemplateSyntax(const SgName &name)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void moveToSubdirectory(std::string directoryName, SgFile *file)
Move file to be generated in a subdirectory (will be generated by the unparser).
ROSE_DLL_API bool isAddressTaken(SgExpression *refExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool hasSimpleChildrenList(SgScopeStatement *scope)
Check if a scope statement has a simple children statement list so insert additional statements under...
ROSE_DLL_API SgFunctionDeclaration * findMain(SgNode *currentNode)
top-down traversal from current node to find the main() function declaration
ROSE_DLL_API SgClassSymbol * lookupClassSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API void removeConsecutiveLabels(SgNode *top)
Remove consecutive labels.
ROSE_DLL_API void setLoopBody(SgScopeStatement *loop, SgStatement *body)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
bool getForLoopInformations(SgForStatement *for_loop, SgVariableSymbol *&iterator, SgExpression *&lower_bound, SgExpression *&upper_bound, SgExpression *&stride)
ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression *)
Append an expression to a SgExprListExp, set the parent pointer also.
ROSE_DLL_API bool isLambdaFunction(SgFunctionDeclaration *func)
Check if a function declaration is a C++11 lambda function.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement *ws)
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API void prependStatement(SgStatement *stmt, SgScopeStatement *scope=NULL)
Prepend a statement to the beginning of the current scope, handling side effects as appropriate.
ROSE_DLL_API bool isCallToParticularFunction(SgFunctionDeclaration *decl, SgExpression *e)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API bool ROSE_DLL_API isMutable(SgInitializedName *name)
True if an SgInitializedName is "mutable' (has storage modifier set)
ROSE_DLL_API bool isCopyConstructible(SgType *type)
Is a type copy constructible? This may not quite work properly.
ROSE_DLL_API SgVariableSymbol * prependArg(SgFunctionParameterList *, SgInitializedName *)
Prepend an argument to SgFunctionParameterList.
ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root)
Set the source code positon for the subtree (including the root).
ROSE_DLL_API SgExpression * copyExpression(SgExpression *e)
Deep copy an expression.
void setParameterList(actualFunction *func, SgFunctionParameterList *paralist)
Set parameter list for a function declaration, considering existing parameter list etc.
SgStatement * findLastDeclarationStatement(SgScopeStatement *scope, bool includePragma=false)
Find the last declaration statement within a scope (if any). This is often useful to decide where to ...
ROSE_DLL_API bool insideSystemHeader(SgLocatedNode *node)
Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool.
std::vector< SgDeclarationStatement * > getDependentDeclarations(SgStatement *stmt)
Get a statement's dependent declarations which declares the types used in the statement....
SgBasicBlock * makeSingleStatementBodyToBlock(SgStatement *singleStmt)
Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc.
void computeUniqueNameForUseAsIdentifier(SgNode *astNode)
Traversal to set the global map of names to node and node to names.collisions to support generateUniq...
ROSE_DLL_API void collectReadOnlyVariables(SgStatement *stmt, std::set< SgInitializedName * > &readOnlyVars, bool coarseGrain=true)
Collect read only variables within a statement. The statement can be either of a function,...
std::string generateUniqueNameForUseAsIdentifier_support(SgDeclarationStatement *declaration)
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API PreprocessingInfo * findHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader)
Find the preprocessingInfo node representing #include <header.h> or #include "header....
ROSE_DLL_API void myRemoveStatement(SgStatement *stmt)
A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's atten...
ROSE_DLL_API SgScopeStatement * getScope(const SgNode *astNode)
Get the closest scope from astNode. Return astNode if it is already a scope.
ROSE_DLL_API bool isStrictIntegerType(SgType *t)
Check if a type is an integral type, only allowing signed/unsigned short, int, long,...
ROSE_DLL_API bool is_Java_language()
ROSE_DLL_API void insertStatementAfter(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement after a target statement, Move around preprocessing info automatically by default.
ROSE_DLL_API bool isEquivalentType(const SgType *lhs, const SgType *rhs)
Test for equivalence of types independent of access permissions (private or protected modes for membe...
ROSE_DLL_API bool isTemplateInstantiationNode(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API void removeStatement(SgStatement *stmt, bool autoRelocatePreprocessingInfo=true)
Remove a statement from its attach point of the AST. Automatically keep its associated preprocessing ...
ROSE_DLL_API SgOmpClauseBodyStatement * findEnclosingOmpClauseBodyStatement(SgStatement *s)
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly.
ROSE_DLL_API bool scopeHasStatementsFromSameFile(SgScopeStatement *scope)
This function supports the token-based unparsing when used with unparsing of header files to know whe...
ROSE_DLL_API SgSourceFile * getEnclosingSourceFile(SgNode *n, const bool includingSelf=false)
Find enclosing source file node.
void rebuildSymbolTable(SgScopeStatement *scope)
Regenerate the symbol table.
ROSE_DLL_API SgSymbol * lookupSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
void setBaseTypeDefiningDeclaration(SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl)
a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side ef...
ROSE_DLL_API void pastePreprocessingInfo(SgLocatedNode *dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &saved_buf)
Paste preprocessing information from a buffer to a destination node. Used in combination of cutPrepro...
ROSE_DLL_API SgStatement * lastFrontEndSpecificStatement(SgGlobal *globalScope)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API SgFunctionType * findFunctionType(SgType *return_type, SgFunctionParameterTypeList *typeList)
Find the function type matching a function signature plus a given return type.
std::set< unsigned int > collectSourceSequenceNumbers(SgNode *astNode)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool is_OpenMP_language()
ROSE_DLL_API std::set< SgNode * > getFrontendSpecificNodes()
Find a node by type using upward traversal.
ROSE_DLL_API bool mergeAssignmentWithDeclaration(SgExprStatement *assign_stmt, SgVariableDeclaration *decl, bool removeAssignStmt=true)
Merge an assignment into its upstream declaration statement. Callers should make sure the merge is se...
ROSE_DLL_API void setFortranNumericLabel(SgStatement *stmt, int label_value, SgLabelSymbol::label_type_enum label_type=SgLabelSymbol::e_start_label_type, SgScopeStatement *label_scope=NULL)
Set a numerical label for a Fortran statement. The statement should have a enclosing function definit...
ROSE_DLL_API SgType * lookupNamedTypeInParentScopes(const std::string &type_name, SgScopeStatement *scope=NULL)
Lookup a named type based on its name, bottomup searching from a specified scope. Note name collison ...
ROSE_DLL_API SgFile * processFile(SgProject *, std::string, bool unparse=false)
Invoke JavaRose to translate a given file and put the resulting AST in the global space of the projec...
bool get(const Word *words, size_t idx)
Return a single bit.
void swap_child(SageNode &lhs, SageNode &rhs, SageChild *(SageNode::*getter)() const, void(SageNode::*setter)(SageChild *))
swaps children (of equal kind) between two ancestor nodes of the same type
std::remove_const< typenamestd::remove_reference< RoseVisitor >::type >::type dispatch(RoseVisitor &&rv, SgNode *n)
uncovers the type of SgNode and passes it to an function "handle" in RoseVisitor.
This file implements generic (template) sage query functions Currently this includes functions for: