Convenience method for setting the nounwind
authorDuncan Sands <baldrick@free.fr>
Tue, 8 Apr 2008 07:23:58 +0000 (07:23 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 8 Apr 2008 07:23:58 +0000 (07:23 +0000)
attribute for a function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49373 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
lib/VMCore/Function.cpp

index ae51fe2f00b8288f4f27ccd4a6efb0b0e94b5801..28c301fe2f6f62dfd0cc9268b76abff510fd1673 100644 (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 {
index 6571f10be5dadd053c91050f756091d3d53bc64b..de011c07bf641a2fa8c16051fdb82347bd2090ad 100644 (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