diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-03 03:28:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-03 03:28:21 +0000 |
commit | 8496639787688225f99ce518d8870caa08ea0ea6 (patch) | |
tree | 1b998a74e22af304ec67dd88462018225f9f5a98 /clang/CodeGen/CodeGenFunction.cpp | |
parent | 184adbfe5b347a77892165d867e294fb81674583 (diff) | |
download | bcm5719-llvm-8496639787688225f99ce518d8870caa08ea0ea6.tar.gz bcm5719-llvm-8496639787688225f99ce518d8870caa08ea0ea6.zip |
Add a bunch of attributes, patch by Nuno Lopes.
llvm-svn: 47837
Diffstat (limited to 'clang/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/CodeGen/CodeGenFunction.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp index c2a303c7557..6701b71f097 100644 --- a/clang/CodeGen/CodeGenFunction.cpp +++ b/clang/CodeGen/CodeGenFunction.cpp @@ -18,6 +18,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +#include "llvm/ParamAttrsList.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Support/CFG.h" using namespace clang; @@ -67,11 +68,33 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { // TODO: Set up linkage and many other things. Note, this is a simple // approximation of what we really want. - if (FD->getStorageClass() == FunctionDecl::Static) - CurFn->setLinkage(llvm::Function::InternalLinkage); - else if (FD->isInline()) + if (FD->getAttr<DLLImportAttr>()) + CurFn->setLinkage(llvm::Function::DLLImportLinkage); + else if (FD->getAttr<DLLExportAttr>()) + CurFn->setLinkage(llvm::Function::DLLExportLinkage); + else if (FD->getAttr<WeakAttr>() || FD->isInline()) CurFn->setLinkage(llvm::Function::WeakLinkage); - + else if (FD->getStorageClass() == FunctionDecl::Static) + CurFn->setLinkage(llvm::Function::InternalLinkage); + + if (const VisibilityAttr *attr = FD->getAttr<VisibilityAttr>()) + CurFn->setVisibility(attr->getVisibility()); + // FIXME: else handle -fvisibility + + + llvm::ParamAttrsVector ParamAttrsVec; + + if (FD->getAttr<NoThrowAttr>()) + ParamAttrsVec.push_back( + llvm::ParamAttrsWithIndex::get(ParamAttrsVec.size(), llvm::ParamAttr::NoUnwind)); + if (FD->getAttr<NoReturnAttr>()) + ParamAttrsVec.push_back( + llvm::ParamAttrsWithIndex::get(ParamAttrsVec.size(), llvm::ParamAttr::NoReturn)); + + if (!ParamAttrsVec.empty()) + CurFn->setParamAttrs(llvm::ParamAttrsList::get(ParamAttrsVec)); + + llvm::BasicBlock *EntryBB = new llvm::BasicBlock("entry", CurFn); // Create a marker to make it easy to insert allocas into the entryblock |