ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sage3basic.h
Go to the documentation of this file.
1 /*
2  * this includes the forward declarations of all the sage node classes
3  * from the generated files (i.e. gives just the class names.)
4  *
5  */
6 
7 #ifndef SAGE3_CLASSES_BASIC__H
8 #define SAGE3_CLASSES_BASIC__H
9 
10 // DQ (11/12/2011): This is support to reduce the size of ROSE so that I can manage development on my laptop.
11 // This option defines a subset of ROSE as required to support wotk on the new EDG front-end.
12 // This is defined here becasuse it is not enough to define it in the rose_config.h
13 // because that can't be read early enough to effect what header files are included.
14 // #define ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
15 
16 // Much of ROSE's binary support uses the intX_t and uintX_t types (where X is a bit width), so we need to have the stdc printf
17 // format macros defined for portability. We do that here because it needs to be done before <inttypes.h> is included for the
18 // first time, and we know that most source files for the ROSE library include this file (sage3basic.h) at or near the
19 // beginning. We don't want to define __STDC_FORMAT_MACROS in user code that includes "rose.h" (the user may define it), and
20 // we need to define it in such a way that we won't get warning's if its already defined. [RMP 2012-01-29]
21 #ifndef __STDC_FORMAT_MACROS
22 #define __STDC_FORMAT_MACROS
23 #endif
24 #include <inttypes.h>
25 
26 
27 #include <semaphore.h>
28 #include "fileoffsetbits.h"
29 #include "rosedll.h"
30 //tps (05/04/2010): Added compatibility
31 #ifdef _MSC_VER
32  #define snprintf _snprintf
33 #endif
34 
35 // George Vulov (Aug. 23, 2010): This macro is not available in OS X by default
36 #ifndef TEMP_FAILURE_RETRY
37 #define TEMP_FAILURE_RETRY(expression) \
38  ({ \
39  long int _result; \
40  do _result = (long int) (expression); \
41  while (_result == -1L && errno == EINTR); \
42  _result; \
43  })
44 #endif
45 
46 // DQ (4/21/2009): Note that this header file will include the STL string header file
47 // which will include sys/stat.h, so the _FILE_OFFSET_BITS macro must be already set
48 // to avoid an ODR violation when using ROSE on 32-bit systems.
49 // DQ (11/10/2007): Added support for ROSE specific paths to be available. These are
50 // useful for tools built using ROSE, they are not presently being used within ROSE.
51 // RPM (8/22/2008): Commented out because it contains info that prevents us from making
52 // optimal use of ccache. "rose_paths.h" contains info that changes every time we
53 // configure. Can it be included at a finer granularity than this?
54 // DQ (8/25/2008): Turn this back on since it breaks ROSE for everyone else. We
55 // are searching for a better solution.
56 #include "rose_paths.h"
57 
58 
59 // DQ (5/30/2004): Added to permit warnings to be placed in the source code so that
60 // issues can be addressed later but called out during development (and eliminated
61 // from the final released version of the source code).
62 #define PRINT_DEVELOPER_WARNINGS 0
63 // #define PRINT_DEVELOPER_WARNINGS 1
64 
65 // Part of debuging use of SUN 6.1 compiler
66 #if defined(__WIN32__) || defined (__WIN16__)
67 #error "WIN macros should not be defined (test in sage3.h)"
68 #endif
69 
70 // Part of debuging use of SUN 6.1 compiler
71 #if defined(__MSDOS__) && defined(_Windows)
72 #error "MSDOS macros should not be defined"
73 #endif
74 
75 // DQ (4/21/2009): Added test to debug use of _FILE_OFFSET_BITS macro in controling size of "struct stat"
76 // #if defined(_FILE_OFFSET_BITS)
77 // #warning "The _FILE_OFFSET_BITS macro should not be set yet!"
78 // #endif
79 
80 // DQ (4/21/2009): This macro is set too late!
81 // Force 64-bit file offsets in struct stat
82 // #define _FILE_OFFSET_BITS 64
83 #include <sys/stat.h>
84 
85 //#include <cstdlib> // For abort()
86 #include <algorithm>
87 #include <fstream>
88 
89 // DQ (9/24/2004): Try again to remove use of set parent side effect in EDG/Sage III connection! This works!!!
90 #define REMOVE_SET_PARENT_FUNCTION
91 
92 // DQ (6/12/2007): Force checking for valid pointers to IR nodes being overwritten.
93 #define DEBUG_SAGE_ACCESS_FUNCTIONS 0
94 // DQ (6/12/2007): Force assertion test to fail such cases caught when DEBUG_SAGE_ACCESS_FUNCTIONS == 1, else just report error.
95 #define DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION 0
96 
97 // DQ (10/12/2004): Remove the resetTemplateName() from use within the EDG/Sage connection
98 // because it will (where required) force calls to generate the qualified name which
99 // requires the parent pointer to have already been set. Since we defer the
100 // setting of the parent pointers until post processing of the Sage III AST.
101 // It is now called within the AstFixup.C.
102 #define USE_RESET_TEMPLATE_NAME false
103 
104 #if 0
105 // DQ (5/22/2005):
106 // This is often turned of during development because it is annoying (until we can actually
107 // remove numerous functions where they are declared). Also not clear what versions of GNU
108 // support it.
109 
110 // Use the new GNU attribute mechanism to add more information to the source code
111 // By specifying funcations and variables as depreicated we can start the remove
112 // some functions and data members from Sage III.
113 #define ROSE_DEPRECATED_FUNCTION __attribute__ ((deprecated))
114 #define ROSE_DEPRECATED_VARIABLE __attribute__ ((deprecated))
115 #else
116 // DQ (9/8/2004): Allow these to get turned of to simplify debugging while we have not yet removed their use.
117 #define ROSE_DEPRECATED_FUNCTION
118 #define ROSE_DEPRECATED_VARIABLE
119 #endif
120 
121 // DQ (12/22/2007): Name of implicit Fortran "main" when building the program function.
122 #define ROSE_IMPLICIT_FORTRAN_PROGRAM_NAME "rose_fortran_main"
123 
124 // DQ (10/6/2004): We have tracked down and noted all locations where a Sage III member function modifies its input parameters.
125 // The locations where this happens are marked with a print statement which this macro permits us to turn off when we want to
126 // either make an intermediate release of just not see the warning messages. Many side-effects have been removed and some are
127 // pending more details discussions internally. I would like to goal to be a simple rule that input parameters to constructors
128 // are not modified by the constructor or any function called within the constructor body. A stronger rule would be that the
129 // input parameters to any access function which gets and data member of sets a data member would not modified its input
130 // parameters. Same idea but applied to all access functions, not just constructors. It is not clear if we need go further.
131 // Clearly it might be important to have some function that modify their input parameters but a simple design would disallow it!
132 #define PRINT_SIDE_EFFECT_WARNINGS false
133 
134 
135 // DQ (10/21/2004): We require a relaxed level of internal error checking for manually generated AST fragments!
136 // This is required for get through the current regression tests associated with the loop processing code which
137 // does not follwo the new rules for what qualifies as a valid AST. Time is needed for the AST Interface code
138 // to be adapted to the new rules. Not clear how this will effect the unparser!!!
139 // In the future we want to make this value "TRUE" this is a work around until then.
140 #ifdef _MSC_VER
141 #define STRICT_ERROR_CHECKING 0
142 #else
143 #define STRICT_ERROR_CHECKING false
144 #endif
145 
146 // DQ (11/7/2007): Reimplementation of "fixup" support for the AST copy mechanism.
147 // This version separates the fixup into three phases:
148 // Use three files to organize the separate functions (parent/scope setup, symbol table setup, and symbol references).
149 // Order of operations:
150 // 1) Setup scopes on all declaration (e.g. SgInitializedName objects).
151 // 2) Setup the symbol table.
152 // template instantiations must be added to to the symbol tables as defined by their scope
153 // because they may be located outside of their scope (indicated by their template declaration).
154 // We might need a test and set policy.
155 // Use the help map to support error checking in the symbol table construction. Check that
156 // scopes are not in the original AST (not keys in the help map).
157 // 3) Setup the references (SgVarRefExp objects pointers to SgVariableSymbol objects)
158 #define ALT_FIXUP_COPY 1
159 
160 
161 // AJ (10/21/2004) : the current version of g++ 3.2.3 has the "hash_map" deprecated - this
162 // deprecated hash_map is // in the global namespace and generates a warning every time
163 // the file gets included. The "ext/hash_map" is the newer version of the hash_map but
164 // it is no longer in the global namespace or std ( since the hash_map is not part of
165 // the standard STL) but in the compiler specific namespace (__gnu_cxx). Because of this,
166 // we have opted for using the newer version and explicitly using the namespace __gnu_cxx
167 // See below the using namespace section. If there is a need to change this to a more
168 // standard include "hash_map", please make sure you have selected the right namespace for
169 // using the hash_map and modify the section below
170 // for that.
171 // Liao, 7/10/2009
172 //#if __GNUC__ > 4 ||
173 // (__GNUC__ == 4 && (__GNUC_MINOR__ > 3 ||
174 // (__GNUC_MINOR__ == 3 &&
175 // __GNUC_PATCHLEVEL__ >= 0)))
176 //#include <unordered_map>
177 //#else
178 
179 
180 
181 //#endif
182 #if 1
183 #ifdef _MSC_VER
184 // DQ (11/4/2009): MS Visual Studio version of hash_multimap
185 //#include <cliext/hash_map>
186 #else
187 // DQ (11/4/2009): Use the GNU depricated stuff (what works in ROSE at the moment)
188 // tps (01/25/2010) : deprecated - does not work in setup.h
189 // CH (04/28/2010) : We don't need it anymore
190 //#include <ext/hash_map>
191 #endif
192 #endif
193 
194 // tps (01/22/2010) :refactored
195 #include "rosedefs.h"
196 // Support for preprocessors declarations and comments
197 #include "rose_attributes_list.h"
198 
199 // Include ROSE common utility function library
200 #include "string_functions.h"
201 #include "escape.h"
202 
203 // Include support for Brian Gunney's command line parser tool (nice work)
204 #include "sla.h"
205 
206 
207 // DQ (3/29/2006): I sure would like to remove this since it
208 // has a potential to effect other files from other projects
209 // used with ROSE.
210 // #define INLINE
211 
212 // DQ (9/21/2005): Support for memory pools.
213 // This allows for a total number of IR nodes (for each type of IR node) of
214 // (MAX_NUMBER_OF_MEMORY_BLOCKS * DEFAULT_CLASS_ALLOCATION_POOL_SIZE)
215 // It might be better to use an STL vector here since they we don't have
216 // an upper bound on the number of IR nodes of each type!!!
217 // #define DEFAULT_CLASS_ALLOCATION_POOL_SIZE 1000
218 
219 // Typical values used to testing the AST File I/O are 1 or 2, but larger values
220 // are required for better performance. At some point the value should be evaluated
221 // as even a value of 1000 is likely a bit small for larger whole applications.
222 // #define DEFAULT_CLASS_ALLOCATION_POOL_SIZE 1000
223 // #define DEFAULT_CLASS_ALLOCATION_POOL_SIZE 1
224 // #define DEFAULT_CLASS_ALLOCATION_POOL_SIZE 2
225 #define DEFAULT_CLASS_ALLOCATION_POOL_SIZE 1000
226 
227 // DQ (3/7/2010):Added error checking.
228 #if DEFAULT_CLASS_ALLOCATION_POOL_SIZE < 1
229  #error "DEFAULT_CLASS_ALLOCATION_POOL_SIZE must be greater than zero!"
230 #endif
231 
232 // DQ (3/7/2010): This is no longer used (for several years) and we use an STL based implementation.
233 // #define MAX_NUMBER_OF_MEMORY_BLOCKS 1000
234 
235 
236 // DQ (9/231/2005): Map these to the C library memory alloction/deallocation functions.
237 // These could use alternative allocators which allocate on page boundaries in the future.
238 // This is part of the support for memory pools for the Sage III IR nodes.
239 // #define ROSE_MALLOC malloc
240 // #define ROSE_FREE free
241 // DQ (9/9/2008): Don't let this be confused by a member function called "free" in Robb's work.
242 #define ROSE_MALLOC ::malloc
243 #define ROSE_FREE ::free
244 
245 // DQ (10/6/2006): Allow us to skip the support for caching so that we can measure the effects.
246 #define SKIP_BLOCK_NUMBER_CACHING 0
247 #define SKIP_MANGLED_NAME_CACHING 0
248 
249 #define USE_OLD_BINARY_EXECUTABLE_IR_NODES 0
250 
251 #define USING_OLD_EXECUTABLE_FORMAT_SUPPORT 0
252 #if USING_OLD_EXECUTABLE_FORMAT_SUPPORT
253 // DQ (12/8/2008): Build a forward declaration for the input parameter type for the
254 // SgAsmFileHeader class constructor.
255 namespace Exec { namespace ELF { class ElfFileHeader; }; };
256 #endif
257 
258 
259 // DQ (12/28/2009): Moved from Cxx_Grammar.h to simplify splitting large files generated by ROSETTA.
260 #include "AstAttributeMechanism.h"
261 
262 // DQ (12/29/2009): This permits the optional use of smaller generated header files for the IR.
263 // Without this option the generated header file for the ROSE IR is nearly 300K in size, and
264 // this can be a problem for some compilers (MSVC). This is part of work to optionally reduce
265 // the sizes of some of the larger ROSETTA generated files in ROSE. Later this will be controled
266 // using a configure command line option to ROSE (at configure time).
267 // #define ROSE_USING_SMALL_GENERATED_HEADER_FILES 1
268 
269 // This is an Autoconf conditional macro (so it should not be defined).
270 #ifdef ROSE_USE_SMALLER_GENERATED_FILES
271 // #warning "ROSE_USE_SMALLER_GENERATED_FILES is defined"
272  #define ROSE_USING_SMALL_GENERATED_HEADER_FILES 1
273 #endif
274 
275 // DQ (3/7/2013): I think that we need to use "" instead of <> and this may make a difference for SWIG.
276 // DQ (9/21/2005): This is the simplest way to include this here
277 // This is the definition of the Sage III IR classes (generated header).
278 // #include <Cxx_Grammar.h>
279 #include "Cxx_Grammar.h"
280 
281 // Disable CC++ extensions (we want to support only the C++ Standard)
282 #undef CCPP_EXTENSIONS_ALLOWED
283 
284 // This should be a simple include (without dependence upon ROSE_META_PROGRAM
285 #include "utility_functions.h"
286 
287 // DQ (3/6/2013): Adding support to restrict visability to SWIG.
288 // #ifndef ROSE_USE_SWIG_SUPPORT
289 
290 // Markus Schordan: temporary fixes for Ast flaws (modified by DQ)
291 #include <typeinfo>
292 
293 // DQ (12/9/2004): The name of this file has been changed to be the new location
294 // of many future Sage III AST manipulation functions in the future. A namespace
295 // (SageInterface) is defined in sageInterface.h.
296 #include "sageInterface.h"
297 
298 
299 // DQ (3/29/2006): Moved Rich's support for better name mangling to a
300 // separate file (out of the code generation via ROSETTA).
301 #include "manglingSupport.h"
302 
303 // Markus Kowarschik: we use the new mechanism of handling preprocessing info;
304 // i.e., we output the preprocessing info attached to the AST nodes.
305 // See the detailed explanation of the mechanisms in the beginning of file
306 // attachPreprocessingInfo.C
307 #define USE_OLD_MECHANISM_OF_HANDLING_PREPROCESSING_INFO 0
308 
309 // DQ (9/1/2006): It is currently an error to normalize the source file names stored
310 // in the SgProject IR node to be absolute paths if they didn't originally appear
311 // that way on the commandline. We have partial support for this but it is a bug
312 // at the moment to use this. However, we do now (work by Andreas) normalize the
313 // source file name when input to EDG so that all Sg_File_Info objects store an
314 // absolute path (unless modified using a #line directive, see test2004_60.C as an
315 // example). The current work is an incremental solution.
316 #define USE_ABSOLUTE_PATHS_IN_SOURCE_FILE_LIST 0
317 
318 #include "RoseBin_support.h"
319 // DQ (7/6/2005): Added to support performance analysis of ROSE.
320 // This is located in ROSE/src/midend/astDiagnostics
321 #include "AstPerformance.h"
322 
323 
324 // DQ (4/10/2010): Moved Dwarf and Intel Pin headers to here from rose.h.
325 // DQ (11/7/2008): Added Dwarf support to ROSE AST (applies only to binary executables generated with dwarf debugging information).
326 #ifndef _MSC_VER
327 // tps (11/23/2009) : Commented out right now to make progress in Windows
328  #if USE_ROSE_DWARF_SUPPORT
329  #include "dwarfSupport.h"
330  #endif
331 
332 // DQ (3/8/2009): Added support for Intel Pin (Dynamic binary Instrumentation)
333 // tps (11/23/2009) : Commented out right now to make progress in Windows
334  #ifdef USE_ROSE_INTEL_PIN_SUPPORT
335 // Note that pin.H (in it's header files) will define "TRUE" and "FALSE" as macros.
336  #include "IntelPinSupport.h"
337  #endif
338 #endif
339 
340 #ifdef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
341  #include "transformationSupport.h"
342 #endif
343 
344 // endif for ifndef ROSE_USE_SWIG_SUPPORT
345 // #endif
346 
347 #endif
348 
349