Clarify some code based on static analysis complaints; NFC (#145679)
In one case, we have a null pointer check that's unnecessary because the only caller of the function already asserts the value is non-null. In the other case, we've got an anti-pattern of `is` followed by `get`. The logic was easier to repair by changing `get` to `cast`. Neither case is a functional change. Fixes #145525
This commit is contained in:
@@ -586,12 +586,12 @@ static void initializeBuffer(CodeGenModule &CGM, llvm::GlobalVariable *GV,
|
||||
void CGHLSLRuntime::initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
|
||||
llvm::GlobalVariable *GV,
|
||||
HLSLResourceBindingAttr *RBA) {
|
||||
assert(RBA && "expect a nonnull binding attribute");
|
||||
llvm::Type *Int1Ty = llvm::Type::getInt1Ty(CGM.getLLVMContext());
|
||||
auto *NonUniform = llvm::ConstantInt::get(Int1Ty, false);
|
||||
auto *Index = llvm::ConstantInt::get(CGM.IntTy, 0);
|
||||
auto *RangeSize = llvm::ConstantInt::get(CGM.IntTy, 1);
|
||||
auto *Space =
|
||||
llvm::ConstantInt::get(CGM.IntTy, RBA ? RBA->getSpaceNumber() : 0);
|
||||
auto *Space = llvm::ConstantInt::get(CGM.IntTy, RBA->getSpaceNumber());
|
||||
Value *Name = nullptr;
|
||||
|
||||
llvm::Intrinsic::ID IntrinsicID =
|
||||
|
||||
@@ -2418,7 +2418,7 @@ static bool CheckFloatOrHalfRepresentation(Sema *S, SourceLocation Loc,
|
||||
clang::QualType PassedType) {
|
||||
clang::QualType BaseType =
|
||||
PassedType->isVectorType()
|
||||
? PassedType->getAs<clang::VectorType>()->getElementType()
|
||||
? PassedType->castAs<clang::VectorType>()->getElementType()
|
||||
: PassedType;
|
||||
if (!BaseType->isHalfType() && !BaseType->isFloat32Type())
|
||||
return S->Diag(Loc, diag::err_builtin_invalid_arg_type)
|
||||
|
||||
Reference in New Issue
Block a user