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 | c4327996caeda7f8bd3ae0ca8209261de53d5c64 (patch) | |
tree | 7bf5a673831fe07c2eb2e61d8f599189e778fa80 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | dc265edb3b48379a769420775ff47d7ee1828775 (diff) | |
download | bcm5719-llvm-c4327996caeda7f8bd3ae0ca8209261de53d5c64.tar.gz bcm5719-llvm-c4327996caeda7f8bd3ae0ca8209261de53d5c64.zip |
Switched code from using hasAttr followed by getAttr to simply call getAttr directly and check the resulting value.
No functional changes intended.
llvm-svn: 197652
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 46e2edd9169..cebd6a7df1d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/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)); } |