Author: Simon Pilgrim Date: 2020-01-08T17:19:08Z New Revision: 5936717fa6537812257990143e2384bb78486ef9
URL: https://github.com/llvm/llvm-project/commit/5936717fa6537812257990143e2384bb78486ef9 DIFF: https://github.com/llvm/llvm-project/commit/5936717fa6537812257990143e2384bb78486ef9.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use castAs<> instead of getAs<> since we know that the pointer will be valid (and is dereferenced immediately below). Added: Modified: clang/lib/CodeGen/CGOpenCLRuntime.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/clang/lib/CodeGen/CGOpenCLRuntime.cpp index 191a95c62992..dbe375294d17 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -96,7 +96,7 @@ llvm::PointerType *CGOpenCLRuntime::getSamplerType(const Type *T) { } llvm::Value *CGOpenCLRuntime::getPipeElemSize(const Expr *PipeArg) { - const PipeType *PipeTy = PipeArg->getType()->getAs<PipeType>(); + const PipeType *PipeTy = PipeArg->getType()->castAs<PipeType>(); // The type of the last (implicit) argument to be passed. llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); unsigned TypeSize = CGM.getContext() @@ -106,7 +106,7 @@ llvm::Value *CGOpenCLRuntime::getPipeElemSize(const Expr *PipeArg) { } llvm::Value *CGOpenCLRuntime::getPipeElemAlign(const Expr *PipeArg) { - const PipeType *PipeTy = PipeArg->getType()->getAs<PipeType>(); + const PipeType *PipeTy = PipeArg->getType()->castAs<PipeType>(); // The type of the last (implicit) argument to be passed. llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); unsigned TypeSize = CGM.getContext() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits