From 65df99c208ed40271f6dcdfc29bed56540467ce7 Mon Sep 17 00:00:00 2001 From: schittir Date: Tue, 21 Jan 2025 21:41:37 -0800 Subject: [PATCH] [NFC] Avoid potential nullptr deref by using castAs<> (#123395) Use castAs<> instead of getAs<> --- clang/lib/CodeGen/CGBuiltin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index c26b81306fb719..054f34e23326f3 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19333,9 +19333,9 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, assert(T0->isVectorTy() && T1->isVectorTy() && "Dot product of vector and scalar is not supported."); - auto *VecTy0 = E->getArg(0)->getType()->getAs(); + auto *VecTy0 = E->getArg(0)->getType()->castAs(); [[maybe_unused]] auto *VecTy1 = - E->getArg(1)->getType()->getAs(); + E->getArg(1)->getType()->castAs(); assert(VecTy0->getElementType() == VecTy1->getElementType() && "Dot product of vectors need the same element types."); @@ -19428,7 +19428,7 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { llvm::Type *Xty = Op0->getType(); llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext()); if (Xty->isVectorTy()) { - auto *XVecTy = E->getArg(0)->getType()->getAs(); + auto *XVecTy = E->getArg(0)->getType()->castAs(); retType = llvm::VectorType::get( retType, ElementCount::getFixed(XVecTy->getNumElements())); } @@ -19614,7 +19614,7 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { llvm::Type *Xty = Op0->getType(); llvm::Type *retType = llvm::Type::getInt32Ty(this->getLLVMContext()); if (Xty->isVectorTy()) { - auto *XVecTy = Arg0->getType()->getAs(); + auto *XVecTy = Arg0->getType()->castAs(); retType = llvm::VectorType::get( retType, ElementCount::getFixed(XVecTy->getNumElements())); }