Convenience method for setting the nounwind

attribute for a function.

llvm-svn: 49373
This commit is contained in:
Duncan Sands 2008-04-08 07:23:58 +00:00
parent 7498965b5a
commit f86399a00f
2 changed files with 10 additions and 0 deletions

View File

@ -178,6 +178,7 @@ public:
/// @brief Determine if the function cannot return.
bool doesNotReturn() const { return paramHasAttr(0, ParamAttr::NoReturn); }
void setDoesNotThrow(bool doesNotThrow = true);
/// @brief Determine if the function cannot unwind.
bool doesNotThrow() const {

View File

@ -219,6 +219,15 @@ void Function::dropAllReferences() {
BasicBlocks.clear(); // Delete all basic blocks...
}
void Function::setDoesNotThrow(bool doesNotThrow) {
PAListPtr PAL = getParamAttrs();
if (doesNotThrow)
PAL = PAL.addAttr(0, ParamAttr::NoUnwind);
else
PAL = PAL.removeAttr(0, ParamAttr::NoUnwind);
setParamAttrs(PAL);
}
// Maintain the collector name for each function in an on-the-side table. This
// saves allocating an additional word in Function for programs which do not use
// GC (i.e., most programs) at the cost of increased overhead for clients which