ROSE  0.11.101.0
rose_attributes_list.h
1 #ifndef __ROSEAttributesList_H__
2 #define __ROSEAttributesList_H__
3 
4 //#include "setup.h"
5 
6 //#include <list>
7 //#include <vector>
8 #include <map>
9 
10 // Include the ROSE lex specific definitions of tokens
11 #include "general_token_defs.h"
12 
13 // #ifdef CAN_NOT_COMPILE_WITH_ROSE
14 // #warning "CAN_NOT_COMPILE_WITH_ROSE IS defined"
15 // #else
16 // #warning "CAN_NOT_COMPILE_WITH_ROSE is NOT defined"
17 // #endif
18 
19 // DQ (2/28/2010): Skip this if we are compiling ROSE using ROSE.
20 // This is being used in place of the CAN_NOT_COMPILE_WITH_ROSE macro.
21 // Note that CAN_NOT_COMPILE_WITH_ROSE is set by the following projects:
22 // 1) projects/DocumentationGenerator
23 // 2) projects/haskellport
24 // in their Makefile.am files. I think that using CXX_IS_ROSE_ANALYSIS
25 // will be equivalent (used to indicate the a ROSE translator is being
26 // used to compile the ROSE source code).
27 // However, it might be that this is equivalent to the USE_ROSE macro,
28 // which is set for all ROSE translators when they compile any code.
29 // DQ (12/22/2008): I would appreciate it if this were a better name...
30 // #if !CAN_NOT_COMPILE_WITH_ROSE
31 // #ifndef USE_ROSE
32 
33 // DQ (5/21/2010): I have built a separate macro for tuning off the compilation of WAVE
34 // since it is done only for the purpose of allowing ROSE based projects:
35 // 1) projects/DocumentationGenerator
36 // 2) projects/haskellport
37 // to process the ROSE files cleanly. ROSE can however process and compile ROSE
38 // (including a slightly modified version of WAVE that EDG will accept) and we
39 // separately test this in noightly tests. The previous 5/18/2010 fix to permit
40 // the Haskell support to skip processign WAVE turned this off and broke the nightly
41 // tests of ROSE compiling ROSE. This use of the macro ROSE_SKIP_COMPILATION_OF_WAVE
42 // it menat to be turned on by ROSE based tools that need to process the ROSE code
43 // and which currently fail (because of Wave) and so turn of the processing of Wave
44 // for those tools.
45 // #ifdef USE_ROSE
46 // #define ROSE_SKIP_COMPILATION_OF_WAVE
47 // #endif
48 
49 // DQ (2/27/2016): Check for DEBIAN and Boost 1.54 and disable WAVE (not found in
50 // Boost 1.54, for Debian OS installations, as I understand it). This is a fix
51 // for a bug identified to be specific to Boost 1.54 on Debian systems, so that
52 // is why it is so specific in deactivating boost::wave. To support this the
53 // boost::wave support had to be revisited to permit it to NOT be a dependence.
54 // We shuld put in place tests that make sure it does not accedently become a
55 // dependence in the future.
56 #ifdef ROSE_DEBIAN_OS_VENDOR
57  #if (ROSE_BOOST_VERSION == 105400)
58  #define ROSE_SKIP_COMPILATION_OF_WAVE
59  #endif
60 #endif
61 
62 #if __sun
63  // PP 05/16/19
64  // Continue skipping WAVE until it is needed
65  // (after boost 1.65 is working on Solaris, WAVE should also work)
66  #define ROSE_SKIP_COMPILATION_OF_WAVE
67 #endif
68 
69 // DQ (2/27/2016): Test compilation of ROSE without boost::wave support.
70 // #define ROSE_SKIP_COMPILATION_OF_WAVE
71 
72 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
73 // #if _MSC_VER < 1600 // 1600 == VC++ 10.0
74  #if (!defined(_MSC_VER) || (_MSC_VER > 1600))
75  #include <boost/preprocessor/iteration/iterate.hpp> // Liao, 7/10/2009, required by GCC 4.4.0 for a #define line of BOOST_PP_ITERATION_DEPTH
76  #ifdef _MSC_VER
77  #include <boost/wave.hpp> // CH (4/7/2010): Put this header here to avoid compiling error about mismatch between defination and declaration
78  #endif
79  #include <boost/wave/cpplexer/cpp_lex_token.hpp> // token class
80  #include <boost/wave/cpplexer/cpp_lex_iterator.hpp> // lexer type
81  #else
82 // #warning "Setting CAN_NOT_COMPILE_WITH_ROSE to value = 1"
83 // #define CAN_NOT_COMPILE_WITH_ROSE 1
84 // tps (12/4/2009) : This is not found in VC++ 10.0 and Boost 1.4
85  #pragma message ("Boost preprocessor and wave not included yet for VC++ 10.0")
86 
87  #endif
88 #endif
89 
90 //template boost::wave::cpplexer::impl::token_data<std::string, boost::wave::util::file_position_type>::delete(std::size_t) ;
91 // DQ (10/16/2002): Required for compiling with SUN 5.2 C++ compiler
92 #ifndef NAMESPACE_IS_BROKEN
93 // DQ (12/30/2005): This is a Bad Bad thing to do (I can explain)
94 // it hides names in the global namespace and causes errors in
95 // otherwise valid and useful code. Where it is needed it should
96 // appear only in *.C files (and only ones not included for template
97 // instantiation reasons) else they effect user who use ROSE unexpectedly.
98 // using namespace std;
99 #endif
100 
101 class ROSE_DLL_API PreprocessingInfo;
102 class ROSEAttributesList;
103 //AS(01/04/07) Global map of filenames to PreprocessingInfo*'s as it is inefficient
104 //to get this by a traversal of the AST
105 extern std::map<std::string,ROSEAttributesList* > mapFilenameToAttributes;
106 
107 
108 // DQ (4/19/2006): Forward declaration so that PreprocessingInfo can
109 // contain a pointer to a Sg_File_Info object.
110 class Sg_File_Info;
111 
112 // DQ (1/21/2008): Need forward declaration
113 class SgFile;
114 
115 // #if !CAN_NOT_COMPILE_WITH_ROSE
116 // #ifndef USE_ROSE
117 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
118 
119 typedef boost::wave::cpplexer::lex_token<> token_type;
120 typedef std::vector<token_type> token_container;
121 typedef std::list<token_type> token_list_container;
122 typedef std::vector<std::list<token_type> > token_container_container;
123 
124 #endif
125 
128  {
129  public:
130  // DQ (10/15/2002) moved this to nested scope to avoid global name pollution :-).
134  {
135  defaultValue = 0, // let the zero value be an error value
136  undef = 1, // Position of the directive is only going to be defined
137  // when the preprocessing object is copied into the AST,
138  // it remains undefined before that
139  before = 2, // Directive goes before the correponding code segment
140  after = 3, // Directive goes after the correponding code segment
141  inside = 4, // Directive goes inside the correponding code segment (as in between "{" and "}" of an empty basic block)
142 
143  // DQ (7/19/2008): Added additional fields so that we could use this enum type in the AstUnparseAttribute
144  // replace = 5, // Support for replacing the IR node in the unparsing of any associated subtree
145  before_syntax = 6, // We still have to specify the syntax
146  after_syntax = 7 // We still have to specify the syntax
147  };
148 
149  // Enum type to help classify the type for string that has been saved.
150  // This helps in the unparsing to make sure that line feeds are introduced properly.
151  //
152  // Rama (08/17/07): Adding a CpreprocessorDeadIfDeclaration and its support
153  // in various files.
154  enum DirectiveType
155  {
156  // This is treated as an error
157  CpreprocessorUnknownDeclaration,
158 
159  // These are a classification for comments
160  C_StyleComment,
161  CplusplusStyleComment,
162  FortranStyleComment,
163 
164  // FMZ(5/14/2010): Added freeform comments (started with "!")
165  F90StyleComment,
166 
167  // Rasmussen (11/3/2020): Added Ada and Jovial comments
168  AdaStyleComment,
169  JovialStyleComment,
170 
171  // DQ (11/20/2008): Added classification for blank line (a language independent form of comment).
172  CpreprocessorBlankLine,
173 
174  // These used to be translated into IR nodes (and will be in the future).
175  CpreprocessorIncludeDeclaration,
176  CpreprocessorIncludeNextDeclaration,
177  CpreprocessorDefineDeclaration,
178  CpreprocessorUndefDeclaration,
179  CpreprocessorIfdefDeclaration,
180  CpreprocessorIfndefDeclaration,
181  CpreprocessorIfDeclaration,
182  CpreprocessorDeadIfDeclaration,
183  CpreprocessorElseDeclaration,
184  CpreprocessorElifDeclaration,
185  CpreprocessorEndifDeclaration,
186  CpreprocessorLineDeclaration,
187  CpreprocessorErrorDeclaration,
188 
189  // DQ (10/19/2005): Added CPP warning directive
190  CpreprocessorWarningDeclaration,
191  CpreprocessorEmptyDeclaration,
192 
193  // AS (11/18/05): Added macro support (these are generated by the Wave
194  // support, but need to be better documented as to what they mean).
195  CSkippedToken,
196  CMacroCall,
197 
198  // AS & LIAO (8/12/2008): A PreprocessingInfo that is a
199  // hand made MacroCall that will expand into a valid statement.
200  CMacroCallStatement,
201 
202  // DQ (11/28/2008): What does this mean!
203  // A line replacement will replace a sub-tree in the AST
204  // after a node with position (filename,line)
205  LineReplacement,
206 
207  // The is the 'extern "C" {' construct. Note that this is not captured in
208  // the EDG AST and it is required to be captured as part of the CPP and
209  // comment preprocessing.
210  ClinkageSpecificationStart,
211  ClinkageSpecificationEnd,
212 
213  // DQ (11/17/2008): Added support for #ident
214  CpreprocessorIdentDeclaration,
215 
216  // DQ (11/17/2008): This handles the case CPP declarations (called "linemarkers")
217  // (see Google for more details) such as: "# 1 "test2008_05.F90"", "# 1 "<built-in>"",
218  // "# 1 "<command line>"" "# 1 "test2008_05.F90""
219  // The first token is the line number,
220  // the second token is the filename (or string),
221  // the optional tokens (zero or more) are flags:
222  // '1' indicates the start of a new file.
223  // '2' indicates returning to a file (having included another file).
224  // '3' indicates that the following text comes from a system header file, so certain warnings should be supressed.
225  // '4' indicates that the following text should be treated as being wrapped in an implicit 'extern "C"' block
226  CpreprocessorCompilerGeneratedLinemarker,
227 
228  // DQ (2/2/2014): permit raw text to be specified as a extremely simple way to add text to the unparsing of the AST.
229  // Note that it is the user's responcability to have the text be legal code. Additionall any language constructs
230  // added using this mechanism will ot show up in the AST. So it is not possible to reference functions (for example)
231  // added using this mechanism to build function calls as transformation elsewhere in the code. But one could add
232  // the function via AST transformations and the function body using a mechanism provided here and that would define
233  // a simple appoach to adding large complex functions for which it is impractical to build up an AST.
234  RawText,
235 
236  CpreprocessorEnd_ifDeclaration, // PP (10/1/21): Ada "end if"
237 
238  LastDirectiveType
239  };
240 
241  // DQ (7/10/2004): Make the data private
242  private:
243 
244  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
245  // information about the filename, line number, and column number.
246  Sg_File_Info* file_info;
247  // int lineNumber;
248  // int columnNumber;
249 
250  // Use string class to improve implementation
251  // char* stringPointer;
252  std::string internalString;
253 
254  int numberOfLines;
255 
256  // enum value representing a classification of the different types of directives
257  DirectiveType whatSortOfDirective;
258 
259  // Corresponding enum value
260  RelativePositionType relativePosition;
261 
262  // DQ (11/28/2008): Support for CPP generated linemarkers
263  int lineNumberForCompilerGeneratedLinemarker;
264  std::string filenameForCompilerGeneratedLinemarker;
265  std::string optionalflagsForCompilerGeneratedLinemarker;
266 
267  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
268  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
269  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
270  // the AST. The problem is that we wnat to record where there might be comments or CPP directives removed and having
271  // a flag here is not going to work for that. so we have to also record that the ROSEAttributesList has changed.
272  bool p_isTransformation;
273 
274 // This is part of Wave support in ROSE.
275 // #ifndef USE_ROSE
276  public:
277 /*
278  // AS using the lexer_token from boost_wave in order to store structures
279  typedef boost::wave::cpplexer::lex_token<> token_type;
280  typedef std::vector<token_type> token_container;
281  typedef std::list<token_type> token_list_container;
282  typedef std::vector<std::list<token_type> > token_container_container;
283 */
284  private:
285  // FIXME: To support Jochens AST binary save work the tokenSteam must
286  // have a pointer type.
287 
288 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
289  // A stream of tokens representing the current prerpocessing info
290  // object. This is equivalent to the internal string, but of cause
291  // contains more information since it is a tokenized stream.
292  token_container* tokenStream;
293 
294  public:
295  typedef struct r_include_directive
296  {
297  // The parameter 'directive' contains the (expanded) file name found after
298  // the #include directive. This has the format '<file>', '"file"' or 'file'.
299  token_type directive;
300  // The paths plus name to the include directive filename
301  std::string absname;
302  std::string relname;
304 
305  // Internal representation of a macro #define directive
306  typedef struct r_macro_def
307  {
308  bool is_functionlike;
309  bool is_predefined;
310  token_type macro_name;
311  token_container paramaters;
312  token_list_container definition;
313  r_macro_def() : macro_name(), paramaters(),definition() {}
315 
316  // Internal representation of a macro call
317  // e.g #define MACRO_CALL int x;
318  // MACRO_CALL
319 #if 0
320  typedef struct r_macro_call
321  {
322  bool is_functionlike;
323  PreprocessingInfo* macro_def;
324  token_type macro_call;
325  token_container_container arguments;
326  token_container expanded_macro;
327 
328  // Get string representation of the expanded macro
329  std::string get_expanded_string()
330  {
331  std::ostringstream os;
332  token_container::const_iterator iter;
333  for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
334  os << (*iter).get_value();
335  return os.str();
336  }
337 
338  r_macro_call() : macro_call(), arguments(),expanded_macro() {}
339  } rose_macro_call;
340 #else
341  // DQ (3/9/2013): Modified to address SWIG error.
343  {
344  bool is_functionlike;
345  PreprocessingInfo* macro_def;
346  token_type macro_call;
347  token_container_container arguments;
348  token_container expanded_macro;
349 
350  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
351  // Get string representation of the expanded macro
352  std::string get_expanded_string();
353 
354  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
355  rose_macro_call();
356  };
357 #endif
358 
359  private:
360  // AS add macro definition
361  rose_macro_definition* macroDef;
362  // AS add macro call
363  rose_macro_call* macroCall;
364  // AS include directive
365  rose_include_directive* includeDirective;
366 
367 #endif
368 
369  // member functions
370  public:
373 
374 // #ifndef USE_ROSE
375 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
376  // AS (112105) Added constructors to support macros
377  PreprocessingInfo(token_container, DirectiveType, RelativePositionType);
380  PreprocessingInfo(token_type, token_list_container, bool, DirectiveType,RelativePositionType);
382 #endif
383 
384  // This constructor is called from the C++ code generated from the lex file (preproc.lex)
385  // PreprocessingInfo(DirectiveType, const char *inputStringPointer, int line_no , int col_no,
386  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag) ROSE_DEPRECATED_FUNCTION;
387 
388  // DQ (7/19/2008): I have removed the bool copiedFlag and bool unparsedFlag parameters because they are not used
389  // and are present only because in an older implementation of the unparser it would make the PreprocessingInfo
390  // as unparsed (and maybe copied) but this sort of side-effect of the unparser was later removed to make the
391  // unparsing side-effect free.
392  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
393  // information about the filename, line number, and column number.
394  // DQ (3/15/2006): Build constructor that uses C++ string as input (to replace the char* based constructor)
395  // PreprocessingInfo(DirectiveType, const std::string inputString, int line_no , int col_no,
396  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag);
397  // PreprocessingInfo(DirectiveType, const std::string & inputString,
398  // const std::string & filenameString, int line_no , int col_no,
399  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag );
400  PreprocessingInfo(DirectiveType, const std::string & inputString,
401  const std::string & filenameString, int line_no , int col_no,
402  int nol, RelativePositionType relPos );
403 
404  // Copy constructor
405  PreprocessingInfo(const PreprocessingInfo &prepInfo);
406 
407  void display(const std::string & label) const;
408 
409  // Access functions
410  int getLineNumber() const;
411  int getColumnNumber() const;
412  std::string getString() const;
413  void setString ( const std::string & s );
414  int getStringLength() const;
415  DirectiveType getTypeOfDirective() const;
416  void setTypeOfDirective(DirectiveType);
417  RelativePositionType getRelativePosition(void) const;
418  void setRelativePosition(RelativePositionType relPos);
419 
420  // DQ (2/27/2019): Adding support for CPP directives and comments to have filename information (already present, but we need to access it).
421  std::string getFilename() const;
422  int getFileId() const;
423 
424  // Number of lines occupied by this comment (count the number of line feeds)
425  int getNumberOfLines() const;
426  int getColumnNumberOfEndOfString() const; // only correct for single line directives
427 
428  // Used in unparse to string mechanism
429  // char* removeLeadingWhiteSpace (const char* inputStringPointer);
430 
431  // DQ (8/6/2006): Modified to make these static functions
432  // useful for debugging
433  static std::string directiveTypeName (const DirectiveType & directive);
434  static std::string relativePositionName (const RelativePositionType & position);
435 
436  // JH (01/03/2006) methods for packing the PreprocessingInfo data, in order to store it into
437  // a file and rebuild it!
438  unsigned int packed_size () const;
439 
440  // JH (01/032006) This pack methods might cause memory leaks. Think of deleting them after stored to file ...
441  char* packed() const;
442  void unpacked( char* storePointer );
443 
444  // DQ (4/19/2006): Added Sg_File_Info objects to each PreprocessingInfo object
445  Sg_File_Info* get_file_info() const;
446  void set_file_info( Sg_File_Info* info );
447 
448  // DQ (8/26/2020): include directive have a filename imbedded inside, and we need to
449  // extract that for from tools (e.g. the fixup for initializers from include files).
450  std::string get_filename_from_include_directive();
451 
452  // DQ (11/28/2008): Support for CPP generated linemarkers
453  int get_lineNumberForCompilerGeneratedLinemarker();
454  std::string get_filenameForCompilerGeneratedLinemarker();
455  std::string get_optionalflagsForCompilerGeneratedLinemarker();
456 
457  // DQ (11/28/2008): Support for CPP generated linemarkers
458  void set_lineNumberForCompilerGeneratedLinemarker( int x );
459  void set_filenameForCompilerGeneratedLinemarker( std::string x );
460  void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
461 
462 // #ifndef USE_ROSE
463 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
464  // Wave specific member functions.
465  public:
466  // Access functions to get the macro call or macro definition.
467  // These are NULL if the type is not CMacroCall or
468  // CpreprocessorDefineDeclaration
469  rose_macro_call* get_macro_call();
470  rose_macro_definition* get_macro_def();
471  rose_include_directive* get_include_directive();
472 
473  const token_container* get_token_stream();
474  void push_front_token_stream(token_type tok);
475  void push_back_token_stream(token_type tok);
476 
477 #endif
478 
479  // DQ (12/30/2013): Adding support to supress output of macros that are self-referential.
480  // e.g. "#define foo X->foo", which would be expanded a second time in the backend processing.
481  // Note that if we don't output the #define, then we still might have a problem if there was
482  // code that depended upon a "#ifdef foo". So this handling is not without some risk, but it
483  // always better to use the token stream unparsing for these cases.
484  bool isSelfReferential();
485  std::string getMacroName();
486 
487  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
488  bool isTransformation() const;
489  void setAsTransformation();
490  void unsetAsTransformation();
491  };
492 
493 // DQ (10/15/2002) Changed list element from "PreprocessingInfo" to
494 // "PreprocessingInfo*" to avoid redundant copying of internal data.
495 // Define a new data type for the container that stores the
496 // PreprocessingInfo objects attached to an AST node
497 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
498 
500  {
501  private:
502  // DQ replaced use of old list class with STL
503  std::vector<PreprocessingInfo*> attributeList;
504 
505  // DQ (1/9/2021): Added comment.
506  // Note that the token stream is contained in the ROSEAttributesList list which before this just held
507  // the comments and CPP directives. This is OK, but the makes of the types and data members are less
508  // than ideal.
509  LexTokenStreamTypePointer rawTokenStream;
510 
511  // [DT] 3/15/2000 -- Name of file from which the directives come.
512  // char fileName[256];
513  std::string fileName;
514 
515  // 3/16/2000 -- Index into the list. Not sure if this is really
516  // necessary. See implementation in unparser.C.
517  //
518  // This is where the current line number is stored while we
519  // go off and unparse a different include file. This really should have
520  // been stored in a static structure (I think) rather than in this list.
521  int index;
522 
523  // DQ (12/15/2012): Save file ids that are from filenames referenced in #line
524  // directives, these will be considered equivalent to the input source filename.
525  std::set<int> filenameIdSet;
526 
527  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
528  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
529  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
530  // the AST. The problem is that we want to record where there might be comments or CPP directives removed and having
531  // a flag here is not going to work for that, so we have to also record that the ROSEAttributesList has changed.
532  // bool p_isTransformation;
533 
534  public:
535  // DQ (11/19/2008): Added language selection support for handling comments
536  enum languageTypeEnum
537  {
538  e_unknown_language = 0,
539  e_C_language = 1,
540  e_Cxx_language = 2,
541  e_Fortran77_language = 3,
542  e_Fortran9x_language = 4,
543  e_Ada_language = 5,
544  e_lastLanguage
545  };
546 
549  // DQ (4/19/2006): Adding SgFileInfo objects so we need to pass in a filename string
550  // void addElement(PreprocessingInfo::DirectiveType, const char *pLine, int lineNumber, int columnNumber, int numberOfLines);
551  void addElement(PreprocessingInfo::DirectiveType, const std::string & pLine, const std::string & filename, int lineNumber, int columnNumber, int numberOfLines);
552 #if 1
553  // DQ (5/9/2007): This is required for WAVE support.
554  // DQ (4/13/2007): I would like to remove this function, but it is used by WAVE support within ROSE.
555  void addElement( PreprocessingInfo &pRef );
556 #endif
557  // void addElements( ROSEAttributesList &);
558  void moveElements( ROSEAttributesList &);
559 
560 #if 1
561  // DQ (5/9/2007): This is required for WAVE support.
562  // DQ (4/13/2007): I would like to remove this function
563  void insertElement( PreprocessingInfo & pRef );
564 #endif
565 
566  // [DT] 3/15/2000 -- Interface to fileName member.
567  void setFileName(const std::string & fName);
568  std::string getFileName();
569 
570  // 3/16/2000 -- Interface to index member.
571  void setIndex(int i);
572  int getIndex();
573 
574  PreprocessingInfo* operator[](int i);
575  int size(void);
576  int getLength(void);
577  void deepClean(void);
578  void clean(void);
579 
580  // DQ (9/19/2013): generate the number associated with each position relative to the attached IR node.
581  // size_t numberByRelativePosition(PreprocessingInfo::RelativePositionType pos);
582 
583  // Access function for list
584  std::vector<PreprocessingInfo*> & getList() { return attributeList; };
585 
586  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
587 
588  // DQ (1/21/2008): Added access function to save the raw token stream from the lex pass.
589  void set_rawTokenStream( LexTokenStreamTypePointer s );
590  LexTokenStreamTypePointer get_rawTokenStream();
591 
592  // This function processes the token stream to generate the input for what weaves the
593  // CPP directives and comments into the AST. All other tokens are ignore in this pass.
594  void generatePreprocessorDirectivesAndCommentsForAST( const std::string & filename );
595 
596  // DQ (11/26/2008): This is old code!
597  // Collection comments and CPP directives for fixed format (easier case)
598  // void collectFixedFormatPreprocessorDirectivesAndCommentsForAST( const std::string & filename );
599 
600  // DQ (11/16/2008): Adding support for recognition of CPP directives outside of the lex tokenization.
601  void collectPreprocessorDirectivesAndCommentsForAST( const std::string & filename, languageTypeEnum languageType );
602 
603  // DQ (11/17/2008): Refactored the code.
604  bool isFortran77Comment( const std::string & line );
605  bool isFortran90Comment( const std::string & line );
606  bool isCppDirective( const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
607 
608  // DQ (12/15/2012): traverse the attributeList and process all of the #line directives to generate a
609  // list of file ids that should be considered equivalent to that of the input source file's filename.
610  // std::set<int> generateFileIdListFromLineDirectives();
611  void generateFileIdListFromLineDirectives();
612 
613  // DQ (12/15/2012): Added access function.
614  std::set<int> & get_filenameIdSet();
615 
616  // DQ (9/29/2013): Added to support adding processed CPP directives and comments as tokens to token list.
617  PreprocessingInfo* lastElement();
618 
619  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
620  // bool isTransformation() const;
621  // void setAsTransformation();
622  // void unsetAsTransformation();
623  };
624 
625 //
626 // [DT] 3/16/2000 -- Want to have preprocessing info for
627 // each file included from the main source file.
628 //
630  {
631  private:
632  // DQ replaced use of old list class with STL
633  // std::vector<ROSEAttributesList*> attributeListList;
634  // std::map<std::string,ROSEAttributesList*>* attrMap;
635  std::map<std::string, ROSEAttributesList*> attributeListMap;
636 
637  public:
640  // void addList ( ROSEAttributesList* listPointer );
641  void addList ( std::string fileName, ROSEAttributesList* listPointer );
642  // void addList(ROSEAttributesList &aRef);
643  // void insertList(ROSEAttributesList &aRef);
644  // ROSEAttributesList* operator[](int i);
645  // ROSEAttributesList* findList ( const std::string & fName );
646 
647  // Check to see if the ROSEAttributesList for the fName (filename) is in the container
648  bool isInList ( const std::string & fName );
649 
650  // int size(void);
651  // int getLength(void);
652  void dumpContents(void); // [DT] 3/16/2000 -- For debugging.
653  void deepClean(void);
654  void clean(void);
655  ROSEAttributesList & operator[]( const std::string & fName);
656 
657  // Access function for list
658  // std::vector<ROSEAttributesList*> & getList() { return attributeListList; };
659  std::map<std::string, ROSEAttributesList*> & getList() { return attributeListMap; };
660  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
661  };
662 
663 
664 // #ifndef USE_ROSE
665 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
666 
667 extern token_container wave_tokenStream;
668 
669 #endif
670 
671 #endif
This class represents a source file for a project (which may contian many source files and or directo...
This class represents the location of the code associated with the IR node in the original source cod...
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code...
For preprocessing information including source comments, #include , #if, #define, etc...