diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2013-12-19 03:09:10 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2013-12-19 03:09:10 +0000 |
| commit | e5e1f3542355ee4fe00de867ddea7d15f872bb1d (patch) | |
| tree | 6556c6b43eb7061cbbd70a8bcee98aa4fce417d3 /lib/CodeGen/CodeGenFunction.cpp | |
| parent | 73b8843fa2827a9b3c0dd1995272e72b3b97a146 (diff) | |
| download | clang-e5e1f3542355ee4fe00de867ddea7d15f872bb1d.tar.gz clang-e5e1f3542355ee4fe00de867ddea7d15f872bb1d.tar.bz2 clang-e5e1f3542355ee4fe00de867ddea7d15f872bb1d.tar.xz | |
Switched code from using hasAttr followed by getAttr to simply call getAttr directly and check the resulting value.
No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197652 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 46e2edd916..cebd6a7df1 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -404,8 +404,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, // Get image access qualifier: if (ty->isImageType()) { - if (parm->hasAttr<OpenCLImageAccessAttr>() && - parm->getAttr<OpenCLImageAccessAttr>()->getAccess() == CLIA_write_only) + const OpenCLImageAccessAttr *A = parm->getAttr<OpenCLImageAccessAttr>(); + if (A && A->getAccess() == CLIA_write_only) accessQuals.push_back(llvm::MDString::get(Context, "write_only")); else accessQuals.push_back(llvm::MDString::get(Context, "read_only")); @@ -438,16 +438,15 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD, GenOpenCLArgMetadata(FD, Fn, CGM, Context, kernelMDArgs, Builder, getContext()); - if (FD->hasAttr<VecTypeHintAttr>()) { - VecTypeHintAttr *attr = FD->getAttr<VecTypeHintAttr>(); - QualType hintQTy = attr->getTypeHint(); + if (const VecTypeHintAttr *A = FD->getAttr<VecTypeHintAttr>()) { + QualType hintQTy = A->getTypeHint(); const ExtVectorType *hintEltQTy = hintQTy->getAs<ExtVectorType>(); bool isSignedInteger = hintQTy->isSignedIntegerType() || (hintEltQTy && hintEltQTy->getElementType()->isSignedIntegerType()); llvm::Value *attrMDArgs[] = { llvm::MDString::get(Context, "vec_type_hint"), - llvm::UndefValue::get(CGM.getTypes().ConvertType(attr->getTypeHint())), + llvm::UndefValue::get(CGM.getTypes().ConvertType(A->getTypeHint())), llvm::ConstantInt::get( llvm::IntegerType::get(Context, 32), llvm::APInt(32, (uint64_t)(isSignedInteger ? 1 : 0))) @@ -455,24 +454,22 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD, kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs)); } - if (FD->hasAttr<WorkGroupSizeHintAttr>()) { - WorkGroupSizeHintAttr *attr = FD->getAttr<WorkGroupSizeHintAttr>(); + if (const WorkGroupSizeHintAttr *A = FD->getAttr<WorkGroupSizeHintAttr>()) { llvm::Value *attrMDArgs[] = { llvm::MDString::get(Context, "work_group_size_hint"), - Builder.getInt32(attr->getXDim()), - Builder.getInt32(attr->getYDim()), - Builder.getInt32(attr->getZDim()) + Builder.getInt32(A->getXDim()), + Builder.getInt32(A->getYDim()), + Builder.getInt32(A->getZDim()) }; kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs)); } - if (FD->hasAttr<ReqdWorkGroupSizeAttr>()) { - ReqdWorkGroupSizeAttr *attr = FD->getAttr<ReqdWorkGroupSizeAttr>(); + if (const ReqdWorkGroupSizeAttr *A = FD->getAttr<ReqdWorkGroupSizeAttr>()) { llvm::Value *attrMDArgs[] = { llvm::MDString::get(Context, "reqd_work_group_size"), - Builder.getInt32(attr->getXDim()), - Builder.getInt32(attr->getYDim()), - Builder.getInt32(attr->getZDim()) + Builder.getInt32(A->getXDim()), + Builder.getInt32(A->getYDim()), + Builder.getInt32(A->getZDim()) }; kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs)); } |
