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;
83 static std::string toStringForRTI(
const std::vector<bool>& x) {
84 std::ostringstream ss;
86 for (std::vector<bool>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i ?
"T" :
"F");}
92 static std::string toStringForRTI(
const std::list<T>& x) {
93 std::ostringstream ss;
95 for (
typename std::list<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
100 template <
typename T>
101 static std::string toStringForRTI(
const std::list<list<T> >& x) {
102 std::ostringstream ss;
104 for (
typename std::list<list<T> >::const_iterator i = x.begin(); i != x.end(); ++i) {
110 template <
typename T>
111 static std::string toStringForRTI(
const std::set<T>& x) {
112 std::ostringstream ss;
114 for (
typename std::set<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
119 template <
typename K,
typename V>
120 static std::string toStringForRTI(
const std::map<K, V>& x) {
121 std::ostringstream ss;
123 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);}
129 template <
typename K>
130 static std::string toStringForRTI(
const std::map<K, std::set<PreprocessingInfo*> >& x) {
131 std::ostringstream ss;
133 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);}
139 template <
typename K,
typename V>
140 static std::string toStringForRTI(
const std::multimap<K, V>& x) {
141 std::ostringstream ss;
143 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;}
149 static std::string toStringForRTI(
const std::map<std::pair<
int,std::pair<int,int> >, uint64_t > & x) {
150 std::ostringstream ss;
159 static std::string toStringForRTI(
const std::map<uint64_t ,std::pair<
int,std::pair<int,int> > > & x) {
160 std::ostringstream ss;
173 #ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
177 std::ostringstream ss;
187 std::ostringstream ss;
196 std::ostringstream ss;
205 std::ostringstream ss;
214 std::ostringstream ss;
223 std::ostringstream ss;
232 static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
234 std::ostringstream ss;
244 static std::string toStringForRTI(
const rose_directed_graph_hash_multimap & x)
246 std::ostringstream ss;
254 #ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
259 std::ostringstream ss;
271 static std::string toStringForRTI(
const std::map<int, SgGraphNode*> & x)
273 std::ostringstream ss;
276 for (std::map<int, SgGraphNode*>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
286 static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
288 std::ostringstream ss;
300 return m.displayString();
304 return m.displayString();
308 return m.displayString();
312 return m.displayString();
316 return m.displayString();
320 return m.displayString();
324 return m.displayString();
328 return m.displayString();
332 return m.displayString();
335 static std::string toStringForRTI(
const SgName& n) {
336 return n.getString();
340 std::ostringstream os;
341 os <<
" ( " << x.x <<
", " << x.y <<
", " << x.z <<
" ) ";
348 template <
typename Sym>
349 static std::string toStringForRTISymbol(Sym* sym) {
350 std::ostringstream ss;
353 ss <<
": varsym " << sym->get_name().str() <<
" declared at 0x" << std::hex << (sym->get_declaration());
358 static std::string toStringForRTI(
SgVariableSymbol* sym) {
return toStringForRTISymbol(sym);}
359 static std::string toStringForRTI(
SgFunctionSymbol* sym) {
return toStringForRTISymbol(sym);}
362 static std::string toStringForRTI(
const SgSymbolTable&) {
return "<no output operator defined for this type>";}
363 static std::string toStringForRTI(
const SgSymbolHashBase::iterator&) {
return "<no output operator defined for this type>";}
366 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);
368 #endif // ROSE_RTIHELPERS_H