ROSE  0.11.52.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  LastDirectiveType
237  };
238 
239  // DQ (7/10/2004): Make the data private
240  private:
241 
242  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
243  // information about the filename, line number, and column number.
244  Sg_File_Info* file_info;
245  // int lineNumber;
246  // int columnNumber;
247 
248  // Use string class to improve implementation
249  // char* stringPointer;
250  std::string internalString;
251 
252  int numberOfLines;
253 
254  // enum value representing a classification of the different types of directives
255  DirectiveType whatSortOfDirective;
256 
257  // Corresponding enum value
258  RelativePositionType relativePosition;
259 
260  // DQ (11/28/2008): Support for CPP generated linemarkers
261  int lineNumberForCompilerGeneratedLinemarker;
262  std::string filenameForCompilerGeneratedLinemarker;
263  std::string optionalflagsForCompilerGeneratedLinemarker;
264 
265  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
266  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
267  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
268  // the AST. The problem is that we wnat to record where there might be comments or CPP directives removed and having
269  // a flag here is not going to work for that. so we have to also record that the ROSEAttributesList has changed.
270  bool p_isTransformation;
271 
272 // This is part of Wave support in ROSE.
273 // #ifndef USE_ROSE
274  public:
275 /*
276  // AS using the lexer_token from boost_wave in order to store structures
277  typedef boost::wave::cpplexer::lex_token<> token_type;
278  typedef std::vector<token_type> token_container;
279  typedef std::list<token_type> token_list_container;
280  typedef std::vector<std::list<token_type> > token_container_container;
281 */
282  private:
283  // FIXME: To support Jochens AST binary save work the tokenSteam must
284  // have a pointer type.
285 
286 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
287  // A stream of tokens representing the current prerpocessing info
288  // object. This is equivalent to the internal string, but of cause
289  // contains more information since it is a tokenized stream.
290  token_container* tokenStream;
291 
292  public:
293  typedef struct r_include_directive
294  {
295  // The parameter 'directive' contains the (expanded) file name found after
296  // the #include directive. This has the format '<file>', '"file"' or 'file'.
297  token_type directive;
298  // The paths plus name to the include directive filename
299  std::string absname;
300  std::string relname;
302 
303  // Internal representation of a macro #define directive
304  typedef struct r_macro_def
305  {
306  bool is_functionlike;
307  bool is_predefined;
308  token_type macro_name;
309  token_container paramaters;
310  token_list_container definition;
311  r_macro_def() : macro_name(), paramaters(),definition() {}
313 
314  // Internal representation of a macro call
315  // e.g #define MACRO_CALL int x;
316  // MACRO_CALL
317 #if 0
318  typedef struct r_macro_call
319  {
320  bool is_functionlike;
321  PreprocessingInfo* macro_def;
322  token_type macro_call;
323  token_container_container arguments;
324  token_container expanded_macro;
325 
326  // Get string representation of the expanded macro
327  std::string get_expanded_string()
328  {
329  std::ostringstream os;
330  token_container::const_iterator iter;
331  for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
332  os << (*iter).get_value();
333  return os.str();
334  }
335 
336  r_macro_call() : macro_call(), arguments(),expanded_macro() {}
337  } rose_macro_call;
338 #else
339  // DQ (3/9/2013): Modified to address SWIG error.
341  {
342  bool is_functionlike;
343  PreprocessingInfo* macro_def;
344  token_type macro_call;
345  token_container_container arguments;
346  token_container expanded_macro;
347 
348  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
349  // Get string representation of the expanded macro
350  std::string get_expanded_string();
351 
352  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
353  rose_macro_call();
354  };
355 #endif
356 
357  private:
358  // AS add macro definition
359  rose_macro_definition* macroDef;
360  // AS add macro call
361  rose_macro_call* macroCall;
362  // AS include directive
363  rose_include_directive* includeDirective;
364 
365 #endif
366 
367  // member functions
368  public:
371 
372 // #ifndef USE_ROSE
373 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
374  // AS (112105) Added constructors to support macros
375  PreprocessingInfo(token_container, DirectiveType, RelativePositionType);
378  PreprocessingInfo(token_type, token_list_container, bool, DirectiveType,RelativePositionType);
380 #endif
381 
382  // This constructor is called from the C++ code generated from the lex file (preproc.lex)
383  // PreprocessingInfo(DirectiveType, const char *inputStringPointer, int line_no , int col_no,
384  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag) ROSE_DEPRECATED_FUNCTION;
385 
386  // DQ (7/19/2008): I have removed the bool copiedFlag and bool unparsedFlag parameters because they are not used
387  // and are present only because in an older implementation of the unparser it would make the PreprocessingInfo
388  // as unparsed (and maybe copied) but this sort of side-effect of the unparser was later removed to make the
389  // unparsing side-effect free.
390  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
391  // information about the filename, line number, and column number.
392  // DQ (3/15/2006): Build constructor that uses C++ string as input (to replace the char* based constructor)
393  // PreprocessingInfo(DirectiveType, const std::string inputString, int line_no , int col_no,
394  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag);
395  // PreprocessingInfo(DirectiveType, const std::string & inputString,
396  // const std::string & filenameString, int line_no , int col_no,
397  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag );
398  PreprocessingInfo(DirectiveType, const std::string & inputString,
399  const std::string & filenameString, int line_no , int col_no,
400  int nol, RelativePositionType relPos );
401 
402  // Copy constructor
403  PreprocessingInfo(const PreprocessingInfo &prepInfo);
404 
405  void display(const std::string & label) const;
406 
407  // Access functions
408  int getLineNumber() const;
409  int getColumnNumber() const;
410  std::string getString() const;
411  void setString ( const std::string & s );
412  int getStringLength() const;
413  DirectiveType getTypeOfDirective() const;
414  void setTypeOfDirective(DirectiveType);
415  RelativePositionType getRelativePosition(void) const;
416  void setRelativePosition(RelativePositionType relPos);
417 
418  // DQ (2/27/2019): Adding support for CPP directives and comments to have filename information (already present, but we need to access it).
419  std::string getFilename() const;
420  int getFileId() const;
421 
422  // Number of lines occupied by this comment (count the number of line feeds)
423  int getNumberOfLines() const;
424  int getColumnNumberOfEndOfString() const; // only correct for single line directives
425 
426  // Used in unparse to string mechanism
427  // char* removeLeadingWhiteSpace (const char* inputStringPointer);
428 
429  // DQ (8/6/2006): Modified to make these static functions
430  // useful for debugging
431  static std::string directiveTypeName (const DirectiveType & directive);
432  static std::string relativePositionName (const RelativePositionType & position);
433 
434  // JH (01/03/2006) methods for packing the PreprocessingInfo data, in order to store it into
435  // a file and rebuild it!
436  unsigned int packed_size () const;
437 
438  // JH (01/032006) This pack methods might cause memory leaks. Think of deleting them after stored to file ...
439  char* packed() const;
440  void unpacked( char* storePointer );
441 
442  // DQ (4/19/2006): Added Sg_File_Info objects to each PreprocessingInfo object
443  Sg_File_Info* get_file_info() const;
444  void set_file_info( Sg_File_Info* info );
445 
446  // DQ (8/26/2020): include directive have a filename imbedded inside, and we need to
447  // extract that for from tools (e.g. the fixup for initializers from include files).
448  std::string get_filename_from_include_directive();
449 
450  // DQ (11/28/2008): Support for CPP generated linemarkers
451  int get_lineNumberForCompilerGeneratedLinemarker();
452  std::string get_filenameForCompilerGeneratedLinemarker();
453  std::string get_optionalflagsForCompilerGeneratedLinemarker();
454 
455  // DQ (11/28/2008): Support for CPP generated linemarkers
456  void set_lineNumberForCompilerGeneratedLinemarker( int x );
457  void set_filenameForCompilerGeneratedLinemarker( std::string x );
458  void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
459 
460 // #ifndef USE_ROSE
461 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
462  // Wave specific member functions.
463  public:
464  // Access functions to get the macro call or macro definition.
465  // These are NULL if the type is not CMacroCall or
466  // CpreprocessorDefineDeclaration
467  rose_macro_call* get_macro_call();
468  rose_macro_definition* get_macro_def();
469  rose_include_directive* get_include_directive();
470 
471  const token_container* get_token_stream();
472  void push_front_token_stream(token_type tok);
473  void push_back_token_stream(token_type tok);
474 
475 #endif
476 
477  // DQ (12/30/2013): Adding support to supress output of macros that are self-referential.
478  // e.g. "#define foo X->foo", which would be expanded a second time in the backend processing.
479  // Note that if we don't output the #define, then we still might have a problem if there was
480  // code that depended upon a "#ifdef foo". So this handling is not without some risk, but it
481  // always better to use the token stream unparsing for these cases.
482  bool isSelfReferential();
483  std::string getMacroName();
484 
485  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
486  bool isTransformation() const;
487  void setAsTransformation();
488  void unsetAsTransformation();
489  };
490 
491 // DQ (10/15/2002) Changed list element from "PreprocessingInfo" to
492 // "PreprocessingInfo*" to avoid redundant copying of internal data.
493 // Define a new data type for the container that stores the
494 // PreprocessingInfo objects attached to an AST node
495 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
496 
498  {
499  private:
500  // DQ replaced use of old list class with STL
501  std::vector<PreprocessingInfo*> attributeList;
502 
503  // DQ (1/9/2021): Added comment.
504  // Note that the token stream is contained in the ROSEAttributesList list which before this just held
505  // the comments and CPP directives. This is OK, but the makes of the types and data members are less
506  // than ideal.
507  LexTokenStreamTypePointer rawTokenStream;
508 
509  // [DT] 3/15/2000 -- Name of file from which the directives come.
510  // char fileName[256];
511  std::string fileName;
512 
513  // 3/16/2000 -- Index into the list. Not sure if this is really
514  // necessary. See implementation in unparser.C.
515  //
516  // This is where the current line number is stored while we
517  // go off and unparse a different include file. This really should have
518  // been stored in a static structure (I think) rather than in this list.
519  int index;
520 
521  // DQ (12/15/2012): Save file ids that are from filenames referenced in #line
522  // directives, these will be considered equivalent to the input source filename.
523  std::set<int> filenameIdSet;
524 
525  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
526  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
527  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
528  // the AST. The problem is that we want to record where there might be comments or CPP directives removed and having
529  // a flag here is not going to work for that, so we have to also record that the ROSEAttributesList has changed.
530  // bool p_isTransformation;
531 
532  public:
533  // DQ (11/19/2008): Added language selection support for handling comments
534  enum languageTypeEnum
535  {
536  e_unknown_language = 0,
537  e_C_language = 1,
538  e_Cxx_language = 2,
539  e_Fortran77_language = 3,
540  e_Fortran9x_language = 4,
541  e_Ada_language = 5,
542  e_lastLanguage
543  };
544 
547  // DQ (4/19/2006): Adding SgFileInfo objects so we need to pass in a filename string
548  // void addElement(PreprocessingInfo::DirectiveType, const char *pLine, int lineNumber, int columnNumber, int numberOfLines);
549  void addElement(PreprocessingInfo::DirectiveType, const std::string & pLine, const std::string & filename, int lineNumber, int columnNumber, int numberOfLines);
550 #if 1
551  // DQ (5/9/2007): This is required for WAVE support.
552  // DQ (4/13/2007): I would like to remove this function, but it is used by WAVE support within ROSE.
553  void addElement( PreprocessingInfo &pRef );
554 #endif
555  // void addElements( ROSEAttributesList &);
556  void moveElements( ROSEAttributesList &);
557 
558 #if 1
559  // DQ (5/9/2007): This is required for WAVE support.
560  // DQ (4/13/2007): I would like to remove this function
561  void insertElement( PreprocessingInfo & pRef );
562 #endif
563 
564  // [DT] 3/15/2000 -- Interface to fileName member.
565  void setFileName(const std::string & fName);
566  std::string getFileName();
567 
568  // 3/16/2000 -- Interface to index member.
569  void setIndex(int i);
570  int getIndex();
571 
572  PreprocessingInfo* operator[](int i);
573  int size(void);
574  int getLength(void);
575  void deepClean(void);
576  void clean(void);
577 
578  // DQ (9/19/2013): generate the number associated with each position relative to the attached IR node.
579  // size_t numberByRelativePosition(PreprocessingInfo::RelativePositionType pos);
580 
581  // Access function for list
582  std::vector<PreprocessingInfo*> & getList() { return attributeList; };
583 
584  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
585 
586  // DQ (1/21/2008): Added access function to save the raw token stream from the lex pass.
587  void set_rawTokenStream( LexTokenStreamTypePointer s );
588  LexTokenStreamTypePointer get_rawTokenStream();
589 
590  // This function processes the token stream to generate the input for what weaves the
591  // CPP directives and comments into the AST. All other tokens are ignore in this pass.
592  void generatePreprocessorDirectivesAndCommentsForAST( const std::string & filename );
593 
594  // DQ (11/26/2008): This is old code!
595  // Collection comments and CPP directives for fixed format (easier case)
596  // void collectFixedFormatPreprocessorDirectivesAndCommentsForAST( const std::string & filename );
597 
598  // DQ (11/16/2008): Adding support for recognition of CPP directives outside of the lex tokenization.
599  void collectPreprocessorDirectivesAndCommentsForAST( const std::string & filename, languageTypeEnum languageType );
600 
601  // DQ (11/17/2008): Refactored the code.
602  bool isFortran77Comment( const std::string & line );
603  bool isFortran90Comment( const std::string & line );
604  bool isCppDirective( const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
605 
606  // DQ (12/15/2012): traverse the attributeList and process all of the #line directives to generate a
607  // list of file ids that should be considered equivalent to that of the input source file's filename.
608  // std::set<int> generateFileIdListFromLineDirectives();
609  void generateFileIdListFromLineDirectives();
610 
611  // DQ (12/15/2012): Added access function.
612  std::set<int> & get_filenameIdSet();
613 
614  // DQ (9/29/2013): Added to support adding processed CPP directives and comments as tokens to token list.
615  PreprocessingInfo* lastElement();
616 
617  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
618  // bool isTransformation() const;
619  // void setAsTransformation();
620  // void unsetAsTransformation();
621  };
622 
623 //
624 // [DT] 3/16/2000 -- Want to have preprocessing info for
625 // each file included from the main source file.
626 //
628  {
629  private:
630  // DQ replaced use of old list class with STL
631  // std::vector<ROSEAttributesList*> attributeListList;
632  // std::map<std::string,ROSEAttributesList*>* attrMap;
633  std::map<std::string, ROSEAttributesList*> attributeListMap;
634 
635  public:
638  // void addList ( ROSEAttributesList* listPointer );
639  void addList ( std::string fileName, ROSEAttributesList* listPointer );
640  // void addList(ROSEAttributesList &aRef);
641  // void insertList(ROSEAttributesList &aRef);
642  // ROSEAttributesList* operator[](int i);
643  // ROSEAttributesList* findList ( const std::string & fName );
644 
645  // Check to see if the ROSEAttributesList for the fName (filename) is in the container
646  bool isInList ( const std::string & fName );
647 
648  // int size(void);
649  // int getLength(void);
650  void dumpContents(void); // [DT] 3/16/2000 -- For debugging.
651  void deepClean(void);
652  void clean(void);
653  ROSEAttributesList & operator[]( const std::string & fName);
654 
655  // Access function for list
656  // std::vector<ROSEAttributesList*> & getList() { return attributeListList; };
657  std::map<std::string, ROSEAttributesList*> & getList() { return attributeListMap; };
658  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
659  };
660 
661 
662 // #ifndef USE_ROSE
663 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
664 
665 extern token_container wave_tokenStream;
666 
667 #endif
668 
669 #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...