ROSE  0.11.96.11
attach_all_info.h
1 #ifndef _ATTACH_ALL_INFO_H_
2 #define _ATTACH_ALL_INFO_H_
3 
4 #if 0
6  {
7  SgLocatedNode *previousLocNodePtr;
8 #if 0
9  // DQ (11/30/2008): Moved currentListOfAttributes to inherited attribute
10  ROSEAttributesList *currentListOfAttributes;
11  int sizeOfCurrentListOfAttributes;
12 #endif
13  // wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t(SgLocatedNode* node=NULL, ROSEAttributesList* preprocInfo=NULL, int len=0);
15  };
16 #else
17 // DQ (12/3/2008): This is the data that we have to save (even though the currentListOfAttributes has been moved to the inherited attribute)
19  {
20  SgLocatedNode *previousLocNodePtr;
21  ROSEAttributesList *currentListOfAttributes;
22  int sizeOfCurrentListOfAttributes;
24  };
25 #endif
26 
28  {
29  private:
30  std::string src_file_name;
31  SgFile * sage_file;
32 
33  /* map: key = filename, value = a wrapper for the data used in AttachPreprocessingInfoTreeTrav. */
34  std::map<int, wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t> map_of_all_attributes;
35 
36  /* map: key = filename, value = the first node in AST from the file (could be NULL) */
37  /* std::map<std::string, SgNode*> map_of_first_node; */
38  /* I need to keep the order for each file when it is discovered from AST */
39  int nFiles; /* total number of files involved */
40  std::map<int, int> map_of_file_order;
41 
42  std::vector<SgNode*> array_of_first_nodes;
43 
44  // This is hepful in limiting the amount of data saved and files processed
45  // within the handling of a large application that include system header files.
46  // Basically we want to avoid processing comments in system header files
47  // because they are not relevant.
48  // Holds paths to exclude when getting all commments and directives
49  std::vector<std::string> pathsToExclude;
50  bool lookForExcludePaths;
51 
52  // Holds paths to include when getting all comments and directives
53  std::vector<std::string> pathsToInclude;
54  bool lookForIncludePaths;
55 
56  /* set the first node for the file (may resize the
57  array_of_first_nodes); return false means the first node for the
58  file has already existed and keep the previous first node. */
59  bool add_first_node_for_file(const int, SgNode* n, int pos);
60 
61  /* it returns the first node after file "fn"; return <NULL,
62  anything> iff no node in the whole array_of_first_nodes for
63  attaching preprocessing info; "hintfororder" is the number of
64  handled files before file "fn". */
65  std::pair<SgNode*, PreprocessingInfo::RelativePositionType> get_first_node_for_file(const int fn, int hintfororder);
66 
67  public:
69 
70  /* Pi: To make the way for attaching preproc info the same as
71  before, we basically call the same functions in
72  AttachPreprocessingInfoTreeTrav, although we need to set the data
73  used by them before calling them, and update the data after they
74  use it. */
77 
78  /* to handle those files which contain no IR nodes. */
79  private:
80  std::istream & dependancies; /* use cin for now, better to run ROSE internally to get the list. TODO. */
81  public:
82  /* attach preproc info from files containing no IR nodes: assume the
83  order of the list of dependency files are in the correct order,
84  attach such preproc info to the first node from the files after
85  the current file. TODO: still have a problem if no files after
86  the current file. */
87  // bool attach_left_info();
88 
89  // DQ (10/27/2007): Added display function to output information gather durring the collection of
90  // comments and CPP directives across all files.
91  void display(const std::string & label) const;
92  };
93 
94 #if 0
95 // DQ (10/27/2007): This is not used!
96 
97 void attachAllPreprocessingInfo1(SgProject* sagep, const char * dep); /* dep is the file containing a list of dependencies. */
98 /* Alg (Too slow): (1) use appropriate shell commands to get a list of
99  dependencies (in a certain format) (could be automated based on the
100  command line options stored in sagep); (2) suppose n dependencies:
101  traverse the whole AST n times, each time set current file name in
102  the SgFile node to a different dependency before traversal (a hack
103  based on evaluateInheritedAttribute(...) in class
104  AttachPreprocessingInfoTreeTrav */
105 
106 // DQ (4/19/2006): This is now placed into the attachPreprocessingInfo(SgFile*) function!
107 // void attachAllPreprocessingInfo(SgFile* sagep);
108 #endif
109 
110 #endif /* _ATTACH_ALL_INFO_H_ */
SgLocatedNode
This class represents the notion of an expression or statement which has a position within the source...
Definition: Cxx_Grammar.h:74391
ROSEAttributesList
Definition: rose_attributes_list.h:495
AttachAllPreprocessingInfoTreeTrav
Definition: attach_all_info.h:27
SgFile
This class represents a source file for a project (which may contian many source files and or directo...
Definition: Cxx_Grammar.h:21163
AttachAllPreprocessingInfoTreeTrav::evaluateSynthesizedAttribute
AttachPreprocessingInfoTreeTraversalSynthesizedAttribute evaluateSynthesizedAttribute(SgNode *n, AttachPreprocessingInfoTreeTraversalInheritedAttrribute inh, SubTreeSynthesizedAttributes st)
pure virtual function which must be implemented to compute the synthesized attribute at a node.
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739
AttachPreprocessingInfoTreeTraversalInheritedAttrribute
Definition: attachPreprocessingInfoTraversal.h:22
AttachPreprocessingInfoTreeTraversalSynthesizedAttribute
Definition: attachPreprocessingInfoTraversal.h:84
StackFrameVector
Definition: StackFrameVector.h:43
AttachPreprocessingInfoTreeTrav
Definition: attachPreprocessingInfoTraversal.h:86
AttachAllPreprocessingInfoTreeTrav::evaluateInheritedAttribute
AttachPreprocessingInfoTreeTraversalInheritedAttrribute evaluateInheritedAttribute(SgNode *n, AttachPreprocessingInfoTreeTraversalInheritedAttrribute inh)
pure virtual function which must be implemented to compute the inherited attribute at a node
SgProject
This class represents a source project, with a list of SgFile objects and global information about th...
Definition: Cxx_Grammar.h:24060
wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t
Definition: attach_all_info.h:18