[clang] [NFC] Remove unneeded nullptr checks after cast<> (PR #74674)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 6 15:08:28 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Mike Rice (mikerice1969)
<details>
<summary>Changes</summary>
Since VD is assigned from a cast<VarDecl> it cannot be a nullptr or it would have asserted. Remove the subsequent checks to clear up any misunderstanding.
---
Full diff: https://github.com/llvm/llvm-project/pull/74674.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2-3)
``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 6a20723bf2bca..b931a81bc0087 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6439,7 +6439,7 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
VD, E->getManglingNumber(), Out);
APValue *Value = nullptr;
- if (E->getStorageDuration() == SD_Static && VD && VD->evaluateValue()) {
+ if (E->getStorageDuration() == SD_Static && VD->evaluateValue()) {
// If the initializer of the extending declaration is a constant
// initializer, we should have a cached constant initializer for this
// temporary. Note that this might have a different value from the value
@@ -6454,8 +6454,7 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
!EvalResult.hasSideEffects())
Value = &EvalResult.Val;
- LangAS AddrSpace =
- VD ? GetGlobalVarAddressSpace(VD) : MaterializedType.getAddressSpace();
+ LangAS AddrSpace = GetGlobalVarAddressSpace(VD);
std::optional<ConstantEmitter> emitter;
llvm::Constant *InitialValue = nullptr;
``````````
</details>
https://github.com/llvm/llvm-project/pull/74674
More information about the cfe-commits
mailing list