fix codegen support for functions that are nothrow and noreturn.

llvm-svn: 47838
This commit is contained in:
Chris Lattner 2008-03-03 03:45:26 +00:00
parent 8496639787
commit 65079bd9be
2 changed files with 13 additions and 9 deletions

View File

@ -82,18 +82,17 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
// 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);

View File

@ -19,3 +19,8 @@ int t5 __attribute__((weak)) = 2;
// 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() {}