Skip to content

Commit

Permalink
[NFC] Avoid potential nullptr deref by using castAs<> (#123395)
Browse files Browse the repository at this point in the history
Use castAs<> instead of getAs<>
  • Loading branch information
schittir authored Jan 22, 2025
1 parent 07d03c8 commit 65df99c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VectorType>();
auto *VecTy0 = E->getArg(0)->getType()->castAs<VectorType>();
[[maybe_unused]] auto *VecTy1 =
E->getArg(1)->getType()->getAs<VectorType>();
E->getArg(1)->getType()->castAs<VectorType>();

assert(VecTy0->getElementType() == VecTy1->getElementType() &&
"Dot product of vectors need the same element types.");
Expand Down Expand Up @@ -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<VectorType>();
auto *XVecTy = E->getArg(0)->getType()->castAs<VectorType>();
retType = llvm::VectorType::get(
retType, ElementCount::getFixed(XVecTy->getNumElements()));
}
Expand Down Expand Up @@ -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<VectorType>();
auto *XVecTy = Arg0->getType()->castAs<VectorType>();
retType = llvm::VectorType::get(
retType, ElementCount::getFixed(XVecTy->getNumElements()));
}
Expand Down

0 comments on commit 65df99c

Please sign in to comment.