ROSE 0.11.145.192
sage3basic.h
1/*
2 * This header (or its precompiled version) includes the forward declarations of all the Sage IR node classes ("Sg*")
3 * from the ROSETTA-generated files (i.e., gives just the class names).
4 *
5 * Every source file (.C) that becomes part of librose should include "sage3basic.h" as the first included file before any C++
6 * token is processed by the compiler, thus allowing a precompiled version of this header to be used. This applies to pretty
7 * much every .C file under the $ROSE/src directory. Such source files should not include "rose.h".
8 *
9 * No librose header file (those under $ROSE/src) should include sage3basic.h, rose_config.h, or rose.h. If a header file
10 * needs something that's declared in sage3basic.h then include sage3basic.h in the .C file first (GCC cannot use the
11 * precompiled version if it is included from inside another header). If a header file needs a configuration macro (like
12 * HAVE_WHATEVER) from rose_config.h, then it should include "rosePublicConfig.h" instead (and use ROSE_HAVE_WHATEVER).
13 */
14
15#ifndef SAGE3_CLASSES_BASIC__H
16#define SAGE3_CLASSES_BASIC__H
17
19//
20// This part of this header contains things that *MUST* be done very early due to designs of non-ROSE header files.
21//
23
24#include <RoseFirst.h>
25
26// The boost::filesystem::path class has no serialization function, and boost::serialization doesn't provide a non-intrusive
27// implementation. Therefore ROSE needs to define one. This code must occur before including any headers that serialize
28// boost::filesystem::path, and specifically before defining AST node types.
29#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
30#include <boost/filesystem.hpp>
31#include <boost/serialization/nvp.hpp>
32namespace boost {
33 namespace serialization {
34 template<class Archive>
35 void serialize(Archive &ar, boost::filesystem::path &path, const unsigned /*version*/) {
36 if (Archive::is_saving::value) {
37 std::string nativePath = path.string();
38 ar & BOOST_SERIALIZATION_NVP(nativePath);
39 } else {
40 std::string nativePath;
41 ar & BOOST_SERIALIZATION_NVP(nativePath);
42 path = nativePath;
43 }
44 }
45 }
46}
47#endif
48
49
50
52//
53// This part of the file contains things that must be done early in nearly every ROSE implementation file for nearly every ROSE
54// configuration. This section should be very small and should not include any headers that are even marginally expensive to
55// parse.
56//
58
59
60
61
63//
64// The rest of this file contains optional things that are not needed by every ROSE implementation file (*.C) or by every ROSE
65// configuration. Do not add more to this -- we're trying to get rid of this section. Instead, move things to other header
66// files (if necessary) and include them into only those source files that depend on them.
67//
69
70#include "Rose/Constants.h" // defines things like Rose::UNLIMITED, Rose::INVALID_INDEX, etc.
71
72// DQ (11/12/2011): This is support to reduce the size of ROSE so that I can manage development on my laptop.
73// This option defines a subset of ROSE as required to support wotk on the new EDG front-end.
74// This is defined here becasuse it is not enough to define it in the rose_config.h
75// because that can't be read early enough to effect what header files are included.
76// #define ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
77
78#include <inttypes.h>
79
80#include <semaphore.h>
81#include "fileoffsetbits.h"
82#include "rosedll.h"
83//tps (05/04/2010): Added compatibility
84#ifdef _MSC_VER
85# if _MSC_VER < 1900
86 #define snprintf _snprintf
87# endif
88#endif
89
90// George Vulov (Aug. 23, 2010): This macro is not available in OS X by default
91#ifndef TEMP_FAILURE_RETRY
92#define TEMP_FAILURE_RETRY(expression) \
93 ({ \
94 long int _result; \
95 do _result = (long int) (expression); \
96 while (_result == -1L && errno == EINTR); \
97 _result; \
98 })
99#endif
100
101// DQ (4/21/2009): Note that this header file will include the STL string header file
102// which will include sys/stat.h, so the _FILE_OFFSET_BITS macro must be already set
103// to avoid an ODR violation when using ROSE on 32-bit systems.
104// DQ (11/10/2007): Added support for ROSE specific paths to be available. These are
105// useful for tools built using ROSE, they are not presently being used within ROSE.
106// RPM (8/22/2008): Commented out because it contains info that prevents us from making
107// optimal use of ccache. "rose_paths.h" contains info that changes every time we
108// configure. Can it be included at a finer granularity than this?
109// DQ (8/25/2008): Turn this back on since it breaks ROSE for everyone else. We
110// are searching for a better solution.
111#include "rose_paths.h"
112
113
114// Part of debuging use of SUN 6.1 compiler
115#if defined(__WIN32__) || defined (__WIN16__)
116#error "WIN macros should not be defined (test in sage3.h)"
117#endif
118
119// Part of debuging use of SUN 6.1 compiler
120#if defined(__MSDOS__) && defined(_Windows)
121#error "MSDOS macros should not be defined"
122#endif
123
124// DQ (4/21/2009): Added test to debug use of _FILE_OFFSET_BITS macro in controling size of "struct stat"
125// #if defined(_FILE_OFFSET_BITS)
126// #warning "The _FILE_OFFSET_BITS macro should not be set yet!"
127// #endif
128
129// DQ (4/21/2009): This macro is set too late!
130// Force 64-bit file offsets in struct stat
131// #define _FILE_OFFSET_BITS 64
132#include <sys/stat.h>
133
134//#include <cstdlib> // For abort()
135#include <algorithm>
136#include <fstream>
137
138// DQ (8/25/2014): Added logic to isTemplateDeclaration(a_routine_ptr) to force isTemplateDeclaration
139// in ROSE/EDG connection to be false where the topScopeStack() is a template class instantaition scope.
140// [Robb Matzke 2024-03-14]: This is only used in once place, and it conditionally compiles a comment.
141#define ENFORCE_NO_FUNCTION_TEMPLATE_DECLARATIONS_IN_TEMPLATE_CLASS_INSTANTIATIONS 0
142
143// DQ (10/12/2004): Remove the resetTemplateName() from use within the EDG/Sage connection
144// because it will (where required) force calls to generate the qualified name which
145// requires the parent pointer to have already been set. Since we defer the
146// setting of the parent pointers until post processing of the Sage III AST.
147// It is now called within the AstFixup.C.
148// [Robb Matzke 2024-03-14]: apparently unused
149#define USE_RESET_TEMPLATE_NAME false
150
151#include <ROSE_DEPRECATED.h>
152
153// DQ (10/6/2004): We have tracked down and noted all locations where a Sage III member function modifies its input parameters.
154// The locations where this happens are marked with a print statement which this macro permits us to turn off when we want to
155// either make an intermediate release of just not see the warning messages. Many side-effects have been removed and some are
156// pending more details discussions internally. I would like to goal to be a simple rule that input parameters to constructors
157// are not modified by the constructor or any function called within the constructor body. A stronger rule would be that the
158// input parameters to any access function which gets and data member of sets a data member would not modified its input
159// parameters. Same idea but applied to all access functions, not just constructors. It is not clear if we need go further.
160// Clearly it might be important to have some function that modify their input parameters but a simple design would disallow it!
161//
162// [Robb Matzke 2024-03-14]: Used only in one place to conditionally compile a printf statement.
163#define PRINT_SIDE_EFFECT_WARNINGS false
164
165#if 1
166#ifdef _MSC_VER
167// DQ (11/4/2009): MS Visual Studio version of hash_multimap
168//#include <cliext/hash_map>
169#else
170// DQ (11/4/2009): Use the GNU depricated stuff (what works in ROSE at the moment)
171// tps (01/25/2010) : deprecated - does not work in setup.h
172// CH (04/28/2010) : We don't need it anymore
173//#include <ext/hash_map>
174#endif
175#endif
176
177// tps (01/22/2010) :refactored
178#include "rosedefs.h"
179// Support for preprocessors declarations and comments
180#include "rose_attributes_list.h"
181
182// Include ROSE common utility function library
183#include <Rose/StringUtility.h>
184#include "FileUtility.h"
185#include "escape.h"
186
187// Include support for Brian Gunney's command line parser tool (nice work)
188#include "sla.h"
189
190// [Robb Matzke 2024-03-14]: apparently unused
191#define SKIP_MANGLED_NAME_CACHING 0
192
193// [Robb Matzke 2024-03-14]: apparently unused
194#define USE_OLD_BINARY_EXECUTABLE_IR_NODES 0
195
196#define USING_OLD_EXECUTABLE_FORMAT_SUPPORT 0
197#if USING_OLD_EXECUTABLE_FORMAT_SUPPORT
198// DQ (12/8/2008): Build a forward declaration for the input parameter type for the
199// SgAsmFileHeader class constructor.
200namespace Exec { namespace ELF { class ElfFileHeader; }; };
201#endif
202
203// DQ (12/28/2009): Moved from Cxx_Grammar.h to simplify splitting large files generated by ROSETTA.
204#include "AstAttributeMechanism.h"
205
206// DQ (3/7/2013): I think that we need to use "" instead of <> and this may make a difference for SWIG.
207// DQ (9/21/2005): This is the simplest way to include this here
208// This is the definition of the Sage III IR classes (generated header).
209// #include <Cxx_Grammar.h>
210#include "Cxx_Grammar.h"
211
212// DQ (10/4/2014): Not clear if this is the best way to control use of ATerm.
213// I think we need a specific macro to be defined for when ATerms are being used.
214// Also I want to initially seperate this from Windows support.
215// Rasmussen (04/17/2019): Support for ATerms has been deprecated.
216#ifndef _MSC_VER
217// #include "atermSupport.h"
218#endif
219
220// Disable CC++ extensions (we want to support only the C++ Standard)
221#undef CCPP_EXTENSIONS_ALLOWED
222
223// This should be a simple include (without dependence upon ROSE_META_PROGRAM
224#include "utility_functions.h"
225
226// DQ (3/6/2013): Adding support to restrict visability to SWIG.
227// #ifndef ROSE_USE_SWIG_SUPPORT
228
229// Markus Schordan: temporary fixes for Ast flaws (modified by DQ)
230#include <typeinfo>
231
232// DQ (12/9/2004): The name of this file has been changed to be the new location
233// of many future Sage III AST manipulation functions in the future. A namespace
234// (SageInterface) is defined in sageInterface.h.
235#include "sageInterface.h"
236
237
238// DQ (3/29/2006): Moved Rich's support for better name mangling to a
239// separate file (out of the code generation via ROSETTA).
240#include "manglingSupport.h"
241
242// DQ (7/6/2005): Added to support performance analysis of ROSE.
243// This is located in ROSE/src/midend/astDiagnostics
244#include "AstPerformance.h"
245
246
247// DQ (4/10/2010): Moved Dwarf and Intel Pin headers to here from rose.h.
248// DQ (11/7/2008): Added Dwarf support to ROSE AST (applies only to binary executables generated with dwarf debugging information).
249#ifndef _MSC_VER
250// DQ (3/8/2009): Added support for Intel Pin (Dynamic binary Instrumentation)
251// tps (11/23/2009) : Commented out right now to make progress in Windows
252 #ifdef USE_ROSE_INTEL_PIN_SUPPORT
253// Note that pin.H (in it's header files) will define "TRUE" and "FALSE" as macros.
254 #include "IntelPinSupport.h"
255 #endif
256#endif
257
258#ifdef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
259 #include "transformationSupport.h"
260#endif
261
262#include <Rose/Initialize.h>
263
264// Liao, 2018/6/25, define the actual version value for OpenMP 4.5
265#define OMPVERSION 201511
266
267#endif
268
269
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.