[LLVMdev] question
Bill? Wendling
wendling at isanbard.org
Sat Nov 16 17:08:01 PST 2002
Also sprach Xiaodong Li:
} Thanks Bill. One more question, when I use the DSNode iterator to
} traverse a node's children. The return value of I.getNode() can only
} be 'const DSNode *', I cannot use 'DSNode *' type. So as a result, I
} always get error message like this:
}
} MemLeakage.cpp:159: invalid conversion from `const DSNode*' to `DSNode*'
} MemLeakage.cpp:159: initializing argument 1 of `void
} <unnamed>::GlobalMemLeakage::KillSetInsert(DSNode*, BBsets&)'
}
} How to use a 'Node *' type iterator? Or is there any other way to traverse
} the DSGraph?
}
I don't know too much about the DSGraph module, so I didn't respond to
that part of your question :-).
However, a few things which will help. If you don't need to modify the
DSNode *, then use a const_iterator instead and pass everything to
functions which take const DSNode *.
If you do need to modify it, then you may have to rely upon a
const_cast<>() to remove the const from the object. So, you'll have code
which looks like this I think:
for (DSGraph::iterator B = dsg.begin(), E = dsg.end(); B != E; ++B) {
DSGraph *D = const_cast<DSGraph *>(*B);
// code...
KillSetInsert(D);
// more code...
}
that may work...
--
|| Bill Wendling "A computer without a Microsoft operating
|| wendling at isanbard.org system is like a dog without bricks tied
|| to its head." -- Anonymous
More information about the llvm-dev
mailing list