diff options
| author | Duncan Sands <baldrick@free.fr> | 2008-04-08 07:23:58 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2008-04-08 07:23:58 +0000 |
| commit | 57d3a363860f1212d37f6df0111c4fc8310d2cc1 (patch) | |
| tree | 05399bcc412d97a94b34cfd43d280ce48e8ee1a9 | |
| parent | 4fdfbf7b89d31bf0edc3a6739f1ac10fa00d0129 (diff) | |
| download | bcm5719-llvm-57d3a363860f1212d37f6df0111c4fc8310d2cc1.tar.gz bcm5719-llvm-57d3a363860f1212d37f6df0111c4fc8310d2cc1.zip | |
Convenience method for setting the nounwind
attribute for a function.
llvm-svn: 49373
| -rw-r--r-- | llvm/include/llvm/Function.h | 1 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Function.cpp | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/llvm/Function.h b/llvm/include/llvm/Function.h index ae51fe2f00b..28c301fe2f6 100644 --- a/llvm/include/llvm/Function.h +++ b/llvm/include/llvm/Function.h @@ -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 { diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 6571f10be5d..de011c07bf6 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -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 |

