1 #ifndef ROSE_RTIHELPERS_H
2 #define ROSE_RTIHELPERS_H
10 #include <boost/lexical_cast.hpp>
11 #include <Sawyer/BitVector.h>
17 #include <valgrind/valgrind.h>
18 #include <valgrind/memcheck.h>
20 static void doUninitializedFieldCheck(
const char* fieldName,
void* fieldPointer,
size_t fieldSize,
void* wholeObject,
const char* className) {
21 if (VALGRIND_CHECK_READABLE(fieldPointer, fieldSize)) {
22 fprintf(stderr,
"Warning: uninitialized field p_%s of object %p of class %s\n", fieldName, wholeObject, className);
28 static std::string toStringForRTI(
const T& x) {
29 std::ostringstream ss;
35 return "0x" + x.
toHex();
39 static std::string toStringForRTI(
const std::vector<T>& x) {
40 std::ostringstream ss;
42 for (
typename std::vector<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
49 static std::string toStringForRTI(
const std::vector<std::pair<T,T> >& x) {
50 std::ostringstream ss;
52 for (
typename std::vector<std::pair<T,T> >::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
58 template <
typename F,
typename S>
59 static std::string toStringForRTI(
const std::vector<std::pair<F,S> >& x) {
60 std::ostringstream ss;
62 for (
typename std::vector<std::pair<F,S> >::const_iterator i = x.begin(); i != x.end(); ++i)
63 {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
69 static std::string toStringForRTI(
const ExtentMap &x)
71 std::ostringstream ss;
73 for (ExtentMap::const_iterator i=x.
begin(); i!=x.
end(); ++i) {
76 ss << i->first <<
"->" << i->second;
82 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
87 std::ostringstream ss;
90 printf (
"Warning: SgSharedVector iterator support is not finished! \n");
100 static std::string toStringForRTI(
const std::vector<bool>& x) {
101 std::ostringstream ss;
103 for (std::vector<bool>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i ?
"T" :
"F");}
108 template <
typename T>
109 static std::string toStringForRTI(
const std::list<T>& x) {
110 std::ostringstream ss;
112 for (
typename std::list<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
117 template <
typename T>
118 static std::string toStringForRTI(
const std::set<T>& x) {
119 std::ostringstream ss;
121 for (
typename std::set<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
126 template <
typename K,
typename V>
127 static std::string toStringForRTI(
const std::map<K, V>& x) {
128 std::ostringstream ss;
130 for (
typename std::map<K, V>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << toStringForRTI(i->second);}
136 template <
typename K>
137 static std::string toStringForRTI(
const std::map<K, std::set<PreprocessingInfo*> >& x) {
138 std::ostringstream ss;
140 for (
typename std::map<K, std::set<PreprocessingInfo*> >::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << toStringForRTI(i->second);}
146 template <
typename K,
typename V>
147 static std::string toStringForRTI(
const std::multimap<K, V>& x) {
148 std::ostringstream ss;
150 for (
typename std::multimap<K, V>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
156 static std::string toStringForRTI(
const std::map<std::pair<
int,std::pair<int,int> >, uint64_t > & x) {
157 std::ostringstream ss;
166 static std::string toStringForRTI(
const std::map<uint64_t ,std::pair<
int,std::pair<int,int> > > & x) {
167 std::ostringstream ss;
180 #ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
184 std::ostringstream ss;
194 std::ostringstream ss;
203 std::ostringstream ss;
212 std::ostringstream ss;
221 std::ostringstream ss;
230 std::ostringstream ss;
239 static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
241 std::ostringstream ss;
251 static std::string toStringForRTI(
const rose_directed_graph_hash_multimap & x)
253 std::ostringstream ss;
261 #ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
266 std::ostringstream ss;
278 static std::string toStringForRTI(
const std::map<int, SgGraphNode*> & x)
280 std::ostringstream ss;
283 for (std::map<int, SgGraphNode*>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
293 static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
295 std::ostringstream ss;
307 return m.displayString();
311 return m.displayString();
315 return m.displayString();
319 return m.displayString();
323 return m.displayString();
327 return m.displayString();
331 return m.displayString();
335 return m.displayString();
339 return m.displayString();
342 static std::string toStringForRTI(
const SgName& n) {
343 return n.getString();
347 std::ostringstream os;
348 os <<
" ( " << x.x <<
", " << x.y <<
", " << x.z <<
" ) ";
355 template <
typename Sym>
356 static std::string toStringForRTISymbol(Sym* sym) {
357 std::ostringstream ss;
360 ss <<
": varsym " << sym->get_name().str() <<
" declared at 0x" << std::hex << (sym->get_declaration());
365 static std::string toStringForRTI(
SgVariableSymbol* sym) {
return toStringForRTISymbol(sym);}
366 static std::string toStringForRTI(
SgFunctionSymbol* sym) {
return toStringForRTISymbol(sym);}
369 static std::string toStringForRTI(
const SgSymbolTable&) {
return "<no output operator defined for this type>";}
370 static std::string toStringForRTI(
const SgSymbolHashBase::iterator&) {
return "<no output operator defined for this type>";}
373 void doRTI(
const char* fieldNameBase,
void* fieldPtr,
size_t fieldSize,
void* thisPtr,
const char* className,
const char* typeString,
const char* fieldName,
const std::string& fieldContents,
RTIMemberData& memberData);
375 #endif // ROSE_RTIHELPERS_H
This class represents modifiers for SgDeclaration (declaration statements).
This class represents strings within the IR nodes.
This class represents the concept of a variable name within the compiler (a shared container for the ...
Access to C++ Run Time Information (RTI)
iterator begin()
First-item iterator.
iterator end()
End-item iterator.
This class represents modifiers specific to storage.
This class represents the symbol tables used in both SgScopeStatement and the SgFunctionTypeSymbolTab...
std::string toHex(const BitRange &range) const
Convert to a hexadecimal string.