-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Clarify some code based on static analysis complaints; NFC #145679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-hlsl Author: Aaron Ballman (AaronBallman) ChangesIn 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 Neither case is a functional change. Full diff: https://github.com/llvm/llvm-project/pull/145679.diff 2 Files Affected:
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 3103f1798e14e..85e602481e647 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -589,8 +589,7 @@ void CGHLSLRuntime::initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
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 =
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 506da8a361edf..4d61ced9b0787 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -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)
|
Windows precommit CI failures appear to be unrelated:
|
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 byget
. The logic was easier to repair by changingget
tocast
.Neither case is a functional change.
Fixes #145525