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