[llvm] Remote redundant null check (PR #100928)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 28 05:12:09 PDT 2024
https://github.com/abhishek-kaushik22 created https://github.com/llvm/llvm-project/pull/100928
`getOrCreateSymbol` should never return a `nullptr`, add an assert and remove the redundant null check in the if condition.
>From 41f08b8ef1ddcb83379c1b816b0f4559eb869341 Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Sun, 28 Jul 2024 17:39:51 +0530
Subject: [PATCH] Remote redundant null check
`getOrCreateSymbol` should never return a `nullptr`, add an assert and remove the redundant null check in the if condition.
---
llvm/lib/MC/MCContext.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 228c4fb03a276..ac3946b6ef46f 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -697,10 +697,11 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
MCSymbol *COMDATSymbol = nullptr;
if (!COMDATSymName.empty()) {
COMDATSymbol = getOrCreateSymbol(COMDATSymName);
+ assert(COMDATSymbol && "COMDATSymbol is null");
COMDATSymName = COMDATSymbol->getName();
// A non-associative COMDAT is considered to define the COMDAT symbol. Check
// the redefinition error.
- if (Selection != COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE && COMDATSymbol &&
+ if (Selection != COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE &&
COMDATSymbol->isDefined() &&
(!COMDATSymbol->isInSection() ||
cast<MCSectionCOFF>(COMDATSymbol->getSection()).getCOMDATSymbol() !=
More information about the llvm-commits
mailing list