[clang] 0808be4 - [NFC] Remove unneeded nullptr checks after cast<> (#74674)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 16:20:26 PST 2023
Author: Mike Rice
Date: 2023-12-07T16:20:22-08:00
New Revision: 0808be47b8fbf0307d0b6f2eb45ba9bfe1b3ae65
URL: https://github.com/llvm/llvm-project/commit/0808be47b8fbf0307d0b6f2eb45ba9bfe1b3ae65
DIFF: https://github.com/llvm/llvm-project/commit/0808be47b8fbf0307d0b6f2eb45ba9bfe1b3ae65.diff
LOG: [NFC] Remove unneeded nullptr checks after cast<> (#74674)
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.
Added:
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
Removed:
################################################################################
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
diff erent 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;
More information about the cfe-commits
mailing list