From ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 3 Mar 2008 03:28:21 +0000 Subject: Add a bunch of attributes, patch by Nuno Lopes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47837 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CodeGenFunction.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'CodeGen/CodeGenFunction.cpp') diff --git a/CodeGen/CodeGenFunction.cpp b/CodeGen/CodeGenFunction.cpp index c2a303c755..6701b71f09 100644 --- a/CodeGen/CodeGenFunction.cpp +++ b/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()) + CurFn->setLinkage(llvm::Function::DLLImportLinkage); + else if (FD->getAttr()) + CurFn->setLinkage(llvm::Function::DLLExportLinkage); + else if (FD->getAttr() || FD->isInline()) CurFn->setLinkage(llvm::Function::WeakLinkage); - + else if (FD->getStorageClass() == FunctionDecl::Static) + CurFn->setLinkage(llvm::Function::InternalLinkage); + + if (const VisibilityAttr *attr = FD->getAttr()) + CurFn->setVisibility(attr->getVisibility()); + // FIXME: else handle -fvisibility + + + llvm::ParamAttrsVector ParamAttrsVec; + + if (FD->getAttr()) + ParamAttrsVec.push_back( + llvm::ParamAttrsWithIndex::get(ParamAttrsVec.size(), llvm::ParamAttr::NoUnwind)); + if (FD->getAttr()) + 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 -- cgit v1.2.3-70-g09d2