Skip to content

Commit 80e19f0

Browse files
committed
Clarify some code based on static analysis complaints; NFC
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.
1 parent f8ed456 commit 80e19f0

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ void CGHLSLRuntime::initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
589589
auto *NonUniform = llvm::ConstantInt::get(Int1Ty, false);
590590
auto *Index = llvm::ConstantInt::get(CGM.IntTy, 0);
591591
auto *RangeSize = llvm::ConstantInt::get(CGM.IntTy, 1);
592-
auto *Space =
593-
llvm::ConstantInt::get(CGM.IntTy, RBA ? RBA->getSpaceNumber() : 0);
592+
auto *Space = llvm::ConstantInt::get(CGM.IntTy, RBA->getSpaceNumber());
594593
Value *Name = nullptr;
595594

596595
llvm::Intrinsic::ID IntrinsicID =

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ static bool CheckFloatOrHalfRepresentation(Sema *S, SourceLocation Loc,
24182418
clang::QualType PassedType) {
24192419
clang::QualType BaseType =
24202420
PassedType->isVectorType()
2421-
? PassedType->getAs<clang::VectorType>()->getElementType()
2421+
? PassedType->castAs<clang::VectorType>()->getElementType()
24222422
: PassedType;
24232423
if (!BaseType->isHalfType() && !BaseType->isFloat32Type())
24242424
return S->Diag(Loc, diag::err_builtin_invalid_arg_type)

0 commit comments

Comments
 (0)