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