fix codegen support for functions that are nothrow and noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47838 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CodeGenFunction.cpp b/CodeGen/CodeGenFunction.cpp
index 6701b71..adbb414 100644
--- a/CodeGen/CodeGenFunction.cpp
+++ b/CodeGen/CodeGenFunction.cpp
@@ -82,18 +82,17 @@
// FIXME: else handle -fvisibility
- llvm::ParamAttrsVector ParamAttrsVec;
-
+ unsigned FuncAttrs = 0;
if (FD->getAttr<NoThrowAttr>())
- ParamAttrsVec.push_back(
- llvm::ParamAttrsWithIndex::get(ParamAttrsVec.size(), llvm::ParamAttr::NoUnwind));
+ FuncAttrs |= llvm::ParamAttr::NoUnwind;
if (FD->getAttr<NoReturnAttr>())
- ParamAttrsVec.push_back(
- llvm::ParamAttrsWithIndex::get(ParamAttrsVec.size(), llvm::ParamAttr::NoReturn));
-
- if (!ParamAttrsVec.empty())
+ FuncAttrs |= llvm::ParamAttr::NoReturn;
+
+ if (FuncAttrs) {
+ llvm::ParamAttrsVector ParamAttrsVec;
+ ParamAttrsVec.push_back(llvm::ParamAttrsWithIndex::get(0, FuncAttrs));
CurFn->setParamAttrs(llvm::ParamAttrsList::get(ParamAttrsVec));
-
+ }
llvm::BasicBlock *EntryBB = new llvm::BasicBlock("entry", CurFn);
diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c
index 59f3e73..73e0601 100644
--- a/test/CodeGen/attributes.c
+++ b/test/CodeGen/attributes.c
@@ -19,3 +19,8 @@
// RUN: clang -emit-llvm < %s | grep 't6.*protected'
int t6 __attribute__((visibility(protected)));
+
+// RUN: clang -emit-llvm < %s | grep 't7.*noreturn'
+// RUN: clang -emit-llvm < %s | grep 't7.*nothrow'
+void t7() __attribute__((noreturn, nothrow));
+void t7() {}