ROSE  0.11.51.0
sageInterface.h
1 #ifndef ROSE_SAGE_INTERFACE
2 #define ROSE_SAGE_INTERFACE
3 
4 #include "sage3basic.hhh"
5 #include <stdint.h>
6 #include <utility>
7 
8 #include "rosePublicConfig.h" // for ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
9 #include "OmpAttribute.h"
10 
11 
12 #if 0 // FMZ(07/07/2010): the argument "nextErrorCode" should be call-by-reference
13 SgFile* determineFileType ( std::vector<std::string> argv, int nextErrorCode, SgProject* project );
14 #else
15 SgFile* determineFileType ( std::vector<std::string> argv, int& nextErrorCode, SgProject* project );
16 #endif
17 
18 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
19 #include "rewrite.h"
20 #endif
21 
22 // DQ (7/20/2008): Added support for unparsing abitrary strings in the unparser.
23 #include "astUnparseAttribute.h"
24 #include <set>
25 
26 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
27 #include "LivenessAnalysis.h"
28 #include "abstract_handle.h"
29 #include "ClassHierarchyGraph.h"
30 #endif
31 
32 // DQ (8/19/2004): Moved from ROSE/src/midend/astRewriteMechanism/rewrite.h
34 ROSE_DLL_API std::string getVariantName (VariantT v);
35 
36 // DQ (12/9/2004): Qing, Rich and Dan have decided to start this namespace within ROSE
37 // This namespace is specific to interface functions that operate on the Sage III AST.
38 // The name was chosen so as not to conflict with other classes within ROSE.
39 // This will become the future home of many interface functions which operate on
40 // the AST and which are generally useful to users. As a namespace multiple files can be used
41 // to represent the compete interface and different developers may contribute interface
42 // functions easily.
43 
44 // Constructor handling: (We have sageBuilder.h now for this purpose, Liao 2/1/2008)
45 // We could add simpler layers of support for construction of IR nodes by
46 // hiding many details in "makeSg***()" functions. Such functions would
47 // return pointers to the associated Sg*** objects and would be able to hide
48 // many IR specific details, including:
49 // memory handling
50 // optional parameter settings not often required
51 // use of Sg_File_Info objects (and setting them as transformations)
52 //
53 // namespace AST_Interface (this name is taken already by some of Qing's work :-)
54 
56 #define TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode()
57 
58 
64 namespace SageInterface
65  {
66  // Liao 6/22/2016: keep records of loop init-stmt normalization, later help undo it to support autoPar.
68  {
69  // a lookup table to check if a for loop has been normalized for its c99-style init-stmt
70  std::map <SgForStatement* , bool > forLoopInitNormalizationTable;
71  // Detailed record about the original declaration (1st in the pair) and the normalization generated new declaration (2nd in the pair)
72  std::map <SgForStatement* , std::pair<SgVariableDeclaration*, SgVariableDeclaration*> > forLoopInitNormalizationRecord;
73  } ;
74 
75  ROSE_DLL_API extern Transformation_Record trans_records;
76 
77  // DQ (4/3/2014): Added general AST support separate from the AST.
78 
79  // Container and API for analysis information that is outside of the AST and as a result
80  // prevents frequent modification of the IR.
82  {
83  // DQ (4/3/2014): This stores all associated declarations as a map of sets.
84  // the key to the map is the first nondefining declaration and the elements of the set are
85  // all of the associated declarations (including the defining declaration).
86 
87  private:
89  std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > declarationMap;
90 
91  public:
92  void addDeclaration(SgDeclarationStatement* decl);
93  const std::set<SgDeclarationStatement*>* getDeclarations(SgDeclarationStatement* decl);
94 
95  std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > & getDeclarationMap();
96 
97  bool isLocatedInDefiningScope(SgDeclarationStatement* decl);
98 
99  };
100 
101  // DQ (4/3/2014): This constructs a data structure that holds analysis information about
102  // the AST that is separate from the AST. This is intended to be a general mechanism
103  // to support analysis information without constantly modifying the IR.
104  DeclarationSets* buildDeclarationSets(SgNode*);
105 
107 ROSE_DLL_API extern int gensym_counter;
108 
109 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
110 SgAsmInterpretation* getMainInterpretation(SgAsmGenericFile* file);
112 
114 uint64_t getAsmConstant(SgAsmValueExpression* e);
115 
117 int64_t getAsmSignedConstant(SgAsmValueExpression *e);
118 #endif
119 
121  void addMessageStatement( SgStatement* stmt, std::string message );
122 
125  {
126  private:
127  std::string name;
128  public:
129  UniqueNameAttribute(std::string n="") {name =n; };
130  void set_name (std::string n) {name = n;};
131  std::string get_name () {return name;};
132  };
133 
134  //------------------------------------------------------------------------
136 
140 // DQ (8/5/2020): the "using namespace" directive will not hide existing visability of symbols in resolving visability.
141 // So we need to test if a symbol is visible exclusing matching alises due to using direectives before we can decide to
142 // persue name space qualification. This is best demonstrated by Cxx_tests/test2020_18.C, test2020_19.C, test2020_20.C,
143 // and test2020_21.C.
144  ROSE_DLL_API SgSymbol *lookupSymbolInParentScopesIgnoringAliasSymbols (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
145 
146 // DQ (8/21/2013): Modified to make newest function parameters be default arguments.
147 // DQ (8/16/2013): For now we want to remove the use of default parameters and add the support for template parameters and template arguments.
149 // SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope=NULL);
150 // SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList);
151  ROSE_DLL_API SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
152 
153  // Liao 1/22/2008, used for get symbols for generating variable reference nodes
154  // ! Find a variable symbol in current and ancestor scopes for a given name
155  ROSE_DLL_API SgVariableSymbol *lookupVariableSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope=NULL);
156 
157  // DQ (11/24/2007): Functions moved from the Fortran support so that they could be called from within astPostProcessing.
159  ROSE_DLL_API SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName & functionName, SgScopeStatement *currentScope=NULL);
160 
161  // Liao, 1/24/2008, find exact match for a function
163  ROSE_DLL_API SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName & functionName,
164  const SgType* t,
165  SgScopeStatement *currentScope=NULL);
166 
167  ROSE_DLL_API SgFunctionSymbol *lookupTemplateFunctionSymbolInParentScopes (const SgName & functionName, SgFunctionType * ftype, SgTemplateParameterPtrList * tplparams, SgScopeStatement *currentScope=NULL);
168  ROSE_DLL_API SgFunctionSymbol *lookupTemplateMemberFunctionSymbolInParentScopes (const SgName & functionName, SgFunctionType * ftype, SgTemplateParameterPtrList * tplparams, SgScopeStatement *currentScope=NULL);
169 
170  ROSE_DLL_API SgTemplateVariableSymbol * lookupTemplateVariableSymbolInParentScopes (const SgName & name, SgTemplateParameterPtrList * tplparams, SgTemplateArgumentPtrList* tplargs, SgScopeStatement *currentScope=NULL);
171 
172 
173 // DQ (8/21/2013): Modified to make newest function parameters be default arguments.
174 // DQ (8/16/2013): For now we want to remove the use of default parameters and add the support for template parameters and template arguments.
175 // DQ (5/7/2011): Added support for SgClassSymbol (used in name qualification support).
176 // SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
177  ROSE_DLL_API SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
178  ROSE_DLL_API SgTypedefSymbol* lookupTypedefSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
179 
180  ROSE_DLL_API SgNonrealSymbol* lookupNonrealSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
181 #if 0
182  // DQ (8/13/2013): This function does not make since any more, now that we have made the symbol
183  // table handling more precise and we have to provide template parameters for any template lookup.
184  // We also have to know if we want to lookup template classes, template functions, or template
185  // member functions (since each have specific requirements).
186  SgTemplateSymbol* lookupTemplateSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
187 #endif
188 #if 0
189 // DQ (8/13/2013): I am not sure if we want this functions in place of lookupTemplateSymbolInParentScopes.
190 // Where these are called we might not know enough information about the template parameters or function
191 // types, for example.
192  SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
193  SgTemplateFunctionSymbol* lookupTemplateFunctionSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL);
194  SgTemplateMemberFunctionSymbol* lookupTemplateMemberFunctionSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL);
195 #endif
196 
197 // DQ (8/21/2013): Modified to make some of the newest function parameters be default arguments.
198 // DQ (8/13/2013): I am not sure if we want this functions in place of lookupTemplateSymbolInParentScopes.
199  ROSE_DLL_API SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes (const SgName & name, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgScopeStatement *cscope = NULL);
200 
201  ROSE_DLL_API SgEnumSymbol* lookupEnumSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
202  ROSE_DLL_API SgNamespaceSymbol* lookupNamespaceSymbolInParentScopes(const SgName & name, SgScopeStatement *currentScope = NULL);
203 
204 // DQ (7/17/2011): Added function from cxx branch that I need here for the Java support.
205 // SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *cscope);
206 
215  // DQ (12/9/2004): Moved this function (by Alin Jula) from being a member of SgInitializedName
216  // to this location where it can be a part of the interface for the Sage III AST.
217  ROSE_DLL_API int set_name (SgInitializedName * initializedNameNode, SgName new_name);
218 
222 
223  // DQ (6/27/2005):
228  ROSE_DLL_API void outputLocalSymbolTables (SgNode * node);
229 
231  {
232  public:
233  void visit (SgNode * node);
234  };
240  // DQ (9/28/2005):
241  void rebuildSymbolTable (SgScopeStatement * scope);
242 
245  void clearUnusedVariableSymbols (SgNode* root = NULL);
246 
247  // DQ (3/1/2009):
249  void fixupReferencesToSymbols( const SgScopeStatement* this_scope, SgScopeStatement* copy_scope, SgCopyHelp & help );
250 
252 
253  //------------------------------------------------------------------------
255 
262  // DQ (9/21/2005): General function for extracting the name of declarations (when they have names)
263  std::string get_name (const SgNode * node);
264 
269  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
270  std::string get_name (const SgStatement * stmt);
271 
276  std::string get_name (const SgExpression * expr);
277 
282  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
283  std::string get_name (const SgDeclarationStatement * declaration);
284 
289  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
290  std::string get_name (const SgScopeStatement * scope);
291 
296  // DQ (2/11/2007): Added this function to make debugging support more complete (useful for symbol table debugging support).
297  std::string get_name (const SgSymbol * symbol);
298 
303  std::string get_name (const SgType * type);
304 
305 
308  std::string get_name (const SgSupport * node);
309 
310 
313  std::string get_name (const SgLocatedNodeSupport * node);
314 
317  std::string get_name ( const SgC_PreprocessorDirectiveStatement* directive );
318 
321  std::string get_name ( const SgToken* token );
322 
323  // DQ (3/20/2016): Added to refactor some of the DSL infrastructure support.
333 
336  extern std::map<std::string,int> local_name_collision_map;
337  extern std::map<std::string,SgNode*> local_name_to_node_map;
338  extern std::map<SgNode*,std::string> local_node_to_name_map;
339 
343 
347 
349 
350  //------------------------------------------------------------------------
352 
357  // DQ (6/21/2005): Get the default destructor from the class declaration
358  ROSE_DLL_API SgMemberFunctionDeclaration *getDefaultDestructor (SgClassDeclaration* classDeclaration);
359 
362  // DQ (6/22/2005): Get the default constructor from the class declaration
363  ROSE_DLL_API SgMemberFunctionDeclaration *getDefaultConstructor (SgClassDeclaration* classDeclaration);
366  // DQ (8/27/2005):
367  ROSE_DLL_API bool templateDefinitionIsInClass (SgTemplateInstantiationMemberFunctionDecl* memberFunctionDeclaration);
368 
373  // DQ (9/17/2005):
375 
377  ROSE_DLL_API bool isStructDeclaration(SgNode * node);
379  ROSE_DLL_API bool isUnionDeclaration(SgNode * node);
380 
381 #if 0
382  // DQ (8/28/2005): This is already a member function of the SgFunctionDeclaration
383  // (so that it can handle template functions and member functions)
384 
388  // DQ (8/27/2005):
389  bool isTemplateMemberFunction (SgTemplateInstantiationMemberFunctionDecl* memberFunctionDeclaration);
390 #endif
391 
392  // DQ (11/9/2020): Added function to support adding a default constructor definition to a class
393  // if it does not have a default constructor, but has any other constructor that would prevend
394  // a compiler generated default constructor from being generated by the compiler.
395  // Note the physical_file_id is so that it can be marked to be unparsed when header file unparsing is active.
396  ROSE_DLL_API bool addDefaultConstructorIfRequired ( SgClassType* classType, int physical_file_id = Sg_File_Info::TRANSFORMATION_FILE_ID );
397 
399 
400  //------------------------------------------------------------------------
402 
408 
410  void saveToPDF(SgNode* node, std::string filename);
411  void saveToPDF(SgNode* node); // enable calling from gdb
412 
414  void printAST (SgNode* node);
415 
417  void printAST2TextFile (SgNode* node, const char* filename);
418  void printAST2TextFile (SgNode* node, std::string filename);
419 
420  // DQ (2/12/2012): Added some diagnostic support.
422  void whereAmI(SgNode* node);
423 
425  std::string extractPragmaKeyword(const SgPragmaDeclaration *);
426 
428  ROSE_DLL_API bool isOmpStatement(SgNode* );
431  // DQ (8/27/2005):
432  bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
433 
434 // DQ (2/14/2012): Added support function used for variable declarations in conditionals.
436  void initializeIfStmt(SgIfStmt *ifstmt, SgStatement* conditional, SgStatement * true_body, SgStatement * false_body);
437 
439  void initializeSwitchStatement(SgSwitchStatement* switchStatement,SgStatement *item_selector,SgStatement *body);
440 
442  void initializeWhileStatement(SgWhileStmt* whileStatement, SgStatement * condition, SgStatement *body, SgStatement *else_body);
443 
446 
448  ROSE_DLL_API bool isMain (const SgNode* node);
449  // DQ (6/22/2005):
460  std::string generateUniqueName ( const SgNode * node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations);
461 
464  std::string generateUniqueVariableName(SgScopeStatement* scope, std::string baseName = "temp");
465 
466  // DQ (8/10/2010): Added const to first parameter.
467  // DQ (3/10/2007):
469  std::string declarationPositionString (const SgDeclarationStatement * declaration);
470 
471  // DQ (1/20/2007):
473  ROSE_DLL_API std::string generateProjectName (const SgProject * project, bool supressSuffix = false );
474 
478 
481 
483  void addVarRefExpFromArrayDimInfo(SgNode * astNode, Rose_STL_Container<SgNode *>& NodeList_t);
484 
485  // DQ (10/6/2006): Added support for faster mangled name generation (caching avoids recomputation).
489 #ifndef SWIG
490 // DQ (3/10/2013): This appears to be a problem for the SWIG interface (undefined reference at link-time).
491  void clearMangledNameCache (SgGlobal * globalScope);
492  void resetMangledNameCache (SgGlobal * globalScope);
493 #endif
494 
495  std::string getMangledNameFromCache (SgNode * astNode);
496  std::string addMangledNameToCache (SgNode * astNode, const std::string & mangledName);
497 
499 
503 
504  // DQ (10/14/2006): This function tests the AST to see if for a non-defining declaration, the
505  // bool declarationPreceedsDefinition ( SgClassDeclaration* classNonDefiningDeclaration, SgClassDeclaration* classDefiningDeclaration );
507  bool declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration);
508 
509  // DQ (10/19/2006): Function calls have interesting context dependent rules to determine if
510  // they are output with a global qualifier or not. Were this is true we have to avoid global
511  // qualifiers, since the function's scope has not been defined. This is an example of where
512  // qualification of function names in function calls are context dependent; an interesting
513  // example of where the C++ language is not friendly to source-to-source processing :-).
515 
520  ROSE_DLL_API std::vector < SgNode * >astIntersection (SgNode * original, SgNode * copy, SgCopyHelp * help = NULL);
521 
523  ROSE_DLL_API SgNode* deepCopyNode (const SgNode* subtree);
524 
526  template <typename NodeType>
527  NodeType* deepCopy (const NodeType* subtree) {
528  return dynamic_cast<NodeType*>(deepCopyNode(subtree));
529  }
530 
532  ROSE_DLL_API SgExpression* copyExpression(SgExpression* e);
533 
535  ROSE_DLL_API SgStatement* copyStatement(SgStatement* s);
536 
537 // from VarSym.cc in src/midend/astOutlining/src/ASTtools
540 
543 
545 ROSE_DLL_API void myRemoveStatement(SgStatement* stmt);
546 
547 ROSE_DLL_API bool isConstantTrue(SgExpression* e);
548 ROSE_DLL_API bool isConstantFalse(SgExpression* e);
549 
551 ROSE_DLL_API bool isCallToParticularFunction(const std::string& qualifiedName, size_t arity, SgExpression* e);
552 
554 bool ROSE_DLL_API isStatic(SgDeclarationStatement* stmt);
555 
557 ROSE_DLL_API void setStatic(SgDeclarationStatement* stmt);
558 
560 ROSE_DLL_API bool isExtern(SgDeclarationStatement* stmt);
561 
563 ROSE_DLL_API void setExtern(SgDeclarationStatement* stmt);
564 
566 bool ROSE_DLL_API isMutable(SgInitializedName* name);
567 
569 bool ROSE_DLL_API isJovialOutParam(SgInitializedName* name);
570 
572 std::vector<SgInitializedName*> getInParameters(const SgInitializedNamePtrList &params);
573 
575 std::vector<SgInitializedName*> getOutParameters(const SgInitializedNamePtrList &params);
576 
580  public:
581  virtual ~StatementGenerator() {};
582  virtual SgStatement* generate(SgExpression* where_to_write_answer) = 0;
583 };
584 
588  bool isAssignmentStatement(SgNode* _s, SgExpression** lhs=NULL, SgExpression** rhs=NULL, bool* readlhs=NULL);
589 
591 ROSE_DLL_API SgInitializedName* convertRefToInitializedName(SgNode* current, bool coarseGrain=true);
592 
595 
597 ROSE_DLL_API SgNode* getSgNodeFromAbstractHandleString(const std::string& input_string);
598 
600 ROSE_DLL_API void dumpInfo(SgNode* node, std::string desc="");
601 
603 ROSE_DLL_API std::vector<SgDeclarationStatement*>
604 sortSgNodeListBasedOnAppearanceOrderInSource(const std::vector<SgDeclarationStatement*>& nodevec);
605 
606 // DQ (4/13/2013): We need these to support the unparing of operators defined by operator syntax or member function names.
608 // bool isPrefixOperator( const SgMemberFunctionRefExp* memberFunctionRefExp );
609 bool isPrefixOperator( SgExpression* exp );
610 
612 bool isPrefixOperatorName( const SgName & functionName );
613 
615 bool isPostfixOperator( SgExpression* exp );
616 
618 bool isIndexOperator( SgExpression* exp );
619 
620 // DQ (1/10/2014): Adding more general support for token based unparsing.
622 SgStatement* lastStatementOfScopeWithTokenInfo (SgScopeStatement* scope, std::map<SgNode*,TokenStreamSequenceToNodeMapping*> & tokenStreamSequenceMap);
623 
624 // DQ (8/12/2020): Check the access permissions of all defining and nodefining declarations.
626 
627 // DQ (8/14/2020): Check the symbol tables for specific scopes (debugging support).
628 void checkSymbolTables ( SgNode* );
629 
630 // DQ (11/9/2020): Added support for makring IR nodes and subtrees of the AST to be unparsed (physical_file_id
631 // is required when unparsing header files is true or support multiple files and shared IR nodes).
632 void markSubtreeToBeUnparsed(SgNode* root, int physical_file_id);
633 void markNodeToBeUnparsed(SgNode* node, int physical_file_id);
634 
635 
637 
638 //------------------------------------------------------------------------
640 
644 // DQ (11/25/2020): Add support to set this as a specific language kind file (there is at least one language kind file processed by ROSE).
645 // The value of 0 allows the old implementation to be tested, and the value of 1 allows the new optimized implementation to be tested.
646 // However to get all of the functions to be inlined, we have to recompile all of ROSE.
647 #define INLINE_OPTIMIZED_IS_LANGUAGE_KIND_FUNCTIONS 1
648 
649 // std::string version(); // utility_functions.h, version number
652 #if INLINE_OPTIMIZED_IS_LANGUAGE_KIND_FUNCTIONS
653  ROSE_DLL_API inline bool is_Ada_language () { return Rose::is_Ada_language; }
654  ROSE_DLL_API inline bool is_C_language () { return Rose::is_C_language; }
655  ROSE_DLL_API inline bool is_Cobol_language () { return Rose::is_Cobol_language; }
656  ROSE_DLL_API inline bool is_OpenMP_language () { return Rose::is_OpenMP_language; }
657  ROSE_DLL_API inline bool is_UPC_language () { return Rose::is_UPC_language; }
658  ROSE_DLL_API inline bool is_UPC_dynamic_threads() { return Rose::is_UPC_dynamic_threads; }
659  ROSE_DLL_API inline bool is_C99_language () { return Rose::is_C99_language; }
660  ROSE_DLL_API inline bool is_Cxx_language () { return Rose::is_Cxx_language; }
661  ROSE_DLL_API inline bool is_Java_language () { return Rose::is_Java_language; }
662  ROSE_DLL_API inline bool is_Jovial_language () { return Rose::is_Jovial_language; }
663  ROSE_DLL_API inline bool is_Fortran_language () { return Rose::is_Fortran_language; }
664  ROSE_DLL_API inline bool is_CAF_language () { return Rose::is_CAF_language; }
665  ROSE_DLL_API inline bool is_PHP_language() { return Rose::is_PHP_language; }
666  ROSE_DLL_API inline bool is_Python_language() { return Rose::is_Python_language; }
667  ROSE_DLL_API inline bool is_Cuda_language() { return Rose::is_Cuda_language; }
668  ROSE_DLL_API inline bool is_OpenCL_language() { return Rose::is_OpenCL_language; }
669  ROSE_DLL_API inline bool is_X10_language() { return Rose::is_X10_language; }
670  ROSE_DLL_API inline bool is_binary_executable() { return Rose::is_binary_executable; }
671 #else
672  ROSE_DLL_API bool is_Ada_language ();
673  ROSE_DLL_API bool is_C_language ();
674  ROSE_DLL_API bool is_Cobol_language ();
675  ROSE_DLL_API bool is_OpenMP_language ();
676  ROSE_DLL_API bool is_UPC_language ();
678  ROSE_DLL_API bool is_UPC_dynamic_threads();
679  ROSE_DLL_API bool is_C99_language ();
680  ROSE_DLL_API bool is_Cxx_language ();
681  ROSE_DLL_API bool is_Java_language ();
682  ROSE_DLL_API bool is_Jovial_language ();
683  ROSE_DLL_API bool is_Fortran_language ();
684  ROSE_DLL_API bool is_CAF_language ();
685  ROSE_DLL_API bool is_PHP_language();
686  ROSE_DLL_API bool is_Python_language();
687  ROSE_DLL_API bool is_Cuda_language();
688  ROSE_DLL_API bool is_OpenCL_language();
689  ROSE_DLL_API bool is_X10_language();
690  ROSE_DLL_API bool is_binary_executable();
691 #endif
692 
693  ROSE_DLL_API bool is_mixed_C_and_Cxx_language ();
694  ROSE_DLL_API bool is_mixed_Fortran_and_C_language ();
695  ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language ();
696  ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language ();
697 
698  ROSE_DLL_API bool is_language_case_insensitive ();
700 
702 
703 //------------------------------------------------------------------------
705 
709  // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
710  // labels for scopes in a function (as required for name mangling).
716  void resetScopeNumbers (SgFunctionDefinition * functionDeclaration);
717 
718  // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
719  // labels for scopes in a function (as required for name mangling).
728  void clearScopeNumbers (SgFunctionDefinition * functionDefinition);
729 
730 
733 // SgNamespaceDefinitionStatement * getEnclosingNamespaceScope (SgNode * node);
734 
735  bool isPrototypeInScope (SgScopeStatement * scope,
736  SgFunctionDeclaration * functionDeclaration,
737  SgDeclarationStatement * startingAtDeclaration);
738 
740  bool ROSE_DLL_API isAncestor(SgNode* node1, SgNode* node2);
742 //------------------------------------------------------------------------
744 
748  void dumpPreprocInfo (SgLocatedNode* locatedNode);
750 
752 ROSE_DLL_API PreprocessingInfo * findHeader(SgSourceFile * source_file, const std::string & header_file_name, bool isSystemHeader);
753 
755 ROSE_DLL_API PreprocessingInfo * insertHeader(SgSourceFile * source_file, const std::string & header_file_name, bool isSystemHeader, bool asLastHeader);
756 
758 ROSE_DLL_API void insertHeader (SgStatement* stmt, PreprocessingInfo* newheader, bool asLastHeader);
759 
761 ROSE_DLL_API PreprocessingInfo * insertHeader(SgSourceFile * source_file, const std::string & header_file_name, bool isSystemHeader = false, PreprocessingInfo::RelativePositionType position = PreprocessingInfo::before);
762 
764 ROSE_DLL_API PreprocessingInfo* insertHeader(const std::string& filename, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::after, bool isSystemHeader=false, SgScopeStatement* scope=NULL);
765 
767 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);
768 
770 ROSE_DLL_API void movePreprocessingInfo (SgStatement* stmt_src, SgStatement* stmt_dst, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef,
771  PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend= false);
772 
773 
775 ROSE_DLL_API void cutPreprocessingInfo (SgLocatedNode* src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& save_buf);
776 
778 ROSE_DLL_API void pastePreprocessingInfo (SgLocatedNode* dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& saved_buf);
779 
782  const std::string & text,
783  PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before);
784 
788 
791  SgSourceFile * source_file,
792  const std::string & content,
793  PreprocessingInfo::DirectiveType directive_type = PreprocessingInfo::C_StyleComment,
794  PreprocessingInfo::RelativePositionType position = PreprocessingInfo::before
795 );
796 
798  ROSE_DLL_API PreprocessingInfo* attachComment(SgLocatedNode* target, const std::string & content,
799  PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before,
800  PreprocessingInfo::DirectiveType dtype= PreprocessingInfo::CpreprocessorUnknownDeclaration);
801 
802 // DQ (7/20/2008): I am not clear were I should put this function, candidates include: SgLocatedNode or SgInterface
804  ROSE_DLL_API void addTextForUnparser ( SgNode* astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation );
805 
810 void guardNode(SgLocatedNode * target, std::string guard);
811 
813 
814 
815 //------------------------------------------------------------------------
817 
821 // ************************************************************************
822 // Newer versions of now depricated functions
823 // ************************************************************************
824 
825 // DQ (5/1/2012): This function queries the SageBuilder::SourcePositionClassification mode (stored in the SageBuilder
826 // interface) and used the specified mode to initialize the source position data (Sg_File_Info objects). This
827 // function is the only function that should be called directly (though in a namespace we can't define permissions).
829  ROSE_DLL_API void setSourcePosition(SgNode* node);
830 
831 // A better name might be "setSourcePositionForSubTree"
833  ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root);
834 
837 
838 // DQ (5/1/2012): Newly renamed function (previous name preserved for backward compatability).
840 
841 // ************************************************************************
842 
843 
844 
845 // ************************************************************************
846 // Older deprecated functions
847 // ************************************************************************
848  // Liao, 1/8/2007, set file info. for a whole subtree as transformation generated
850  ROSE_DLL_API void setOneSourcePositionForTransformation(SgNode *node);
851 
853  ROSE_DLL_API void setOneSourcePositionNull(SgNode *node);
854 
856  ROSE_DLL_API void setSourcePositionForTransformation (SgNode * root);
857 
859 // ROSE_DLL_API void setSourcePositionForTransformation_memoryPool();
860 
862  ROSE_DLL_API bool insideSystemHeader (SgLocatedNode* node);
863 
864 // DQ (2/27/2021): Adding support to detect if a SgLocatedNode is located in a header file.
866  ROSE_DLL_API bool insideHeader (SgLocatedNode* node);
867 
869 // ROSE_DLL_API void setSourcePosition (SgLocatedNode * locatedNode);
870 // ************************************************************************
871 
873 
874 
875 //------------------------------------------------------------------------
877 
881 // from src/midend/astInlining/typeTraits.h
882 // src/midend/astUtil/astInterface/AstInterface.h
883 
886 
887 
891 ROSE_DLL_API bool isStrictIntegerType(SgType* t);
893 ROSE_DLL_API SgType* getFirstVarType(SgVariableDeclaration* decl);
894 
896 ROSE_DLL_API bool isDefaultConstructible(SgType* type);
897 
899 ROSE_DLL_API bool isCopyConstructible(SgType* type);
900 
902 ROSE_DLL_API bool isAssignable(SgType* type);
903 
904 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
905 ROSE_DLL_API bool isPureVirtualClass(SgType* type, const ClassHierarchyWrapper& classHierarchy);
909 #endif
910 
912 ROSE_DLL_API bool hasTrivialDestructor(SgType* t);
913 
915 ROSE_DLL_API bool isNonconstReference(SgType* t);
916 
918 ROSE_DLL_API bool isReferenceType(SgType* t);
919 
921 ROSE_DLL_API bool isPointerType(SgType* t);
922 
928 ROSE_DLL_API bool isPointerToNonConstType(SgType* type);
929 
931 /* const char* p = "aa"; is not treated as having a const type. It is a pointer to const char.
932  * Similarly, neither for const int b[10]; or const int & c =10;
933  * The standard says, "A compound type is not cv-qualified by the cv-qualifiers (if any) of
934 the types from which it is compounded. Any cv-qualifiers applied to an array type affect the array element type, not the array type".
935  */
936 ROSE_DLL_API bool isConstType(SgType* t);
937 
940 
942 ROSE_DLL_API bool isVolatileType(SgType* t);
943 
945 ROSE_DLL_API bool isRestrictType(SgType* t);
946 
948 
950 ROSE_DLL_API bool isScalarType(SgType* t);
951 
955 ROSE_DLL_API bool isStrictIntegerType(SgType* t);
956 
958 ROSE_DLL_API bool isStructType(SgType* t);
959 
961 ROSE_DLL_API std::string mangleType(SgType* type);
962 
964 ROSE_DLL_API std::string mangleScalarType(SgType* type);
965 
967 ROSE_DLL_API std::string mangleModifierType(SgModifierType* type);
968 
970 ROSE_DLL_API size_t getArrayElementCount(SgArrayType* t);
971 
973 ROSE_DLL_API int getDimensionCount(SgType* t);
974 
976 ROSE_DLL_API SgType* getArrayElementType(SgType* t);
977 
979 ROSE_DLL_API SgType* getElementType(SgType* t);
980 
981 
998 std::vector<SgExpression*>
999 get_C_array_dimensions(const SgArrayType& arrtype);
1000 
1021 std::vector<SgExpression*>
1022 get_C_array_dimensions(const SgArrayType& arrtype, const SgVarRefExp& varref);
1023 
1027 std::vector<SgExpression*>
1028 get_C_array_dimensions(const SgArrayType& arrtype, SgInitializedName& initname);
1029 
1030 
1032 ROSE_DLL_API bool isArrayReference(SgExpression* ref, SgExpression** arrayNameExp=NULL, std::vector<SgExpression*>** subscripts=NULL);
1033 
1034 
1036 ROSE_DLL_API int collectVariableReferencesInArrayTypes (SgLocatedNode* root, Rose_STL_Container<SgNode*> & currentVarRefList);
1038 
1047 ROSE_DLL_API bool hasUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL );
1048 
1050 
1053 ROSE_DLL_API bool isUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL);
1054 
1056 ROSE_DLL_API bool isUpcSharedModifierType (SgModifierType* mod_type);
1057 
1059 ROSE_DLL_API bool isUpcSharedArrayType (SgArrayType* array_type);
1060 
1062 ROSE_DLL_API bool isUpcStrictSharedModifierType(SgModifierType* mode_type);
1063 
1065 ROSE_DLL_API size_t getUpcSharedBlockSize(SgModifierType* mod_type);
1066 
1068 ROSE_DLL_API size_t getUpcSharedBlockSize(SgType* t);
1069 
1071 ROSE_DLL_API bool isUpcPhaseLessSharedType (SgType* t);
1072 
1074 ROSE_DLL_API bool isUpcPrivateToSharedType(SgType* t);
1075 
1077 ROSE_DLL_API bool isUpcArrayWithThreads(SgArrayType* t);
1078 
1080 ROSE_DLL_API SgType* lookupNamedTypeInParentScopes(const std::string& type_name, SgScopeStatement* scope=NULL);
1081 
1082 // DQ (7/22/2014): Added support for comparing expression types in actual arguments with those expected from the formal function parameter types.
1084 ROSE_DLL_API SgType* getAssociatedTypeFromFunctionTypeList(SgExpression* actual_argument_expression);
1085 
1087 ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument * arg1, SgTemplateArgument * arg2);
1088 
1090 ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList & list1, const SgTemplateArgumentPtrList & list2);
1091 
1093 ROSE_DLL_API bool isEquivalentType (const SgType* lhs, const SgType* rhs);
1094 
1096 ROSE_DLL_API SgFunctionType* findFunctionType (SgType* return_type, SgFunctionParameterTypeList* typeList);
1097 
1100 ROSE_DLL_API bool isEquivalentFunctionType (const SgFunctionType* lhs, const SgFunctionType* rhs);
1101 
1103 
1104 //------------------------------------------------------------------------
1106 
1110 // by Jeremiah
1119 ROSE_DLL_API void addStepToLoopBody(SgScopeStatement* loopStmt, SgStatement* step);
1120 
1122 ROSE_DLL_API void convertForToWhile(SgForStatement* f);
1123 ROSE_DLL_API void convertAllForsToWhiles(SgNode* top);
1125 ROSE_DLL_API void changeContinuesToGotos(SgStatement* stmt, SgLabelStatement* label);
1126 
1128 ROSE_DLL_API SgInitializedName* getLoopIndexVariable(SgNode* loop);
1129 
1132 ROSE_DLL_API bool isLoopIndexVariable(SgInitializedName* ivar, SgNode* subtree_root);
1133 
1135 
1139 ROSE_DLL_API bool hasMultipleInitStatmentsOrExpressions (SgForStatement* for_loop);
1140 
1142 ROSE_DLL_API SgStatement* getLoopBody(SgScopeStatement* loop);
1143 
1144 ROSE_DLL_API void setLoopBody(SgScopeStatement* loop, SgStatement* body);
1145 
1147 ROSE_DLL_API SgStatement* getLoopCondition(SgScopeStatement* loop);
1148 
1150 ROSE_DLL_API void setLoopCondition(SgScopeStatement* loop, SgStatement* cond);
1151 
1155 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);
1156 
1158 ROSE_DLL_API bool isCanonicalDoLoop(SgFortranDo* loop,SgInitializedName** ivar/*=NULL*/, SgExpression** lb/*=NULL*/, SgExpression** ub/*=NULL*/, SgExpression** step/*=NULL*/, SgStatement** body/*=NULL*/, bool *hasIncrementalIterationSpace/*= NULL*/, bool* isInclusiveUpperBound/*=NULL*/);
1159 
1161 ROSE_DLL_API void setLoopLowerBound(SgNode* loop, SgExpression* lb);
1162 
1164 ROSE_DLL_API void setLoopUpperBound(SgNode* loop, SgExpression* ub);
1165 
1167 ROSE_DLL_API void setLoopStride(SgNode* loop, SgExpression* stride);
1168 
1169 
1171 ROSE_DLL_API bool normalizeForLoopInitDeclaration(SgForStatement* loop);
1172 
1174 ROSE_DLL_API bool unnormalizeForLoopInitDeclaration(SgForStatement* loop);
1175 
1187 ROSE_DLL_API bool forLoopNormalization(SgForStatement* loop, bool foldConstant = true);
1188 
1192 ROSE_DLL_API bool normalizeForLoopTest(SgForStatement* loop);
1193 ROSE_DLL_API bool normalizeForLoopIncrement(SgForStatement* loop);
1194 
1196 ROSE_DLL_API bool doLoopNormalization(SgFortranDo* loop);
1197 
1199 ROSE_DLL_API bool loopUnrolling(SgForStatement* loop, size_t unrolling_factor);
1200 
1202 ROSE_DLL_API bool loopInterchange(SgForStatement* loop, size_t depth, size_t lexicoOrder);
1203 
1205 ROSE_DLL_API bool loopTiling(SgForStatement* loopNest, size_t targetLevel, size_t tileSize);
1206 
1207 //Winnie Loop Collapsing
1208 SgExprListExp * loopCollapsing(SgForStatement* target_loop, size_t collapsing_factor);
1209 
1211  SgForStatement * for_loop,
1212  SgVariableSymbol * & iterator,
1213  SgExpression * & lower_bound,
1214  SgExpression * & upper_bound,
1215  SgExpression * & stride
1216 );
1217 
1219 
1220 //------------------------------------------------------------------------
1222 
1226 template <typename NodeType>
1228 std::vector<NodeType*> querySubTree(SgNode* top, VariantT variant = (VariantT)NodeType::static_variant)
1229  {
1230 #if 0
1231  printf ("Top of SageInterface::querySubTree() \n");
1232 #endif
1233 
1234  Rose_STL_Container<SgNode*> nodes = NodeQuery::querySubTree(top,variant);
1235  std::vector<NodeType*> result(nodes.size(), NULL);
1236  int count = 0;
1237 #if 0
1238  printf ("In SageInterface::querySubTree(): before initialization loop \n");
1239 #endif
1240 
1241  for (Rose_STL_Container<SgNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i, ++count)
1242  {
1243 #if 0
1244  printf ("In SageInterface::querySubTree(): in loop: count = %d \n",count);
1245 #endif
1246  NodeType* node = dynamic_cast<NodeType*>(*i);
1247  ROSE_ASSERT (node);
1248  result[count] = node;
1249  }
1250 #if 0
1251  printf ("Leaving SageInterface::querySubTree(): after initialization loop \n");
1252 #endif
1253 
1254  return result;
1255  }
1260  std::vector < SgFile * >generateFileList ();
1261 
1266 ROSE_DLL_API SgProject * getProject();
1267 
1269  SgProject * getProject(const SgNode * node);
1270 
1272 template <typename NodeType>
1273 static std::vector<NodeType*> getSgNodeListFromMemoryPool()
1274 {
1275  // This function uses a memory pool traversal specific to the SgFile IR nodes
1276  class MyTraversal : public ROSE_VisitTraversal
1277  {
1278  public:
1279  std::vector<NodeType*> resultlist;
1280  void visit ( SgNode* node)
1281  {
1282  NodeType* result = dynamic_cast<NodeType* > (node);
1283  ROSE_ASSERT(result!= NULL);
1284  if (result!= NULL)
1285  {
1286  resultlist.push_back(result);
1287  }
1288  };
1289  virtual ~MyTraversal() {}
1290  };
1291 
1292  MyTraversal my_traversal;
1293  NodeType::traverseMemoryPoolNodes(my_traversal);
1294  return my_traversal.resultlist;
1295 }
1296 
1297 
1300 ROSE_DLL_API SgFunctionDeclaration* findMain(SgNode* currentNode);
1301 
1303 SgStatement* findLastDeclarationStatement(SgScopeStatement * scope, bool includePragma = false);
1304 
1305  //midend/programTransformation/partialRedundancyElimination/pre.h
1307 std::vector<SgVariableSymbol*> getSymbolsUsedInExpression(SgExpression* expr);
1308 
1310 
1315 std::vector<SgBreakStmt*> findBreakStmts(SgStatement* code, const std::string& fortranLabel = "");
1316 
1318 
1323 std::vector<SgContinueStmt*> findContinueStmts(SgStatement* code, const std::string& fortranLabel = "");
1324 std::vector<SgGotoStatement*> findGotoStmts(SgStatement* scope, SgLabelStatement* l);
1325 std::vector<SgStatement*> getSwitchCases(SgSwitchStatement* sw);
1326 
1328 void collectVarRefs(SgLocatedNode* root, std::vector<SgVarRefExp* >& result);
1329 
1331 template <typename T>
1332 T* findDeclarationStatement(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining)
1333  {
1334  bool found = false;
1335 
1336 #if 0
1337  printf ("In findDeclarationStatement(): root = %p \n",root);
1338  printf ("In findDeclarationStatement(): name = %s \n",name.c_str());
1339  printf ("In findDeclarationStatement(): scope = %p \n",scope);
1340  printf ("In findDeclarationStatement(): isDefining = %s \n",isDefining ? "true" : "false");
1341 #endif
1342 
1343  // Do we really want a NULL pointer to be acceptable input to this function?
1344  // Maybe we should have an assertion that it is non-null?
1345  if (!root) return NULL;
1346 
1347  T* decl = dynamic_cast<T*>(root);
1348 
1349 #if 0
1350  printf ("In findDeclarationStatement(): decl = %p \n",decl);
1351 #endif
1352 
1353  if (decl != NULL)
1354  {
1355  if (scope)
1356  {
1357  if ((decl->get_scope() == scope) && (decl->search_for_symbol_from_symbol_table()->get_name() == name))
1358  {
1359  found = true;
1360  }
1361  }
1362  else // Liao 2/9/2010. We should allow NULL scope
1363  {
1364 #if 0
1365  // DQ (12/6/2016): Include this into the debugging code to aboid compiler warning about unused variable.
1366  SgSymbol* symbol = decl->search_for_symbol_from_symbol_table();
1367  printf ("In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table() = %p \n",symbol);
1368  printf ("In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table()->get_name() = %s \n",symbol->get_name().str());
1369 #endif
1370  if (decl->search_for_symbol_from_symbol_table()->get_name() == name)
1371  {
1372  found = true;
1373  }
1374  }
1375  }
1376 
1377  if (found)
1378  {
1379  if (isDefining)
1380  {
1381 #if 0
1382  printf ("In findDeclarationStatement(): decl->get_firstNondefiningDeclaration() = %p \n",decl->get_firstNondefiningDeclaration());
1383  printf ("In findDeclarationStatement(): decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1384 #endif
1385  ROSE_ASSERT (decl->get_definingDeclaration() != NULL);
1386 #if 0
1387  printf ("In findDeclarationStatement(): returing decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1388 #endif
1389  return dynamic_cast<T*> (decl->get_definingDeclaration());
1390  }
1391  else
1392  {
1393 #if 0
1394  printf ("In findDeclarationStatement(): returing decl = %p \n",decl);
1395 #endif
1396  return decl;
1397  }
1398  }
1399 
1400  std::vector<SgNode*> children = root->get_traversalSuccessorContainer();
1401 
1402 #if 0
1403  printf ("In findDeclarationStatement(): children.size() = %zu \n",children.size());
1404 #endif
1405 
1406  // DQ (4/10/2016): Note that if we are searching for a function member that has it's defining
1407  // declaration defined outside of the class then it will not be found in the child list.
1408  for (std::vector<SgNode*>::const_iterator i = children.begin(); i != children.end(); ++i)
1409  {
1410  T* target = findDeclarationStatement<T> (*i,name,scope,isDefining);
1411 
1412  if (target)
1413  {
1414  return target;
1415  }
1416  }
1417 
1418  return NULL;
1419  }
1421  SgFunctionDeclaration* findFunctionDeclaration(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining);
1422 
1423 #if 0 //TODO
1424  // 1. preorder traversal from current SgNode till find next SgNode of type V_SgXXX
1425  // until reach the end node
1426  SgNode* getNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
1427 
1428  // 2. return all nodes of type VariantT following the source node
1429  std::vector<SgNode*> getAllNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
1430 #endif
1431 
1433 
1434 //------------------------------------------------------------------------
1436 
1439 // remember to put const to all arguments.
1440 
1441 
1456 template <typename NodeType>
1457 NodeType* getEnclosingNode(const SgNode* astNode, const bool includingSelf = false)
1458  {
1459 #define DEBUG_GET_ENCLOSING_NODE 0
1460 
1461 #if 1 /* TOP_LEVEL_IF */
1462  // DQ (12/31/2019): This version does not detect a cycle that Robb's version detects in processing Cxx11_tests/test2016_23.C.
1463  // This will have to be investigated seperately from the issue I am working on currently.
1464 
1465  // DQ (10/20/2012): This is the older version of this implementation. Until I am sure that
1466  // the newer version (below) is what we want to use I will resolve this conflict by keeping
1467  // the previous version in place.
1468 
1469  if (NULL == astNode)
1470  {
1471  return NULL;
1472  }
1473 
1474  if ( (includingSelf ) && (dynamic_cast<const NodeType*>(astNode)) )
1475  {
1476  return const_cast<NodeType*>(dynamic_cast<const NodeType*> (astNode));
1477  }
1478 
1479  // DQ (3/5/2012): Check for reference to self...
1480  ROSE_ASSERT(astNode->get_parent() != astNode);
1481 
1482  SgNode* parent = astNode->get_parent();
1483 
1484  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1485  SgNode* previouslySeenParent = parent;
1486  bool foundCycle = false;
1487  int counter = 0;
1488 
1489 #if DEBUG_GET_ENCLOSING_NODE
1490  printf ("In getEnclosingNode(): previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->class_name().c_str());
1491 #endif
1492 
1493  while ( (foundCycle == false) && (parent != NULL) && (!dynamic_cast<const NodeType*>(parent)) )
1494  {
1495  ROSE_ASSERT(parent->get_parent() != parent);
1496 
1497 #if DEBUG_GET_ENCLOSING_NODE
1498  printf (" --- parent = %p = %s \n",parent,parent->class_name().c_str());
1499  printf (" --- --- parent->get_parent() = %p = %s \n",parent->get_parent(),parent->get_parent()->class_name().c_str());
1500 #endif
1501 
1502 #if 1
1503  // DQ (1/8/2020): ROSE-82 (on RZ) This limit needs to be larger and increasing it to 500 was enough
1504  // for a specific code with a long chain of if-then-else nesting, So to make this sufficent for more
1505  // general code we have increased the lomit to 100,000. Note that 50 was not enough for real code,
1506  // but was enough for our regression tests.
1507  // DQ (12/30/2019): This is added to support detection of infinite loops over parent pointers.
1508  // if (counter >= 500)
1509  if (counter >= 100000)
1510  {
1511  printf ("Exiting: In getEnclosingNode(): loop limit exceeded: counter = %d \n",counter);
1512  ROSE_ABORT();
1513  }
1514 #endif
1515  parent = parent->get_parent();
1516 
1517  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1518  // ROSE_ASSERT(parent != previouslySeenParent);
1519  if (parent == previouslySeenParent)
1520  {
1521  foundCycle = true;
1522  }
1523  counter++;
1524 
1525  }
1526 
1527 #if DEBUG_GET_ENCLOSING_NODE
1528  printf ("previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->class_name().c_str());
1529 #endif
1530 
1531  parent = previouslySeenParent;
1532 
1533  SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(parent);
1534  if (declarationStatement != NULL)
1535  {
1536 #if 0
1537  printf ("Found a SgDeclarationStatement \n");
1538 #endif
1539  SgDeclarationStatement* definingDeclaration = declarationStatement->get_definingDeclaration();
1540  SgDeclarationStatement* firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1541 
1542 #if 0
1543  printf (" --- declarationStatement = %p \n",declarationStatement);
1544  printf (" --- definingDeclaration = %p \n",definingDeclaration);
1545  if (definingDeclaration != NULL && definingDeclaration->get_parent() != NULL)
1546  printf (" --- definingDeclaration ->get_parent() = %p = %s \n",definingDeclaration->get_parent(),definingDeclaration->get_parent()->class_name().c_str());
1547  printf (" --- firstNondefiningDeclaration = %p \n",firstNondefiningDeclaration);
1548  if (firstNondefiningDeclaration != NULL && firstNondefiningDeclaration->get_parent() != NULL)
1549  printf (" --- firstNondefiningDeclaration ->get_parent() = %p = %s \n",firstNondefiningDeclaration->get_parent(),firstNondefiningDeclaration->get_parent()->class_name().c_str());
1550 #endif
1551  if (definingDeclaration != NULL && declarationStatement != firstNondefiningDeclaration)
1552  {
1553 #if 0
1554  printf ("Found a nondefining declaration so use the non-defining declaration instead \n");
1555 #endif
1556  // DQ (10/19/2012): Use the defining declaration instead.
1557  // parent = firstNondefiningDeclaration;
1558  parent = definingDeclaration;
1559  }
1560  }
1561 
1562 #if 0
1563  printf ("reset: previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->class_name().c_str());
1564 #endif
1565 
1566  // DQ (10/19/2012): This branch is just to document the cycle that was previously detected, it is for
1567  // debugging only. Thus it ony make sense for it to be executed when "(foundCycle == true)". However,
1568  // this will have to be revisited later since it appears clear that it is a problem for the binary analysis
1569  // work when it is visited for this case. Since the cycle is detected, but there is no assertion on the
1570  // cycle, we don't exit when a cycle is identified (which is the point of the code below).
1571  // Note also that I have fixed the code (above and below) to only chase pointers through defining
1572  // declarations (where they exist), this is important since non-defining declarations can be almost
1573  // anywhere (and thus chasing them can make it appear that there are cycles where there are none
1574  // (I think); test2012_234.C demonstrates an example of this.
1575  // DQ (10/9/2012): Robb has suggested this change to fix the binary analysis work.
1576  // if (foundCycle == true)
1577  if (foundCycle == false)
1578  {
1579 
1580 
1581  while ( (parent != NULL) && (!dynamic_cast<const NodeType*>(parent)) )
1582  {
1583  ROSE_ASSERT(parent->get_parent() != parent);
1584 #if 0
1585  printf ("In getEnclosingNode() (2nd try): parent = %p = %s \n",parent,parent->class_name().c_str());
1586  if (parent->get_file_info() != NULL)
1587  parent->get_file_info()->display("In getEnclosingNode() (2nd try): debug");
1588 #endif
1589  SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(parent);
1590  if (declarationStatement != NULL)
1591  {
1592 #if DEBUG_GET_ENCLOSING_NODE
1593  printf ("Found a SgDeclarationStatement \n");
1594 #endif
1595  SgDeclarationStatement* definingDeclaration = declarationStatement->get_definingDeclaration();
1596  SgDeclarationStatement* firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1597 #if 0
1598  printf (" --- declarationStatement = %p = %s \n",declarationStatement,(declarationStatement != NULL) ? declarationStatement->class_name().c_str() : "null");
1599 
1600  printf (" --- definingDeclaration = %p \n",definingDeclaration);
1601  if (definingDeclaration != NULL && definingDeclaration->get_parent() != NULL)
1602  printf (" --- definingDeclaration ->get_parent() = %p = %s \n",definingDeclaration->get_parent(),definingDeclaration->get_parent()->class_name().c_str());
1603 
1604  printf (" --- firstNondefiningDeclaration = %p \n",firstNondefiningDeclaration);
1605  if (firstNondefiningDeclaration != NULL && firstNondefiningDeclaration->get_parent() != NULL)
1606  printf (" --- firstNondefiningDeclaration ->get_parent() = %p = %s \n",firstNondefiningDeclaration->get_parent(),firstNondefiningDeclaration->get_parent()->class_name().c_str());
1607 #endif
1608  if (definingDeclaration != NULL && declarationStatement != firstNondefiningDeclaration)
1609  {
1610 #if 0
1611  printf ("Found a nondefining declaration so use the firstNondefining declaration instead \n");
1612 #endif
1613  // DQ (10/19/2012): Use the defining declaration instead.
1614  // parent = firstNondefiningDeclaration;
1615  parent = definingDeclaration;
1616  }
1617  }
1618 
1619  parent = parent->get_parent();
1620 
1621 #if 1
1622  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1623  ROSE_ASSERT(parent != previouslySeenParent);
1624 #else
1625  printf ("WARNING::WARNING::WARNING commented out assertion for parent != previouslySeenParent \n");
1626  if (parent == previouslySeenParent)
1627  break;
1628 #endif
1629  }
1630  }
1631 
1632  return const_cast<NodeType*>(dynamic_cast<const NodeType*> (parent));
1633 #else /* TOP_LEVEL_IF */
1634  // DQ (10/20/2012): Using Robb's newer version with my modification to use the definingDeclaration rather than firstNondefiningDeclaration (below).
1635 
1636  // Find the parent of specified type, but watch out for cycles in the ancestry (which would cause an infinite loop).
1637  // Cast away const because isSg* functions aren't defined for const node pointers; and our return is not const.
1638  SgNode *node = const_cast<SgNode*>(!astNode || includingSelf ? astNode : astNode->get_parent());
1639  std::set<const SgNode*> seen; // nodes we've seen, in order to detect cycles
1640  while (node) {
1641  if (NodeType *found = dynamic_cast<NodeType*>(node))
1642  return found;
1643 
1644  // FIXME: Cycle detection could be moved elsewhere so we don't need to do it on every call. [RPM 2012-10-09]
1645  // DQ (12/30/2019): Provide more detail in error message.
1646  if (seen.insert(node).second == false)
1647  {
1648  printf ("Error: node is already in set and defines a cycle: node = %p = %s \n",node,node->class_name().c_str());
1649  std::set<const SgNode*>::const_iterator i = seen.begin();
1650  while (i != seen.end())
1651  {
1652  const SgNode* element = *i;
1653  printf (" --- seen element: element = %p = %s \n",element,element->class_name().c_str());
1654  i++;
1655  }
1656 
1657  printf ("Exiting after error! \n");
1658  ROSE_ABORT();
1659  }
1660  // ROSE_ASSERT(seen.insert(node).second);
1661 
1662  // Traverse to parent (declaration statements are a special case)
1663  if (SgDeclarationStatement *declarationStatement = isSgDeclarationStatement(node)) {
1664  SgDeclarationStatement *definingDeclaration = declarationStatement->get_definingDeclaration();
1665  SgDeclarationStatement *firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1666  if (definingDeclaration && firstNondefiningDeclaration && declarationStatement != firstNondefiningDeclaration) {
1667  // DQ (10/19/2012): Use the defining declaration instead.
1668  // node = firstNondefiningDeclaration;
1669  node = definingDeclaration;
1670  }
1671  } else {
1672  node = node->get_parent();
1673  }
1674  }
1675  return NULL;
1676 #endif /* TOP_LEVEL_IF */
1677  }
1678 
1680  ROSE_DLL_API SgSourceFile* getEnclosingSourceFile(SgNode* n, const bool includingSelf=false);
1681 
1683  ROSE_DLL_API SgScopeStatement* getScope(const SgNode* astNode);
1684 
1686  ROSE_DLL_API SgScopeStatement* getEnclosingScope(SgNode* n, const bool includingSelf=false);
1687 
1689  ROSE_DLL_API SgGlobal* getGlobalScope( const SgNode* astNode);
1690 
1691  // DQ (12/7/2020): This is supporting the recognition of functions in header files from two different AST.
1693  ROSE_DLL_API bool hasSameGlobalScope ( SgStatement* statement_1, SgStatement* statement_2 );
1694 
1696  ROSE_DLL_API SgFunctionDefinition* getEnclosingProcedure(SgNode* n, const bool includingSelf=false);
1697 
1698  ROSE_DLL_API SgFunctionDefinition* getEnclosingFunctionDefinition(SgNode* astNode, const bool includingSelf=false);
1699 
1701  ROSE_DLL_API SgStatement* getEnclosingStatement(SgNode* n);
1702 
1705 
1708 
1710  ROSE_DLL_API SgScopeStatement* findEnclosingLoop(SgStatement* s, const std::string& fortranLabel = "", bool stopOnSwitches = false);
1711 
1713  ROSE_DLL_API SgFunctionDeclaration * getEnclosingFunctionDeclaration (SgNode * astNode, const bool includingSelf=false);
1714  //roseSupport/utility_functions.h
1716  ROSE_DLL_API SgFile* getEnclosingFileNode (SgNode* astNode );
1717 
1720 
1722  ROSE_DLL_API SgClassDefinition* getEnclosingClassDefinition(SgNode* astnode, const bool includingSelf=false);
1723 
1725  ROSE_DLL_API SgClassDeclaration* getEnclosingClassDeclaration( SgNode* astNode );
1726 
1727  // DQ (2/7/2019): Adding support for name qualification of variable references associated with SgPointerMemberType function parameters.
1729  ROSE_DLL_API SgExprListExp* getEnclosingExprListExp(SgNode* astNode, const bool includingSelf = false);
1730 
1731  // DQ (2/7/2019): Need a function to return when an expression is in an expression subtree.
1732  // This is part of index evaluation ofr expressions in function argument lists, but likely usefule elsewhere as well.
1733  ROSE_DLL_API bool isInSubTree(SgExpression* subtree, SgExpression* exp);
1734 
1735  // DQ (2/7/2019): Need a function to return the SgFunctionDeclaration from a SgFunctionCallExp.
1736  ROSE_DLL_API SgFunctionDeclaration* getFunctionDeclaration ( SgFunctionCallExp* functionCallExp );
1737 
1738  // DQ (2/17/2019): Generalizing this support for SgVarRefExp and SgMemberFunctionRefExp nodes.
1739  // DQ (2/8/2019): Adding support for detecting when to use added name qualification for pointer-to-member expressions.
1740  ROSE_DLL_API bool isDataMemberReference(SgVarRefExp* varRefExp);
1741  // ROSE_DLL_API bool isAddressTaken(SgVarRefExp* varRefExp);
1742  ROSE_DLL_API bool isAddressTaken(SgExpression* refExp);
1743 
1744  // DQ (2/17/2019): Adding support for detecting when to use added name qualification for membr function references.
1745  ROSE_DLL_API bool isMemberFunctionMemberReference(SgMemberFunctionRefExp* memberFunctionRefExp);
1746 
1747  // DQ (2/15/2019): Adding support for detecting which class a member reference is being made from.
1748  // ROSE_DLL_API SgClassType* getClassTypeForDataMemberReference(SgVarRefExp* varRefExp);
1749  // ROSE_DLL_API std::list<SgClassType*> getClassTypeChainForDataMemberReference(SgVarRefExp* varRefExp);
1750  ROSE_DLL_API std::list<SgClassType*> getClassTypeChainForMemberReference(SgExpression* refExp);
1751 
1752  ROSE_DLL_API std::set<SgNode*> getFrontendSpecificNodes();
1753 
1754  // DQ (2/17/2019): Display the shared nodes in the AST for debugging.
1755  ROSE_DLL_API void outputSharedNodes( SgNode* node );
1756 
1757  // DQ (10/31/2020): Added function to help debug edits to statements in scopes.
1758  ROSE_DLL_API void displayScope(SgScopeStatement* scope);
1759 
1760 // TODO
1761 #if 0
1762  SgNode * getEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
1763  std::vector<SgNode *> getAllEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
1764  SgVariableDeclaration* findVariableDeclaratin( const string& varname)
1765 
1767 
1768  // e.g. for some expression, find its parent statement
1769  SgStatement* getEnclosingStatement(const SgNode* astNode);
1770 
1771  SgSwitchStatement* getEnclosingSwitch(SgStatement* s);
1772  SgModuleStatement* getEnclosingModuleStatement( const SgNode* astNode);
1773 
1774  // used to build a variable reference for compiler generated code in current scope
1775  SgSymbol * findReachingDefinition (SgScopeStatement* startScope, SgName &name);
1776 #endif
1777 
1778 
1779 //------------------------------------------------------------------------
1781 
1784  // Liao, 1/9/2008
1788  ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project);
1789 
1793  ROSE_DLL_API SgStatement* getLastStatement(SgScopeStatement *scope);
1794 
1796  ROSE_DLL_API SgStatement* getFirstStatement(SgScopeStatement *scope,bool includingCompilerGenerated=false);
1799 
1801  ROSE_DLL_API SgStatement* getNextStatement(SgStatement * currentStmt);
1802 
1804  ROSE_DLL_API SgStatement* getPreviousStatement(SgStatement * currentStmt, bool climbOutScope = true);
1805 #if 0 //TODO
1806  // preorder traversal from current SgNode till find next SgNode of type V_SgXXX
1807  SgNode* getNextSgNode( const SgNode* currentNode, VariantT=V_SgNode);
1808 #endif
1809 
1810  // DQ (11/15/2018): Adding support for traversals over the include file tree.
1812  void listHeaderFiles ( SgIncludeFile* includeFile );
1813 
1814 
1816 
1817 //------------------------------------------------------------------------
1819 
1822  ROSE_DLL_API bool isEqualToIntConst(SgExpression* e, int value);
1824 
1826 
1829  ROSE_DLL_API bool isSameFunction(SgFunctionDeclaration* func1, SgFunctionDeclaration* func2);
1830 
1832  ROSE_DLL_API bool isLastStatement(SgStatement* stmt);
1833 
1835 
1836 //------------------------------------------------------------------------
1838 
1844 #if 1
1846  {
1847  // DQ (11/19/2020): We need to expand the use of this to cover deffered transformations of common SageInterface transformations (e.g. replaceStatement).
1848  // So I needed to move this out of being specific to the outliner and make it more generally data structure in the SageInterface.
1849 
1850  // DQ (11/15/2020): Need to add the concept of deffered transformation to cover replaceStatement operations.
1851 
1852  // DQ (8/7/2019): Store data required to support defering the transformation to insert the outlined function prototypes
1853  // into class declaration (when this is required to support the outlined function's access to protected or private data members).
1854  // This is part of an optimization to support the optimization of header file unparsing (limiting the overhead of supporting any
1855  // header file to just focus on the few (typically one) header file that would have to be unparsed.
1856 
1857  enum TransformationKind
1858  {
1859  // DQ (11/22/2020): Might need to also add SageInterface::addDefaultConstructorIfRequired() and SageStatement::insert_statment()
1860  // to support the processStatements.C transforamtions to pre-process the AST (return expressions and variable initializations).
1861  e_error,
1862  e_default,
1863  e_outliner,
1864  e_replaceStatement,
1865  e_removeStatement,
1866  e_replaceDefiningFunctionDeclarationWithFunctionPrototype,
1867  e_last
1868  };
1869 
1870  TransformationKind deferredTransformationKind;
1871 
1872  // DQ (12/12/2020): Adding a string label so that we can name the different kinds of transformations.
1873  // E.g. moving pattern matched function from header file to dynamic library, vs. replacing function
1874  // definitions in the dynamic library file with function prototypes.
1875  std::string transformationLabel;
1876 
1877  // Remove sets statementToRemove, replace sets statementToRemove and StatementToAdd.
1878  SgStatement* statementToRemove;
1879  SgStatement* statementToAdd;
1880 
1881  SgClassDefinition* class_definition;
1882  SgDeclarationStatement* target_class_member;
1883  SgDeclarationStatement* new_function_prototype;
1884 
1885  typedef std::set<SgClassDefinition *> ClassDefSet_t;
1886  ClassDefSet_t targetClasses;
1887 
1888  typedef std::vector<SgFunctionDeclaration *> FuncDeclList_t;
1889  FuncDeclList_t targetFriends;
1890 
1891  // DQ (2/28/2021): Adding support for outlining where it involves building up pre-transformations.
1892  // For example, in the code segregation, we build a conditiona around the interval of statements
1893  // that we are outlining. This conditional is used to overwrite the first statement in the interval
1894  // list. Because we don't want to transform the AST until after the outlining, we need so save the
1895  // whole interval so that we, after the outlining, remove the statements in the interval after that
1896  // first statement.
1897  typedef std::vector<SgStatement*> IntervalType;
1898  IntervalType statementInterval;
1899  SgStatement* locationToOverwriteWithTransformation;
1900  SgStatement* transformationToOverwriteFirstStatementInInterval;
1901  SgBasicBlock* blockOfStatementsToOutline;
1902 
1903  // DQ (12/5/2019): Added ROSE_DLL_API prefix for Windows support (too all of these functions).
1904  ROSE_DLL_API DeferredTransformation();
1905  ROSE_DLL_API DeferredTransformation(SgClassDefinition* class_definition, SgDeclarationStatement* target_class_member, SgDeclarationStatement* new_function_prototype);
1906  ROSE_DLL_API DeferredTransformation (const DeferredTransformation& X);
1907  ROSE_DLL_API ~DeferredTransformation (void);
1908 
1909  ROSE_DLL_API DeferredTransformation & operator= (const DeferredTransformation& X);
1910 
1911  // DQ (11/20/20): static function to generate specialized version of deferred transformation object.
1912  static ROSE_DLL_API DeferredTransformation replaceDefiningFunctionDeclarationWithFunctionPrototype( SgFunctionDeclaration* functionDeclaration );
1913  static ROSE_DLL_API DeferredTransformation replaceStatement(SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);
1914 
1915  static ROSE_DLL_API std::string outputDeferredTransformationKind(const TransformationKind & kind);
1916  ROSE_DLL_API void display ( std::string label ) const;
1917 
1918  };
1919 #endif
1920 
1921 
1922 // DQ (2/24/2009): Simple function to delete an AST subtree (used in outlining).
1924 ROSE_DLL_API void deleteAST(SgNode* node);
1925 
1928 
1929 // DQ (2/25/2009): Added new function to support outliner.
1931 ROSE_DLL_API void moveStatementsBetweenBlocks ( SgBasicBlock* sourceBlock, SgBasicBlock* targetBlock );
1932 
1934 ROSE_DLL_API void moveStatementsBetweenBlocks ( SgAdaPackageSpec * sourceBlock, SgNamespaceDefinitionStatement* targetBlock );
1935 
1937 ROSE_DLL_API void moveStatementsBetweenBlocks ( SgAdaPackageBody* sourceBlock, SgNamespaceDefinitionStatement* targetBlock );
1938 
1940 ROSE_DLL_API void moveStatementsBetweenBlocks ( SgNamespaceDefinitionStatement* sourceBlock, SgNamespaceDefinitionStatement* targetBlock );
1941 
1943 ROSE_DLL_API void moveVariableDeclaration(SgVariableDeclaration* decl, SgScopeStatement* target_scope);
1945 ROSE_DLL_API void appendStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
1946 
1948 ROSE_DLL_API void appendStatement(SgStatement *stmt, SgForInitStatement* for_init_stmt);
1949 
1951 ROSE_DLL_API void appendStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
1952 
1953 // DQ (2/6/2009): Added function to support outlining into separate file.
1955 ROSE_DLL_API void appendStatementWithDependentDeclaration( SgDeclarationStatement* decl, SgGlobal* scope, SgStatement* original_statement, bool excludeHeaderFiles );
1956 
1959 ROSE_DLL_API void prependStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
1960 
1962 ROSE_DLL_API void prependStatement(SgStatement *stmt, SgForInitStatement* for_init_stmt);
1963 
1966 ROSE_DLL_API void prependStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
1967 
1971 ROSE_DLL_API bool hasSimpleChildrenList (SgScopeStatement* scope);
1972 
1974 ROSE_DLL_API void insertStatement(SgStatement *targetStmt, SgStatement* newStmt, bool insertBefore= true, bool autoMovePreprocessingInfo = true);
1975 
1977 //target's scope
1978 ROSE_DLL_API void insertStatementList(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts, bool insertBefore= true);
1979 
1981 ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
1982 
1984 ROSE_DLL_API void insertStatementListBefore(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts);
1985 
1987 ROSE_DLL_API void insertStatementAfter(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
1988 
1990 ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmt);
1991 
1993 ROSE_DLL_API void insertStatementAfterLastDeclaration(SgStatement* stmt, SgScopeStatement* scope);
1994 
1996 ROSE_DLL_API void insertStatementAfterLastDeclaration(std::vector<SgStatement*> stmt_list, SgScopeStatement* scope);
1997 
1999 // then the statement is inserted at the end of the scope.
2000 ROSE_DLL_API void insertStatementBeforeFirstNonDeclaration(SgStatement *newStmt, SgScopeStatement *scope,
2001  bool movePreprocessingInfo=true);
2002 
2004 //then the new statements are inserted at the end of the scope.
2005 ROSE_DLL_API void insertStatementListBeforeFirstNonDeclaration(const std::vector<SgStatement*> &newStmts, SgScopeStatement *scope);
2006 
2007 // DQ (11/21/2018): We need to sometimes insert something after the last statement of the collection from rose_edg_required_macros_and_functions.h.
2008 ROSE_DLL_API SgStatement* lastFrontEndSpecificStatement( SgGlobal* globalScope );
2009 
2011 ROSE_DLL_API void removeStatement(SgStatement* stmt, bool autoRelocatePreprocessingInfo = true);
2012 
2014 ROSE_DLL_API void deepDelete(SgNode* root);
2015 
2017 ROSE_DLL_API void replaceStatement(SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);
2018 
2020 ROSE_DLL_API SgNode* replaceWithPattern (SgNode * anchor, SgNode* new_pattern);
2021 
2023 // Essentially replace variable a with b.
2024 ROSE_DLL_API void replaceVariableReferences(SgVariableSymbol* old_sym, SgVariableSymbol* new_sym, SgScopeStatement * scope );
2025 
2026 // DQ (11/12/2018): Adding test to avoid issues that we can't test for in the unparsing of header files using the token based unparsing.
2030 ROSE_DLL_API bool statementCanBeTransformed(SgStatement* stmt);
2031 
2032 
2043 std::pair<SgVariableDeclaration*, SgExpression* > createTempVariableForExpression(SgExpression* expression,
2044  SgScopeStatement* scope, bool initializeInDeclaration, SgAssignOp** reEvaluate = NULL);
2045 
2046 /* This function creates a temporary variable for a given expression in the given scope
2047  This is different from SageInterface::createTempVariableForExpression in that it does not
2048  try to be smart to create pointers to reference types and so on. The tempt is initialized to expression.
2049  The caller is responsible for setting the parent of SgVariableDeclaration since buildVariableDeclaration
2050  may not set_parent() when the scope stack is empty. See programTransformation/extractFunctionArgumentsNormalization/ExtractFunctionArguments.C for sample usage.
2051  @param expression Expression which will be replaced by a variable
2052  @param scope scope in which the temporary variable will be generated
2053 */
2054 
2055 std::pair<SgVariableDeclaration*, SgExpression*> createTempVariableAndReferenceForExpression
2056  (SgExpression* expression, SgScopeStatement* scope);
2057 
2059 
2066 
2068 ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression*);
2069 
2071 ROSE_DLL_API void appendExpressionList(SgExprListExp *, const std::vector<SgExpression*>&);
2072 
2074 template <class actualFunction>
2075 void setParameterList(actualFunction *func,SgFunctionParameterList *paralist) {
2076 
2077  // TODO consider the difference between C++ and Fortran
2078  // fixup the scope of arguments,no symbols for nondefining function declaration's arguments
2079 
2080  // DQ (11/25/2011): templated function so that we can handle both
2081  // SgFunctionDeclaration and SgTemplateFunctionDeclaration (and their associated member
2082  // function derived classes).
2083 
2084  ROSE_ASSERT(func != NULL);
2085  ROSE_ASSERT(paralist != NULL);
2086 
2087 #if 0
2088  // At this point we don't have cerr and endl defined, so comment this code out.
2089  // Warn to users if a paralist is being shared
2090  if (paralist->get_parent() !=NULL)
2091  {
2092  cerr << "Waring! Setting a used SgFunctionParameterList to function: "
2093  << (func->get_name()).getString()<<endl
2094  << " Sharing parameter lists can corrupt symbol tables!"<<endl
2095  << " Please use deepCopy() to get an exclusive parameter list for each function declaration!"<<endl;
2096  // ROSE_ASSERT(false);
2097  }
2098 #endif
2099 
2100  // Liao,2/5/2008 constructor of SgFunctionDeclaration will automatically generate SgFunctionParameterList, so be cautious when set new paralist!!
2101  if (func->get_parameterList() != NULL)
2102  {
2103  if (func->get_parameterList() != paralist)
2104  {
2105  delete func->get_parameterList();
2106  }
2107  }
2108 
2109  func->set_parameterList(paralist);
2110  paralist->set_parent(func);
2111 
2113  {
2114  // Ada stores variable declarations in the function parameter scope (for functions)
2115  // and in a discriminantScope (for discriminated declarations).
2116  // ==> just make sure that these are set.
2117  SgInitializedNamePtrList& args = paralist->get_args();
2118  for (SgInitializedNamePtrList::iterator i = args.begin(); i != args.end(); ++i)
2119  {
2120  ROSE_ASSERT(*i && isSgVariableDeclaration((*i)->get_declptr()));
2121  }
2122  }
2123  else
2124  {
2125  // DQ (5/15/2012): Need to set the declptr in each SgInitializedName IR node.
2126  // This is needed to support the AST Copy mechanism (at least). The files: test2005_150.C,
2127  // test2012_81.C and testcode2012_82.C demonstrate this problem.
2128  SgInitializedNamePtrList & args = paralist->get_args();
2129  for (SgInitializedNamePtrList::iterator i = args.begin(); i != args.end(); i++)
2130  {
2131  (*i)->set_declptr(func);
2132  }
2133  }
2134  }
2135 
2137 ROSE_DLL_API void setPragma(SgPragmaDeclaration* decl, SgPragma *pragma);
2138 
2140 ROSE_DLL_API void replaceExpression(SgExpression* oldExp, SgExpression* newExp, bool keepOldExp=false);
2141 
2143 ROSE_DLL_API void replaceExpressionWithStatement(SgExpression* from,
2147 ROSE_DLL_API void replaceSubexpressionWithStatement(SgExpression* from,
2149 
2151 ROSE_DLL_API void setOperand(SgExpression* target, SgExpression* operand);
2152 
2154 ROSE_DLL_API void setLhsOperand(SgExpression* target, SgExpression* lhs);
2155 
2157 ROSE_DLL_API void setRhsOperand(SgExpression* target, SgExpression* rhs);
2158 
2160 ROSE_DLL_API void removeAllOriginalExpressionTrees(SgNode* top);
2161 
2162 // DQ (1/25/2010): Added support for directories
2164 ROSE_DLL_API void moveToSubdirectory ( std::string directoryName, SgFile* file );
2165 
2167 ROSE_DLL_API SgStatement* findSurroundingStatementFromSameFile(SgStatement* targetStmt, bool & surroundingStatementPreceedsTargetStatement);
2168 
2170 ROSE_DLL_API void moveCommentsToNewStatement(SgStatement* sourceStatement, const std::vector<int> & indexList, SgStatement* targetStatement, bool surroundingStatementPreceedsTargetStatement);
2171 
2172 // DQ (7/19/2015): This is required to support general unparsing of template instantations for the GNU g++
2173 // compiler which does not permit name qualification to be used to support the expression of the namespace
2174 // where a template instantiatoon would be places. Such name qualification would also sometimes require
2175 // global qualification which is also not allowed by the GNU g++ compiler. These issues appear to be
2176 // specific to the GNU compiler versions, at least versions 4.4 through 4.8.
2178 ROSE_DLL_API void moveDeclarationToAssociatedNamespace ( SgDeclarationStatement* declarationStatement );
2179 
2180 ROSE_DLL_API bool isTemplateInstantiationNode(SgNode* node);
2181 
2183 
2184 // DQ (12/1/2015): Adding support for fixup internal data struuctures that have references to statements (e.g. macro expansions).
2185 ROSE_DLL_API void resetInternalMapsForTargetStatement(SgStatement* sourceStatement);
2186 
2187 // DQ (6/7/2019): Add support for transforming function definitions to function prototypes in a subtree.
2188 // We might have to make this specific to a file (only traversing the functions in that file).
2197 
2198 // DQ (11/10/2019): Lower level support for convertFunctionDefinitionsToFunctionPrototypes().
2199 // DQ (10/27/2020): Need to return the generated function prototype (incase we want to mark it for output or template unparsing from the AST).
2200 // ROSE_DLL_API void replaceDefiningFunctionDeclarationWithFunctionPrototype ( SgFunctionDeclaration* functionDeclaration );
2201 // ROSE_DLL_API SgDeclarationStatement* replaceDefiningFunctionDeclarationWithFunctionPrototype ( SgFunctionDeclaration* functionDeclaration );
2203 ROSE_DLL_API std::vector<SgFunctionDeclaration*> generateFunctionDefinitionsList(SgNode* node);
2204 
2205 // DQ (10/29/2020): build a function prototype for all but member functions outside of the class (except for template instantiations).
2206 // The reason why member functions outside of the class are an exception is because they can not be used except in a class and there
2207 // would already be one present for the code to compile.
2208 ROSE_DLL_API SgFunctionDeclaration* buildFunctionPrototype ( SgFunctionDeclaration* functionDeclaration );
2209 
2210 
2212 //------------------------------------------------------------------------
2214 
2221 
2227 ROSE_DLL_API int fixVariableReferences(SgNode* root, bool cleanUnusedSymbol=true);
2228 
2230 
2234 ROSE_DLL_API void fixVariableDeclaration(SgVariableDeclaration* varDecl, SgScopeStatement* scope);
2235 
2237 ROSE_DLL_API void fixStructDeclaration(SgClassDeclaration* structDecl, SgScopeStatement* scope);
2239 ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration* classDecl, SgScopeStatement* scope);
2240 
2242 ROSE_DLL_API void fixNamespaceDeclaration(SgNamespaceDeclarationStatement* structDecl, SgScopeStatement* scope);
2243 
2244 
2246 ROSE_DLL_API void fixLabelStatement(SgLabelStatement* label_stmt, SgScopeStatement* scope);
2247 
2249 ROSE_DLL_API void setFortranNumericLabel(SgStatement* stmt, int label_value,
2250  SgLabelSymbol::label_type_enum label_type=SgLabelSymbol::e_start_label_type,
2251  SgScopeStatement* label_scope=NULL);
2252 
2254 ROSE_DLL_API int suggestNextNumericLabel(SgFunctionDefinition* func_def);
2255 
2257 ROSE_DLL_API void fixFunctionDeclaration(SgFunctionDeclaration* stmt, SgScopeStatement* scope);
2258 
2260 ROSE_DLL_API void fixTemplateDeclaration(SgTemplateDeclaration* stmt, SgScopeStatement* scope);
2261 
2263 ROSE_DLL_API void fixStatement(SgStatement* stmt, SgScopeStatement* scope);
2264 
2265 // DQ (6/11/2015): This reports the statements that are marked as transformed (used to debug the token-based unparsing).
2267 ROSE_DLL_API std::set<SgStatement*> collectTransformedStatements( SgNode* node );
2268 
2270 ROSE_DLL_API std::set<SgStatement*> collectModifiedStatements( SgNode* node );
2271 
2273 ROSE_DLL_API std::set<SgLocatedNode*> collectModifiedLocatedNodes( SgNode* node );
2274 
2275 // DQ (6/5/2019): Use the previously constructed set (above) to reset the IR nodes to be marked as isModified.
2277 ROSE_DLL_API void resetModifiedLocatedNodes(const std::set<SgLocatedNode*> & modifiedNodeSet);
2278 
2279 
2280 // DQ (10/23/2018): Report nodes that are marked as modified.
2281 ROSE_DLL_API void reportModifiedStatements(const std::string & label, SgNode* node);
2282 
2283 // DQ (3/22/2019): Translate CPP directives from attached preprocessor information to CPP Directive Declaration IR nodes.
2284 ROSE_DLL_API void translateToUseCppDeclarations( SgNode* n );
2285 
2286 ROSE_DLL_API void translateScopeToUseCppDeclarations( SgScopeStatement* scope );
2287 
2288 ROSE_DLL_API std::vector<SgC_PreprocessorDirectiveStatement*> translateStatementToUseCppDeclarations( SgStatement* statement, SgScopeStatement* scope);
2289 ROSE_DLL_API void printOutComments ( SgLocatedNode* locatedNode );
2290 ROSE_DLL_API bool skipTranslateToUseCppDeclaration( PreprocessingInfo* currentPreprocessingInfo );
2291 
2292 // DQ (12/2/2019): Debugging support.
2293 ROSE_DLL_API void outputFileIds( SgNode* node );
2294 
2295 
2297 
2299 
2305 
2306 //------------------------------------------------------------------------
2308 
2312 ROSE_DLL_API bool
2314 collectReadWriteRefs(SgStatement* stmt, std::vector<SgNode*>& readRefs, std::vector<SgNode*>& writeRefs, bool useCachedDefUse=false);
2315 
2317 ROSE_DLL_API bool collectReadWriteVariables(SgStatement* stmt, std::set<SgInitializedName*>& readVars, std::set<SgInitializedName*>& writeVars, bool coarseGrain=true);
2318 
2320 ROSE_DLL_API void collectReadOnlyVariables(SgStatement* stmt, std::set<SgInitializedName*>& readOnlyVars, bool coarseGrain=true);
2321 
2323 ROSE_DLL_API void collectReadOnlySymbols(SgStatement* stmt, std::set<SgVariableSymbol*>& readOnlySymbols, bool coarseGrain=true);
2324 
2326 ROSE_DLL_API bool isUseByAddressVariableRef(SgVarRefExp* ref);
2327 
2329 ROSE_DLL_API void collectUseByAddressVariableRefs (const SgStatement* s, std::set<SgVarRefExp* >& varSetB);
2330 
2331 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
2332 ROSE_DLL_API LivenessAnalysis * call_liveness_analysis(SgProject* project, bool debug=false);
2334 
2336 ROSE_DLL_API void getLiveVariables(LivenessAnalysis * liv, SgForStatement* loop, std::set<SgInitializedName*>& liveIns, std::set<SgInitializedName*> & liveOuts);
2337 #endif
2338 
2340 ROSE_DLL_API void ReductionRecognition(SgForStatement* loop, std::set< std::pair <SgInitializedName*, OmpSupport::omp_construct_enum> > & results);
2341 
2343 
2344 ROSE_DLL_API void constantFolding(SgNode* r);
2345 
2347 
2349 ROSE_DLL_API int instrumentEndOfFunction(SgFunctionDeclaration * func, SgStatement* s);
2350 
2352 ROSE_DLL_API void removeJumpsToNextStatement(SgNode*);
2353 
2355 ROSE_DLL_API void removeUnusedLabels(SgNode* top, bool keepChild =false);
2356 
2358 ROSE_DLL_API std::set<SgLabelStatement*> findUnusedLabels (SgNode* top);
2359 
2361 ROSE_DLL_API void removeConsecutiveLabels(SgNode* top);
2362 
2364 
2370 ROSE_DLL_API bool mergeDeclarationAndAssignment (SgVariableDeclaration* decl, SgExprStatement* assign_stmt, bool removeAssignStmt = true);
2371 
2372 
2374 ROSE_DLL_API bool mergeAssignmentWithDeclaration (SgExprStatement* assign_stmt, SgVariableDeclaration* decl, bool removeAssignStmt = true);
2375 
2377 
2380 ROSE_DLL_API bool mergeDeclarationWithAssignment (SgVariableDeclaration* decl, SgExprStatement* assign_stmt);
2381 
2383 
2388 
2390 ROSE_DLL_API int splitVariableDeclaration (SgScopeStatement* scope, bool topLevelOnly = true);
2391 
2393 
2400  ROSE_DLL_API SgAssignInitializer* splitExpression(SgExpression* from, std::string newName = "");
2401 
2403 ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression* expr);
2404 
2406 ROSE_DLL_API void removeLabeledGotos(SgNode* top);
2407 
2409 ROSE_DLL_API void changeBreakStatementsToGotos(SgStatement* loopOrSwitch);
2410 
2413 
2416 
2419 
2422 
2425 
2428 
2431 
2434 
2436 ROSE_DLL_API SgBasicBlock* ensureBasicBlockAsFalseBodyOfIf(SgIfStmt* ifs, bool createEmptyBody = true);
2437 
2440 
2443 
2444 // DQ (1/18/2015): This is added to support better quality token-based unparsing.
2446 ROSE_DLL_API void cleanupNontransformedBasicBlockNode();
2447 
2448 // DQ (1/18/2015): This is added to support better quality token-based unparsing.
2450 ROSE_DLL_API void recordNormalizations(SgStatement* s);
2451 
2454 bool isBodyStatement (SgStatement* s);
2455 
2457 void changeAllBodiesToBlocks(SgNode* top, bool createEmptyBody = true);
2458 
2459 // The same as changeAllBodiesToBlocks(SgNode* top). Phased out.
2460 //void changeAllLoopBodiesToBlocks(SgNode* top);
2461 
2464 
2465 #if 0
2466 
2469 SgLocatedNode* ensureBasicBlockAsParent(SgStatement* s);
2470 #endif
2471 
2474 unsigned long long getIntegerConstantValue(SgValueExp* expr);
2475 
2477 std::vector<SgDeclarationStatement*> getDependentDeclarations (SgStatement* stmt );
2478 
2479 
2482 
2484 SgCommaOpExp *insertAfterUsingCommaOp (SgExpression* new_exp, SgExpression* anchor_exp, SgStatement** temp_decl = NULL, SgVarRefExp** temp_ref = NULL);
2485 
2486 
2516 std::pair<SgStatement*, SgInitializedName*>
2517 wrapFunction(SgFunctionDeclaration& definingDeclaration, SgName newName);
2518 
2524 template <class NameGen>
2525 std::pair<SgStatement*, SgInitializedName*>
2526 wrapFunction(SgFunctionDeclaration& definingDeclaration, NameGen nameGen)
2527 {
2528  return wrapFunction(definingDeclaration, nameGen(definingDeclaration.get_name()));
2529 }
2530 
2534 
2535 
2537 
2538 // DQ (6/7/2012): Unclear where this function should go...
2539  bool hasTemplateSyntax( const SgName & name );
2540 
2541 #if 0
2542 
2543 //------------------------AST dump, stringify-----------------------------
2544 //------------------------------------------------------------------------
2545  std::string buildOperatorString ( SgNode* astNode ); //transformationSupport.h
2546 
2547  // do we need these?
2548  std::string dump_node(const SgNode* astNode);
2549  std::string dump_tree(const SgNode* astNode);
2550 
2551  // or a friendly version of unparseToString(), as a memeber function
2552  std::string SgNode::toString(bool asSubTree=true); // dump node or subtree
2553 
2554 //----------------------------AST comparison------------------------------
2555 //------------------------------------------------------------------------
2556 // How to get generic functions for comparison?
2557  bool isNodeEqual(SgNode* node1, SgNode* node2); //?
2558  bool isTreeEqual(SgNode* tree1, SgNode* tree2);
2559 
2561  bool expressionTreeEqual(SgExpression*, SgExpression*);
2563  bool expressionTreeEqualStar(const SgExpressionPtrList&,
2564  const SgExpressionPtrList&);
2565 
2566 //----------------------AST verfication/repair----------------------------
2567 //------------------------------------------------------------------------
2568 // sanity check of AST subtree, any suggestions?
2569 // TODO
2570  verifySgNode(SgNode* node, bool subTree=true);
2571  //src/midend/astDiagnostics/AstConsistencyTests.h
2572  // AstTests::runAllTests(SgProject * )
2573 
2574  //src/midend/astUtil/astInterface/AstInterface.h.C
2575  //FixSgProject(SgProject &project)
2576  //FixSgTree(SgNode* r)
2577 
2578  //src/frontend/SageIII/astPostProcessing
2579  //AstPostProcessing(SgNode * node)
2580 
2581 //--------------------------AST modification------------------------------
2582 //------------------------------------------------------------------------
2583 // any operations changing AST tree, including
2584 // insert, copy, delete(remove), replace
2585 
2586  // insert before or after some point, argument list is consistent with LowLevelRewrite
2587  void insertAst(SgNode* targetPosition, SgNode* newNode, bool insertBefore=true);
2588 
2589  // previous examples
2590  //void myStatementInsert(SgStatement* target,...)
2591  // void AstInterfaceBase::InsertStmt(AstNodePtr const & orig, AstNodePtr const &n, bool insertbefore, bool extractfromBasicBlock)
2592 
2593  // copy
2594  // copy children of one basic block to another basic block
2595  //void appendStatementCopy (const SgBasicBlock* a, SgBasicBlock* b);
2596  void copyStatements (const SgBasicBlock* src, SgBasicBlock* dst);
2597 
2598  // delete (remove) a node or a whole subtree
2599  void removeSgNode(SgNode* targetNode); // need this?
2600  void removeSgNodeTree(SgNode* subtree); // need this?
2601 
2602  void removeStatement( SgStatement* targetStmt);
2603 
2604  //Move = delete + insert
2605  void moveAst (SgNode* src, SgNode* target); // need this?
2606  // similar to
2607  void moveStatements (SgBasicBlock* src, SgBasicBlock* target);
2608 
2609  // replace= delete old + insert new (via building or copying)
2610 
2611 // DQ (1/25/2010): This does not appear to exist as a definition anywhere in ROSE.
2612 // void replaceAst(SgNode* oldNode, SgNode* newNode);
2613 
2614  //void replaceChild(SgNode* parent, SgNode* from, SgNode* to);
2615  //bool AstInterface::ReplaceAst( const AstNodePtr& orig, const AstNodePtr& n)
2616 
2617 //--------------------------AST transformations---------------------------
2618 //------------------------------------------------------------------------
2619 // Advanced AST modifications through basic AST modifications
2620 // Might not be included in AST utitlity list, but listed here for the record.
2621 
2622  // extract statements/content from a scope
2623  void flattenBlocks(SgNode* n);
2624 
2625  //src/midend/astInlining/inlinerSupport.h
2626  void renameVariables(SgNode* n);
2627  void renameLabels(SgNode* n, SgFunctionDefinition* enclosingFunctionDefinition);
2628 
2629  void simpleCopyAndConstantPropagation(SgNode* top);
2630  void changeAllMembersToPublic(SgNode* n);
2631 
2632  void removeVariableDeclaration(SgInitializedName* initname);
2633 
2635  SgAssignOp* convertInitializerIntoAssignment(SgAssignInitializer* init);
2636 
2641  void pushTestIntoBody(LoopStatement* loopStmt);
2642 
2643  //programTransformation/finiteDifferencing/finiteDifferencing.h
2645  void moveForDeclaredVariables(SgNode* root);
2646 
2647 //------------------------ Is/Has functions ------------------------------
2648 //------------------------------------------------------------------------
2649 // misc. boolean functions
2650 // some of them could moved to SgXXX class as a member function
2651 
2652  bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
2653 
2654  bool isSwitchCond (const SgStatement* s);
2655  bool isIfCond (const SgStatement* s);
2656  bool isWhileCond (const SgStatement* s);
2657  bool isStdNamespace (const SgScopeStatement* scope);
2658  bool isTemplateInst (const SgDeclarationStatement* decl);
2659 
2660 
2661  bool isCtor (const SgFunctionDeclaration* func);
2662  bool isDtor (const SgFunctionDeclaration* func);
2663 
2664  // src/midend/astInlining/typeTraits.h
2665  bool hasTrivialDestructor(SgType* t);
2666  ROSE_DLL_API bool isNonconstReference(SgType* t);
2667  ROSE_DLL_API bool isReferenceType(SgType* t);
2668 
2669  // generic ones, or move to the SgXXX class as a member function
2670 
2671  bool isConst(SgNode* node); // const type, variable, function, etc.
2672  // .... and more
2673 
2674  bool isConstType (const SgType* type);
2675  bool isConstFunction (const SgFunctionDeclaration* decl);
2676 
2677 
2678  bool isMemberVariable(const SgInitializedName & var);
2679  //bool isMemberVariable(const SgNode& in);
2680 
2681  bool isPrototypeInScope (SgScopeStatement * scope,
2682  SgFunctionDeclaration * functionDeclaration,
2683  SgDeclarationStatement * startingAtDeclaration);
2684 
2685  bool MayRedefined(SgExpression* expr, SgNode* root);
2686  // bool isPotentiallyModified(SgExpression* expr, SgNode* root); // inlinderSupport.h
2687  bool hasAddressTaken(SgExpression* expr, SgNode* root);
2688 
2689  //src/midend/astInlining/inlinerSupport.C
2690  // can also classified as topdown search
2691  bool containsVariableReference(SgNode* root, SgInitializedName* var);
2692 
2693  bool isDeclarationOf(SgVariableDeclaration* decl, SgInitializedName* var);
2694  bool isPotentiallyModifiedDuringLifeOf(SgBasicBlock* sc,
2695  SgInitializedName* toCheck,
2696  SgInitializedName* lifetime)
2697  //src/midend/programTransformation/partialRedundancyElimination/pre.h
2698  bool anyOfListPotentiallyModifiedIn(const std::vector<SgVariableSymbol*>& syms, SgNode* n);
2699 
2700 //------------------------ loop handling ---------------------------------
2701 //------------------------------------------------------------------------
2702  //get and set loop control expressions
2703  // 0: init expr, 1: condition expr, 2: stride expr
2704 
2705  SgExpression* getForLoopTripleValues(int valuetype,SgForStatement* forstmt );
2706  int setForLoopTripleValues(int valuetype,SgForStatement* forstmt, SgExpression* exp);
2707 
2708  bool isLoopIndexVarRef(SgForStatement* forstmt, SgVarRefExp *varref);
2709  SgInitializedName * getLoopIndexVar(SgForStatement* forstmt);
2710 
2711 //------------------------expressions-------------------------------------
2712 //------------------------------------------------------------------------
2713  //src/midend/programTransformation/partialRedundancyElimination/pre.h
2714  int countComputationsOfExpressionIn(SgExpression* expr, SgNode* root);
2715 
2716  //src/midend/astInlining/replaceExpressionWithStatement.h
2717  void replaceAssignmentStmtWithStatement(SgExprStatement* from, StatementGenerator* to);
2718 
2720  StatementGenerator* to);
2721  SgExpression* getRootOfExpression(SgExpression* n);
2722 
2723 //--------------------------preprocessing info. -------------------------
2724 //------------------------------------------------------------------------
2726  void cutPreprocInfo (SgBasicBlock* b,
2728  AttachedPreprocessingInfoType& save_buf);
2730  void pastePreprocInfoFront (AttachedPreprocessingInfoType& save_buf,
2731  SgStatement* s);
2733  void pastePreprocInfoBack (AttachedPreprocessingInfoType& save_buf,
2734  SgStatement* s);
2735 
2741  // a generic one for all
2743  void moveBeforePreprocInfo (SgStatement* src, SgStatement* dest);
2744  void moveInsidePreprocInfo (SgBasicBlock* src, SgBasicBlock* dest);
2745  void moveAfterPreprocInfo (SgStatement* src, SgStatement* dest);
2746 
2747 //--------------------------------operator--------------------------------
2748 //------------------------------------------------------------------------
2749  from transformationSupport.h, not sure if they should be included here
2750  /* return enum code for SAGE operators */
2751  operatorCodeType classifyOverloadedOperator(); // transformationSupport.h
2752 
2758  std::string stringifyOperator (std::string name);
2759 
2760 //--------------------------------macro ----------------------------------
2761 //------------------------------------------------------------------------
2762  std::string buildMacro ( std::string s ); //transformationSupport.h
2763 
2764 //--------------------------------access functions---------------------------
2765 //----------------------------------get/set sth.-----------------------------
2766 // several categories:
2767 * get/set a direct child/grandchild node or fields
2768 * get/set a property flag value
2769 * get a descendent child node using preorder searching
2770 * get an ancestor node using bottomup/reverse searching
2771 
2772  // SgName or string?
2773  std::string getFunctionName (SgFunctionCallExp* functionCallExp);
2774  std::string getFunctionTypeName ( SgFunctionCallExp* functionCallExpression );
2775 
2776  // do we need them anymore? or existing member functions are enought?
2777  // a generic one:
2778  std::string get_name (const SgNode* node);
2779  std::string get_name (const SgDeclarationStatement * declaration);
2780 
2781  // get/set some property: should moved to SgXXX as an inherent memeber function?
2782  // access modifier
2783  void setExtern (SgFunctionDeclartion*)
2784  void clearExtern()
2785 
2786  // similarly for other declarations and other properties
2788  void setPublic()
2789  void setPrivate()
2790 
2791 #endif
2792 
2793 // DQ (1/23/2013): Added support for generated a set of source sequence entries.
2794  std::set<unsigned int> collectSourceSequenceNumbers( SgNode* astNode );
2795 
2796 //--------------------------------Type Traits (C++)---------------------------
2797  bool HasNoThrowAssign(const SgType * const inputType);
2798  bool HasNoThrowCopy(const SgType * const inputType);
2799  bool HasNoThrowConstructor(const SgType * const inputType);
2800  bool HasTrivialAssign(const SgType * const inputType);
2801  bool HasTrivialCopy(const SgType * const inputType);
2802  bool HasTrivialConstructor(const SgType * const inputType);
2803  bool HasTrivialDestructor(const SgType * const inputType);
2804  bool HasVirtualDestructor(const SgType * const inputType);
2805  bool IsBaseOf(const SgType * const inputBaseType, const SgType * const inputDerivedType);
2806  bool IsAbstract(const SgType * const inputType);
2807  bool IsClass(const SgType * const inputType);
2808  bool IsEmpty(const SgType * const inputType);
2809  bool IsEnum(const SgType * const inputType);
2810  bool IsPod(const SgType * const inputType);
2811  bool IsPolymorphic(const SgType * const inputType);
2812  bool IsStandardLayout(const SgType * const inputType);
2813  bool IsLiteralType(const SgType * const inputType);
2814  bool IsTrivial(const SgType * const inputType);
2815  bool IsUnion(const SgType * const inputType);
2816  SgType * UnderlyingType(SgType *type);
2817 
2818 // DQ (3/2/2014): Added a new interface function (used in the snippet insertion support).
2819 // void supportForInitializedNameLists ( SgScopeStatement* scope, SgInitializedNamePtrList & variableList );
2820 
2821 // DQ (3/4/2014): Added support for testing two trees for equivalents using the AST iterators.
2822  bool isStructurallyEquivalentAST( SgNode* tree1, SgNode* tree2 );
2823 
2824 // JP (10/14/24): Moved code to evaluate a const integer expression (like in array size definitions) to SageInterface
2827  size_t value_;
2828  bool hasValue_;
2829  };
2832 
2833 // JP (9/17/14): Added function to test whether two SgType* are equivalent or not
2834  bool checkTypesAreEqual(SgType *typeA, SgType *typeB);
2835 
2836 //--------------------------------Java interface functions ---------------------
2837 #ifdef ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
2838  ROSE_DLL_API std::string getTempDirectory(SgProject *project);
2839  ROSE_DLL_API void destroyTempDirectory(std::string);
2840  ROSE_DLL_API SgFile *processFile(SgProject *, std::string, bool unparse = false);
2841  ROSE_DLL_API std::string preprocessPackage(SgProject *, std::string);
2842  ROSE_DLL_API std::string preprocessImport(SgProject *, std::string);
2843  ROSE_DLL_API SgFile* preprocessCompilationUnit(SgProject *, std::string, std::string, bool unparse = true);
2844  ROSE_DLL_API SgClassDefinition *findJavaPackage(SgScopeStatement *, std::string);
2845  ROSE_DLL_API SgClassDefinition *findOrInsertJavaPackage(SgProject *, std::string, bool create_directory = false);
2846  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, SgClassDefinition *package_definition, std::string);
2847  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, std::string, std::string);
2848  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, SgClassType *);
2849  ROSE_DLL_API SgMemberFunctionDeclaration *findJavaMain(SgClassDefinition *);
2850  ROSE_DLL_API SgMemberFunctionDeclaration *findJavaMain(SgClassType *);
2851 #endif // ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
2852 
2853 
2854 
2855 // DQ (8/31/2016): Making this a template function so that we can have it work with user defined filters.
2857 
2863 template < class T >
2865  {
2866  // DQ (9/1/2016): This function is called in the Call graph generation to avoid filtering out EDG normalized
2867  // function template instnatiations (which come from normalized template functions and member functions).
2868  // Note that because of the EDG normailzation the membr function is moved outside of the class, and
2869  // thus marked as compiler generated. However the template instantiations are always marked as compiler
2870  // generated (if not specializations) and so we want to include a template instantiation that is marked
2871  // as compiler generated, but is from a template declaration that satisfyied a specific user defined filter.
2872  // The complexity of this detection is isolated here, but knowing that it must be called is more complex.
2873  // This function is call in the CG.C file of tests/nonsmoke/functional/roseTests/programAnalysisTests/testCallGraphAnalysis.
2874 
2875  bool retval = false;
2876 
2877 #define DEBUG_TEMPLATE_NORMALIZATION_DETECTION 0
2878 
2879 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2880  printf ("In isNormalizedTemplateInstantiation(): function = %p = %s = %s \n",function,function->class_name().c_str(),function->get_name().str());
2881 #endif
2882 
2883  // Test for this to be a template instantation (in which case it was marked as
2884  // compiler generated but we may want to allow it to be used in the call graph,
2885  // if it's template was a part was defined in the current directory).
2886  SgTemplateInstantiationFunctionDecl* templateInstantiationFunction = isSgTemplateInstantiationFunctionDecl(function);
2887  SgTemplateInstantiationMemberFunctionDecl* templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(function);
2888 
2889  if (templateInstantiationFunction != NULL)
2890  {
2891  // When the defining function has been normalized by EDG, only the non-defining declaration will have a source position.
2892  templateInstantiationFunction = isSgTemplateInstantiationFunctionDecl(templateInstantiationFunction->get_firstNondefiningDeclaration());
2893  SgTemplateFunctionDeclaration* templateFunctionDeclaration = templateInstantiationFunction->get_templateDeclaration();
2894  if (templateFunctionDeclaration != NULL)
2895  {
2896  retval = filter->operator()(templateFunctionDeclaration);
2897  }
2898  else
2899  {
2900  // Assume false.
2901  }
2902 
2903 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2904  printf (" --- case of templateInstantiationFunction: retval = %s \n",retval ? "true" : "false");
2905 #endif
2906  }
2907  else
2908  {
2909  if (templateInstantiationMemberFunction != NULL)
2910  {
2911  // When the defining function has been normalized by EDG, only the non-defining declaration will have a source position.
2912  templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(templateInstantiationMemberFunction->get_firstNondefiningDeclaration());
2913  SgTemplateMemberFunctionDeclaration* templateMemberFunctionDeclaration = templateInstantiationMemberFunction->get_templateDeclaration();
2914  if (templateMemberFunctionDeclaration != NULL)
2915  {
2916  retval = filter->operator()(templateMemberFunctionDeclaration);
2917  }
2918  else
2919  {
2920  // Assume false.
2921  }
2922 
2923 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2924  printf (" --- case of templateInstantiationMemberFunction: retval = %s \n",retval ? "true" : "false");
2925 #endif
2926  }
2927  }
2928 
2929  return retval;
2930  }
2931 
2932 void detectCycleInType(SgType * type, const std::string & from);
2933 
2934 // DQ (7/14/2020): Debugging support.
2935 void checkForInitializers( SgNode* node );
2936 
2937 }// end of namespace
2938 
2939 
2940 
2941 #endif
std::string extractPragmaKeyword(const SgPragmaDeclaration *)
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of...
ROSE_DLL_API void constantFolding(SgNode *r)
Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values...
ROSE_DLL_API SgStatement * findSurroundingStatementFromSameFile(SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement)
Supporting function to comment relocation in insertStatement() and removeStatement().
ROSE_DLL_API SgFunctionDeclaration * findFirstDefiningFunctionDecl(SgScopeStatement *scope)
Find the first defining function declaration statement in a scope.
This class represents the notion of an initializer for a variable declaration or expression in a func...
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.
ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language()
ROSE_DLL_API size_t getUpcSharedBlockSize(SgModifierType *mod_type)
Get the block size of a UPC shared modifier type.
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...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt)
Insert a list of statements after a target statement.
This class represents the concept of an instantiation of member function template or a member functio...
bool getForLoopInformations(SgForStatement *for_loop, SgVariableSymbol *&iterator, SgExpression *&lower_bound, SgExpression *&upper_bound, SgExpression *&stride)
Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
A persistent attribute to represent a unique name for an expression.
ROSE_DLL_API SgFile * getEnclosingFileNode(SgNode *astNode)
get the SgFile node from current node
This class represents the concept of a class declaration statement. It includes the concept of an ins...
bool declarationPreceedsDefinition(SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration)
Check if a defining declaration comes before of after the non-defining declaration.
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
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 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 SgStatement * getEnclosingStatement(SgNode *n)
Find the closest enclosing statement, including the given node.
std::string generateUniqueNameForUseAsIdentifier(SgDeclarationStatement *declaration)
Generate a useful name to support construction of identifiers from declarations.
bool ROSE_DLL_API isMutable(SgInitializedName *name)
True if an SgInitializedName is "mutable' (has storage modifier set)
ROSE_DLL_API SgScopeStatement * getEnclosingScope(SgNode *n, const bool includingSelf=false)
Get the enclosing scope from a node n.
ROSE_DLL_API bool mergeDeclarationAndAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt, bool removeAssignStmt=true)
Merge a variable assignment statement into a matching variable declaration statement. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check.
This class represents the concept of a declaration list.
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 SgVariableSymbol * getFirstVarSym(SgVariableDeclaration *decl)
Get the variable symbol for the first initialized name of a declaration stmt.
ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement before a target statement.
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 bool isUpcSharedModifierType(SgModifierType *mod_type)
Check if a modifier type is a UPC shared type.
ROSE_DLL_API std::string mangleType(SgType *type)
Generate a mangled string for a given type based on Itanium C++ ABI.
ROSE_DLL_API SgExprStatement * splitVariableDeclaration(SgVariableDeclaration *decl)
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignm...
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 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.
ROSE_DLL_API bool is_Fortran_language()
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 bool isAddressTaken(SgExpression *refExp)
Find a node by type using upward traversal.
ROSE_DLL_API void insertStatementListBefore(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts)
Insert a list of statements before a target statement.
ROSE_DLL_API bool hasTrivialDestructor(SgType *t)
Does a type have a trivial (built-in) destructor?
ROSE_DLL_API void setOneSourcePositionNull(SgNode *node)
Set current node's source position as NULL.
bool isPostfixOperator(SgExpression *exp)
Is an overloaded operator a postfix operator. (e.g. ).
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.
std::string getMangledNameFromCache(SgNode *astNode)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
ROSE_DLL_API SgFunctionDefinition * getEnclosingFunctionDefinition(SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
ROSE_DLL_API SgClassDeclaration * getEnclosingClassDeclaration(SgNode *astNode)
Get the closest class declaration enclosing the specified AST node,.
ROSE_DLL_API bool is_Ada_language()
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement *ompbodyStmt)
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not.
This class represents the concept of a C or C++ statement which contains a expression.
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 AbstractHandle::abstract_handle * buildAbstractHandle(SgNode *)
Build an abstract handle from an AST node, reuse previously built handle when possible.
std::string generateUniqueName(const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
Generate unique name from C and C++ constructs. The name may contain space.
ROSE_DLL_API std::string mangleModifierType(SgModifierType *type)
Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI...
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).
This class represents a source file for a project (which may contian many source files and or directo...
ROSE_DLL_API void removeLabeledGotos(SgNode *top)
Remove labeled goto statements.
This class represents the variable declaration or variable initialization withn a for loop...
ROSE_DLL_API bool isInSubTree(SgExpression *subtree, SgExpression *exp)
Find a node by type using upward traversal.
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 SgMemberFunctionDeclaration * getDefaultConstructor(SgClassDeclaration *classDeclaration)
Get the default constructor from the class declaration.
ROSE_DLL_API bool normalizeForLoopTest(SgForStatement *loop)
Normalize a for loop's test expression ix is normalized to i>= (x...
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...
void initializeIfStmt(SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
Support function used for variable declarations in conditionals.
Class for traversing the AST.
bool isTemplateInstantiationFromTemplateDeclarationSatisfyingFilter(SgFunctionDeclaration *function, T *filter)
This function detects template instantiations that are relevant when filters are used.
void guardNode(SgLocatedNode *target, std::string guard)
Add preproccessor guard around a given node.
This class represents the rhs of a variable declaration which includes an optional assignment (e...
ROSE_DLL_API bool is_language_case_insensitive()
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 bool is_Java_language()
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...
ROSE_DLL_API void setPragma(SgPragmaDeclaration *decl, SgPragma *pragma)
Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer.
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 SgFunctionDeclaration * getFunctionDeclaration(SgFunctionCallExp *functionCallExp)
Find a node by type using upward traversal.
This class represents the base class for all types.
SgType * removeConst(SgType *t)
Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers...
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 SgNode * deepCopyNode(const SgNode *subtree)
Deep copy an arbitrary subtree.
This class represents the concept of a do-while statement.
ROSE_DLL_API bool isUpcStrictSharedModifierType(SgModifierType *mode_type)
Check if a shared UPC type is strict memory consistency or not. Return false if it is relaxed...
ROSE_DLL_API bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration)
Return true if template definition is in the class, false if outside of class.
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 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.
This class represents the concept of a class name within the compiler.
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...
void printAST(SgNode *node)
Pretty print AST horizontally, output to std output.
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 SgBasicBlock * ensureBasicBlockAsTrueBodyOfIf(SgIfStmt *ifs)
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool isUpcArrayWithThreads(SgArrayType *t)
Is a UPC array with dimension of X*THREADS.
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 ...
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 std::string mangleScalarType(SgType *type)
Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarT...
label_type_enum
Type of label used (fortran only)
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...
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
void setSourcePositionPointersToNull(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API bool isEquivalentFunctionType(const SgFunctionType *lhs, const SgFunctionType *rhs)
Test if two types are equivalent SgFunctionType nodes.
std::vector< SgVariableSymbol * > getSymbolsUsedInExpression(SgExpression *expr)
Find referenced symbols within an expression.
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 void setLhsOperand(SgExpression *target, SgExpression *lhs)
set left hand operand for binary expressions, transparently downcasting target expressions when neces...
This class represents the notion of a declared variable.
ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root)
Set the source code positon for the subtree (including the root).
ROSE_DLL_API std::string generateProjectName(const SgProject *project, bool supressSuffix=false)
Added mechanism to generate project name from list of file names.
bool isBodyStatement(SgStatement *s)
Check if a statement is a (true or false) body of a container-like parent, such as For...
ROSE_DLL_API SgVariableSymbol * prependArg(SgFunctionParameterList *, SgInitializedName *)
Prepend an argument to SgFunctionParameterList.
NodeType * deepCopy(const NodeType *subtree)
A template function for deep copying a subtree. It is also used to create deepcopy functions with spe...
This class represents the concept of a member function declaration statement.
This class represents the concept of a C and C++ case option (used within a switch statement)...
SgBasicBlock * ensureBasicBlockAsBodyOfDefaultOption(SgDefaultOptionStmt *cs)
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not...
This class represents the concept of a function declaration statement.
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...
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 isOmpStatement(SgNode *)
Check if a node is SgOmp*Statement.
ROSE_DLL_API void convertFunctionDefinitionsToFunctionPrototypes(SgNode *node)
XXX This function operates on the new file used to support outlined function definitions. We use a copy of the file where the code will be outlined FROM, so that if there are references to declarations in the outlined code we can support the outpiled code with those references. This approach has the added advantage of also supporting the same include file tree as the original file where the outlined code is being taken from.
ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language()
Interface for creating a statement whose computation writes its answer into a given variable...
ROSE_DLL_API DeferredTransformation & operator=(const DeferredTransformation &X)
Shallow; does not delete fields.
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...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
SgType * getBoolType(SgNode *n)
Get the right bool type according to C or C++ language input.
ROSE_DLL_API SgSourceFile * getEnclosingSourceFile(SgNode *n, const bool includingSelf=false)
Find enclosing source file node.
ROSE_DLL_API bool is_Python_language()
bool ROSE_DLL_API isStatic(SgDeclarationStatement *stmt)
Check if a declaration has a "static' modifier.
unsigned long long getIntegerConstantValue(SgValueExp *expr)
Get the constant value from a constant integer expression; abort on everything else.
This class represents the concept of a C and C++ expression list.
void clearScopeNumbers(SgFunctionDefinition *functionDefinition)
Clears the cache of scope,integer pairs for the input function.
ROSE_DLL_API void setStatic(SgDeclarationStatement *stmt)
Set a declaration as static.
ROSE_DLL_API void outputLocalSymbolTables(SgNode *node)
Output the local symbol tables.
ROSE_DLL_API bool isUpcSharedArrayType(SgArrayType *array_type)
Check if an array type is a UPC shared type. ROSE AST represents a UPC shared array as regular array ...
ROSE_DLL_API void printOutComments(SgLocatedNode *locatedNode)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
void checkSymbolTables(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
ROSE_DLL_API bool is_binary_executable()
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...
std::vector< SgBreakStmt * > findBreakStmts(SgStatement *code, const std::string &fortranLabel="")
Find break statements inside a particular statement, stopping at nested loops or switches.
AncestorNode * ancestor(SgNode *n)
finds an ancestor node with a given type
Definition: sageGeneric.h:1266
ROSE_DLL_API void setSourcePositionForTransformation(SgNode *root)
Recursively set source position info(Sg_File_Info) as transformation generated.
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.
ROSE_DLL_API SgStatement * getLoopBody(SgScopeStatement *loop)
Routines to get and set the body of a loop.
std::vector< SgFile * > generateFileList()
Returns STL vector of SgFile IR node pointers.
std::string generateUniqueNameForUseAsIdentifier_support(SgDeclarationStatement *declaration)
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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 int set_name(SgInitializedName *initializedNameNode, SgName new_name)
set_name of symbol in symbol table.
void changeAllBodiesToBlocks(SgNode *top, bool createEmptyBody=true)
Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components...
ROSE_DLL_API bool isPointerType(SgType *t)
Is this type a pointer type? (Handles typedefs correctly)
bool isOverloaded(SgFunctionDeclaration *functionDeclaration)
Return true if function is overloaded.
ROSE_DLL_API SgNode * getSgNodeFromAbstractHandleString(const std::string &input_string)
Obtain a matching SgNode from an abstract handle string.
ROSE_DLL_API void fixStatement(SgStatement *stmt, SgScopeStatement *scope)
A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements. Should be used before attaching the statement into AST.
ROSE_DLL_API void deleteExpressionTreeWithOriginalExpressionSubtrees(SgNode *root)
Special purpose function for deleting AST expression tress containing valid original expression trees...
ROSE_DLL_API bool isCopyConstructible(SgType *type)
Is a type copy constructible? This may not quite work properly.
bool ROSE_DLL_API isJovialOutParam(SgInitializedName *name)
True if a parameter name is a Jovial output parameter.
This class represents the base class of a numbr of IR nodes that don't otherwise fit into the existin...
bool isPrefixOperator(SgExpression *exp)
Is an overloaded operator a prefix operator (e.g. address operator X * operator&(), dereference operator X & operator*(), unary plus operator X & operator+(), etc.
void printAST2TextFile(SgNode *node, const char *filename)
Pretty print AST horizontally, output to a specified text file.
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 bool isStructType(SgType *t)
Check if a type is a struct type (a special SgClassType in ROSE)
void resetScopeNumbers(SgFunctionDefinition *functionDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
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...
SgExpression * forallMaskExpression(SgForAllStatement *stmt)
Get the mask expression from the header of a SgForAllStatement.
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 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...
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...
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API bool isConstantTrue(SgExpression *e)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
SgDeclarationStatement * getNonInstantiatonDeclarationForClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
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 int getDimensionCount(SgType *t)
Get the number of dimensions of an array type.
ROSE_DLL_API ~DeferredTransformation(void)
Copy constructor.
void visit(SgNode *node)
this method is called at every traversed node.
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code...
void clearMangledNameCache(SgGlobal *globalScope)
Support for faster mangled name generation (caching avoids recomputation).
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultDestructor(SgClassDeclaration *classDeclaration)
Get the default destructor from the class declaration.
void whereAmI(SgNode *node)
Diagnostic function for tracing back through the parent list to understand at runtime where in the AS...
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 bool isStrictIntegerType(SgType *t)
Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long. /! /! There is another similar function named SgType::isIntegerType(), which allows additional types char, wchar, and bool to be treated as integer types.
SgBasicBlock * makeSingleStatementBodyToBlock(SgStatement *singleStmt)
Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc...
ROSE_DLL_API SgInitializer * getInitializerOfExpression(SgExpression *n)
Get the initializer containing an expression if it is within an initializer.
ROSE_DLL_API void replaceExpression(SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false)
Replace an expression with another, used for variable reference substitution and others. the old expression can be deleted (default case) or kept.
ROSE_DLL_API bool is_OpenMP_language()
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...
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.
ROSE_DLL_API PreprocessingInfo * findHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader)
Find the preprocessingInfo node representing #include or #include "header.h" within a source file. Return NULL if not found.
ROSE_DLL_API std::set< SgNode * > getFrontendSpecificNodes()
Find a node by type using upward traversal.
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 bool is_UPC_language()
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfUpcForAll(SgUpcForAllStatement *fs)
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.
void outputGlobalFunctionTypeSymbolTable()
Output function type symbols in global function type symbol table.
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< NodeType * > querySubTree(SgNode *top, VariantT variant=(VariantT) NodeType::static_variant)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
std::vector< SgContinueStmt * > findContinueStmts(SgStatement *code, const std::string &fortranLabel="")
Find all continue statements inside a particular statement, stopping at nested loops.
void setBaseTypeDefiningDeclaration(SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl)
a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side ef...
ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList &list1, const SgTemplateArgumentPtrList &list2)
Verify that 2 SgTemplateArgumentPtrList are equivalent.
const SgInitializedNamePtrList & get_args() const
Access function for p_args.
ROSE_DLL_API SgGlobal * getGlobalScope(const SgNode *astNode)
Traverse back through a node's parents to find the enclosing global scope.
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...
This class represents the concept of a name within the compiler.
T * findDeclarationStatement(SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining)
Topdown traverse a subtree from root to find the first declaration given its name, scope (optional, can be NULL), and defining or nondefining flag.
ROSE_DLL_API SgInitializedName * convertRefToInitializedName(SgNode *current, bool coarseGrain=true)
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. For Dot and Arrow Expressions, their lhs is used to obtain SgInitializedName (coarse grain) by default. Otherwise, fine-grain rhs is used.
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...
void dumpPreprocInfo(SgLocatedNode *locatedNode)
Dumps a located node's preprocessing information.
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 replaceSubexpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Similar to replaceExpressionWithStatement, but with more restrictions.
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...
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 bool is_Cobol_language()
Supporting class from copy mechanism within ROSE.
Definition: Cxx_Grammar.h:9296
ROSE_DLL_API void setSourcePosition(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API bool isPureVirtualClass(SgType *type, const ClassHierarchyWrapper &classHierarchy)
Check if a class type is a pure virtual class.
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 bool isUseByAddressVariableRef(SgVarRefExp *ref)
Check if a variable reference is used by its address: including &a expression and foo(a) when type2 f...
ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project)
return the first global scope under current project
Base class for all IR node attribute values.
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 fixStructDeclaration(SgClassDeclaration *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API SgType * getFirstVarType(SgVariableDeclaration *decl)
Get the data type of the first initialized name of a declaration statement.
ROSE_DLL_API bool isUpcSharedType(SgType *t, SgModifierType **mod_type_out=NULL)
Check if a type is a UPC shared type, including shared array, shared pointers etc. Exclude private pointers to shared types. Optionally return the modifier type with the UPC shared property.
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API int collectVariableReferencesInArrayTypes(SgLocatedNode *root, Rose_STL_Container< SgNode * > &currentVarRefList)
Collect variable references in array types. The default NodeQuery::querySubTree() will miss variables...
void checkAccessPermissions(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
This class represents the concept of a class definition in C++.
This class represents strings within the IR nodes.
ROSE_DLL_API bool isMemberFunctionMemberReference(SgMemberFunctionRefExp *memberFunctionRefExp)
Find a node by type using upward traversal.
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...
void resetMangledNameCache(SgGlobal *globalScope)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
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 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 size_t getArrayElementCount(SgArrayType *t)
Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int...
ROSE_DLL_API void moveCommentsToNewStatement(SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *targetStatement, bool surroundingStatementPreceedsTargetStatement)
Relocate comments and CPP directives from one statement to another.
ROSE_DLL_API bool isMain(const SgNode *node)
Check if a SgNode is a main() function declaration.
ROSE_DLL_API void displayScope(SgScopeStatement *scope)
Find a node by type using upward traversal.
ROSE_DLL_API void setExtern(SgDeclarationStatement *stmt)
Set a declaration as extern.
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...
std::vector< SgStatement * > getSwitchCases(SgSwitchStatement *sw)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
void setSourcePositionAsTransformation(SgNode *node)
DQ (5/1/2012): New function with improved name.
bool isPrototypeInScope(SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
Functions that are useful when operating on the AST.
Definition: sageBuilder.h:25
static ROSE_DLL_API DeferredTransformation replaceDefiningFunctionDeclarationWithFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
operator=()
ROSE_DLL_API bool doLoopNormalization(SgFortranDo *loop)
Normalize a Fortran Do loop. Make the default increment expression (1) explicit.
ROSE_DLL_API bool isConstantFalse(SgExpression *e)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
ROSE_DLL_API bool isExtern(SgDeclarationStatement *stmt)
Check if a declaration has an "extern" modifier.
ROSE_DLL_API SgFunctionDeclaration * findMain(SgNode *currentNode)
top-down traversal from current node to find the main() function declaration
ROSE_DLL_API SgInitializedName * getFirstInitializedName(SgVariableDeclaration *decl)
Get the first initialized name of a declaration statement.
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 bool is_UPC_dynamic_threads()
ROSE_DLL_API void translateScopeToUseCppDeclarations(SgScopeStatement *scope)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void cleanupNontransformedBasicBlockNode()
Remove unused basic block IR nodes added as part of normalization.
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 bool isVolatileType(SgType *t)
Is this a volatile type?
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 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...
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...
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 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 SgStatement * getLoopCondition(SgScopeStatement *loop)
Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop.
This class represents the concept of a namespace name within the compiler.
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...
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).
SgBasicBlock * ensureBasicBlockAsBodyOfCaseOption(SgCaseOptionStmt *cs)
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API SgTemplateInstantiationMemberFunctionDecl * buildForwardFunctionDeclaration(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Generate a non-defining (forward) declaration from a defining function declaration.
ROSE_DLL_API std::list< SgClassType * > getClassTypeChainForMemberReference(SgExpression *refExp)
Find a node by type using upward traversal.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9555
This class represents the concept of a catch within a try-catch construct used in C++ exception handl...
void markSubtreeToBeUnparsed(SgNode *root, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
This class represents the notion of an value (expression value).
std::vector< SgInitializedName * > getInParameters(const SgInitializedNamePtrList &params)
Get a vector of Jovial input parameters from the function parameter list (may work for Fortran in the...
This class represents the concept of a variable name within the compiler (a shared container for the ...
This class represents the concept of an instantiation of function template.
bool isPrefixOperatorName(const SgName &functionName)
Check for proper names of possible prefix operators (used in isPrefixOperator()). ...
ROSE_DLL_API std::set< SgStatement * > collectTransformedStatements(SgNode *node)
This collects the statements that are marked as transformed (useful in debugging).
NodeType * getEnclosingNode(const SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
ROSE_DLL_API bool is_Jovial_language()
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...
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
SgTemplateMemberFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
std::vector< SgDeclarationStatement * > getDependentDeclarations(SgStatement *stmt)
Get a statement's dependent declarations which declares the types used in the statement. The returned vector of declaration statements are sorted according to their appearance order in the original AST. Any reference to a class or template class from a namespace will treated as a reference to the enclosing namespace.
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 SgClassDefinition * getEnclosingClassDefinition(SgNode *astnode, const bool includingSelf=false)
Get the closest class definition enclosing the specified AST node,.
std::map< std::string, SgNode * > local_name_to_node_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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...
SgStatement * lastStatementOfScopeWithTokenInfo(SgScopeStatement *scope, std::map< SgNode *, TokenStreamSequenceToNodeMapping * > &tokenStreamSequenceMap)
Used to support token unparsing (when the output the trailing token sequence).
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 bool is_OpenCL_language()
ROSE_DLL_API bool normalizeForLoopInitDeclaration(SgForStatement *loop)
Normalize loop init stmt by promoting the single variable declaration statement outside of the for lo...
ROSE_DLL_API bool isLastStatement(SgStatement *stmt)
Check if a statement is the last statement within its closed scope.
ROSE_DLL_API SgType * getAssociatedTypeFromFunctionTypeList(SgExpression *actual_argument_expression)
Get the type of the associated argument expression from the function type.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfFor(SgForStatement *fs)
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
std::vector< SgExpression * > get_C_array_dimensions(const SgArrayType &arrtype)
returns the array dimensions in an array as defined for arrtype
This class represents the concept of a block (not a basic block from control flow analysis)...
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...
This class represents the concept of a C++ namespace declaration.
ROSE_DLL_API SgFunctionDefinition * getEnclosingProcedure(SgNode *n, const bool includingSelf=false)
Find the function definition.
ROSE_DLL_API SgFunctionDeclaration * getEnclosingFunctionDeclaration(SgNode *astNode, const bool includingSelf=false)
Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStat...
This class represents the notion of a statement.
For preprocessing information including source comments, #include , #if, #define, etc...
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 bool is_C_language()
ROSE_DLL_API SgStatement * lastFrontEndSpecificStatement(SgGlobal *globalScope)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
This class represents the concept of a namespace definition.
This class represents the concept of a for loop.
ROSE_DLL_API bool isStructDeclaration(SgNode *node)
Check if a SgNode is a declaration for a structure.
ROSE_DLL_API SgStatement * getLastStatement(SgScopeStatement *scope)
get the last statement within a scope, return NULL if it does not exit
void clearUnusedVariableSymbols(SgNode *root=NULL)
Clear those variable symbols with unknown type (together with initialized names) which are also not r...
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 bool skipTranslateToUseCppDeclaration(PreprocessingInfo *currentPreprocessingInfo)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void resetInternalMapsForTargetStatement(SgStatement *sourceStatement)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
SgDeclarationStatement * get_definingDeclaration() const
This is an access function for the SgDeclarationStatement::p_definingDeclaration data member (see tha...
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 SgInitializedName * getLoopIndexVariable(SgNode *loop)
Return the loop index variable for a for loop.
ROSE_DLL_API bool isUnionDeclaration(SgNode *node)
Check if a SgNode is a declaration for a union.
ROSE_DLL_API bool is_X10_language()
ROSE_DLL_API bool statementCanBeTransformed(SgStatement *stmt)
If header file unparsing and token-based unparsing are used, then some statements in header files use...
This class represents a type for all functions.
void annotateExpressionsWithUniqueNames(SgProject *project)
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttri...
SgInitializedName & getFirstVariable(SgVariableDeclaration &vardecl)
convenience function that returns the first initialized name in a list of variable declarations...
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...
This class represents the concept of a namespace definition.
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 SgStatement * copyStatement(SgStatement *s)
Deep copy a statement.
void addMessageStatement(SgStatement *stmt, std::string message)
Function to add "C" style comment to statement.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt *cos)
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool isScalarType(SgType *t)
Is this a scalar type?
This class represents the concept of a C Assembler statement (untested).
ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression *)
Append an expression to a SgExprListExp, set the parent pointer also.
ROSE_DLL_API void updateDefiningNondefiningLinks(SgFunctionDeclaration *func, SgScopeStatement *scope)
Update defining and nondefining links due to a newly introduced function declaration. Should be used after inserting the function into a scope.
ROSE_DLL_API bool hasUpcSharedType(SgType *t, SgModifierType **mod_type_out=NULL)
Has a UPC shared type of any kinds (shared-to-shared, private-to-shared, shared-to-private, shared scalar/array)? An optional parameter, mod_type_out, stores the first SgModifierType with UPC access information.
bool isIndexOperator(SgExpression *exp)
Is an overloaded operator an index operator (also referred to as call or subscript operators)...
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 bool isNonconstReference(SgType *t)
Is this type a non-constant reference type? (Handles typedefs correctly)
This class represents the concept of a C or C++ default case within a switch statement.
ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument *arg1, SgTemplateArgument *arg2)
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declara...
This class represents the concept of an "if" construct.
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 recursivePrintCurrentAndParent(SgNode *n)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
to specify a construct using a specifier Can be used alone or with parent handles when relative speci...
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 void outputFileIds(SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
virtual std::string class_name() const
returns a string representing the class name
ROSE_DLL_API void deleteAST(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
std::vector< SgGotoStatement * > findGotoStmts(SgStatement *scope, SgLabelStatement *l)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
ROSE_DLL_API SgScopeStatement * getScope(const SgNode *astNode)
Get the closest scope from astNode. Return astNode if it is already a scope.
void setParameterList(actualFunction *func, SgFunctionParameterList *paralist)
Set parameter list for a function declaration, considering existing parameter list etc...
This class represents the concept of a template declaration.
ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration *classDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API bool forLoopNormalization(SgForStatement *loop, bool foldConstant=true)
Normalize a for loop, return true if successful.
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 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...
This class represents the notion of an expression or statement which has a position within the source...
ROSE_DLL_API bool isReferenceType(SgType *t)
Is this type a const or non-const reference type? (Handles typedefs correctly)
This class represents template argument within the use of a template to build an instantiation.
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...
This class represents the variable refernece in expressions.
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 ...
This class represents the concept of a do-while statement.
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 isUpcPrivateToSharedType(SgType *t)
Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC inf...
void initializeSwitchStatement(SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body)
Support function used for variable declarations in conditionals.
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...
std::map< std::string, int > local_name_collision_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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 std::set< SgLabelStatement * > findUnusedLabels(SgNode *top)
Find unused labels which are not targets of any goto statements.
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::vector< SgInitializedName * > getOutParameters(const SgInitializedNamePtrList &params)
Get a vector of Jovial output parameters from the function parameter list (may work for Fortran in th...
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...
ROSE_DLL_API bool isDefaultConstructible(SgType *type)
Is a type default constructible? This may not quite work properly.
ROSE_DLL_API void wrapAllTemplateInstantiationsInAssociatedNamespaces(SgProject *root)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
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 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...
ROSE_DLL_API SgFunctionDeclaration * buildFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
Base class for values.
ROSE_DLL_API bool mergeDeclarationWithAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt)
Merge a declaration statement into a matching followed variable assignment. Callers should make sure ...
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 bool isAssignable(SgType *type)
Is a type assignable? This may not quite work properly.
ROSE_DLL_API void setLoopLowerBound(SgNode *loop, SgExpression *lb)
Set the lower bound of a loop header for (i=lb; ...)
ROSE_DLL_API SgProject * getProject()
Get the current SgProject IR Node.
This class represents the member function being called and must be assembled in the SgFunctionCall wi...
ROSE_DLL_API bool is_PHP_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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression *expr)
Split long expressions into blocks of statements.
ROSE_DLL_API SgFunctionType * findFunctionType(SgType *return_type, SgFunctionParameterTypeList *typeList)
Find the function type matching a function signature plus a given return type.
void initializeWhileStatement(SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body)
Support function used for variable declarations in conditionals.
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 void removeConsecutiveLabels(SgNode *top)
Remove consecutive labels.
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 void setOneSourcePositionForTransformation(SgNode *root)
Set current node's source position as transformation generated.
ROSE_DLL_API void moveDeclarationToAssociatedNamespace(SgDeclarationStatement *declarationStatement)
Relocate the declaration to be explicitly represented in its associated namespace (required for some ...
ROSE_DLL_API void setRhsOperand(SgExpression *target, SgExpression *rhs)
set left hand operand for binary expression
SgNode * get_parent() const
Access function for parent node.
ROSE_DLL_API void myRemoveStatement(SgStatement *stmt)
A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's atten...
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope(SgFunctionCallExp *functionCall)
Recursively print current and parent nodes. used within gdb to probe the context of a node...
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 int gensym_counter
An internal counter for generating unique SgName.
ROSE_DLL_API void outputSharedNodes(SgNode *node)
Find a node by type using upward traversal.
ROSE_DLL_API bool isEqualToIntConst(SgExpression *e, int value)
Check if a SgIntVal node has a given value.
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 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 void changeContinuesToGotos(SgStatement *stmt, SgLabelStatement *label)
Change continue statements in a given block of code to gotos to a label.
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 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 bool is_Cxx_language()
ROSE_DLL_API bool isDataMemberReference(SgVarRefExp *varRefExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool language_may_contain_nondeclarations_in_scope()
void rebuildSymbolTable(SgScopeStatement *scope)
Regenerate the symbol table.
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...
ROSE_DLL_API bool isConstType(SgType *t)
Is this a const type?
ROSE_DLL_API LivenessAnalysis * call_liveness_analysis(SgProject *project, bool debug=false)
Call liveness analysis on an entire project.
SgFunctionDeclaration * getDeclarationOfNamedFunction(SgExpression *func)
Given a SgExpression that represents a named function (or bound member function), return the mentione...
ROSE_DLL_API PreprocessingInfo * insertHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader, bool asLastHeader)
Insert #include "filename" or #include (system header) onto the global scope of a source f...
ROSE_DLL_API bool isRestrictType(SgType *t)
Is this a restrict type?
ROSE_DLL_API bool is_C99_language()
This class represents a source project, with a list of SgFile objects and global information about th...
ROSE_DLL_API SgStatement * getNextStatement(SgStatement *currentStmt)
Get next statement within the same scope of current statement.
ROSE_DLL_API SgType * getElementType(SgType *t)
Get the element type of an array, pointer or string, or NULL if not applicable. This function only ch...
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 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 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...
virtual std::string class_name() const ROSE_OVERRIDE
returns a string representing the class name
ROSE_DLL_API SgVariableSymbol * appendArg(SgFunctionParameterList *, SgInitializedName *)
Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for argume...
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 bool is_mixed_Fortran_and_C_language()
SgNamespaceDefinitionStatement * enclosingNamespaceScope(SgDeclarationStatement *declaration)
Find the enclosing namespace of a declaration.
ROSE_DLL_API bool is_CAF_language()
ROSE_DLL_API void removeJumpsToNextStatement(SgNode *)
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments...
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 bool insideHeader(SgLocatedNode *node)
Check if a node is from a header file.
void collectVarRefs(SgLocatedNode *root, std::vector< SgVarRefExp * > &result)
Collect all variable references in a subtree.
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 void deepDelete(SgNode *root)
Deep delete a sub AST tree. It uses postorder traversal to delete each child node. Users must take care of any dangling pointers, symbols or types that result. This is identical to deleteAST()
std::string declarationPositionString(const SgDeclarationStatement *declaration)
Generate a unique string from the source file position information.
This class represents the concept of a C or C++ variable declaration.
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, starting from top of ScopeStack if currentscope is not given or NULL
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...
std::map< SgNode *, std::string > local_node_to_name_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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...
Represents an interpretation of a binary container.
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 ...
This class represents the concept of a C or C++ label statement.
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...
ROSE_DLL_API bool isPointerToNonConstType(SgType *type)
Is this a pointer to a non-const type? Note that this function will return true for const pointers po...
SgDeclarationStatement * get_firstNondefiningDeclaration() const
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
ROSE_DLL_API void dumpInfo(SgNode *node, std::string desc="")
Dump information about a SgNode for debugging.
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 void fixNamespaceDeclaration(SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
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. Move around preprocessing info automatically.
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, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default.
This class represents the concept of a C++ function call (which is an expression).
void reset_name_collision_map()
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.
Base class for binary files.
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 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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API bool is_Cuda_language()
ROSE_DLL_API SgNode * replaceWithPattern(SgNode *anchor, SgNode *new_pattern)
Replace an anchor node with a specified pattern subtree with optional SgVariantExpression. All SgVariantExpression in the pattern will be replaced with copies of the anchor node.
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 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...
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...
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 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...
This class represents the concept of a declaration statement.
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
This class represents the concept of a switch.
ROSE_DLL_API SgExpression * copyExpression(SgExpression *e)
Deep copy an expression.
ROSE_DLL_API bool isUpcPhaseLessSharedType(SgType *t)
Is UPC phase-less shared type? Phase-less means block size of the first SgModifierType with UPC infor...
ROSE_DLL_API SgType * getArrayElementType(SgType *t)
Get the element type of an array. It recursively find the base type for multi-dimension array types...
void listHeaderFiles(SgIncludeFile *includeFile)
return path prefix for subtree of include files.
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 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 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 replaceMacroCallsWithExpandedStrings(SgPragmaDeclaration *target)
Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the p...
ROSE_DLL_API bool is_mixed_C_and_Cxx_language()
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...