Skip to content

Commit 7a80c86

Browse files
[MC] Remove redundant null check, NFCI (#100928)
`getOrCreateSymbol` should never return a `nullptr`, add an assert and remove the redundant null check in the if condition.
1 parent 7c1ddcd commit 7a80c86

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/MC/MCContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,11 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
697697
MCSymbol *COMDATSymbol = nullptr;
698698
if (!COMDATSymName.empty()) {
699699
COMDATSymbol = getOrCreateSymbol(COMDATSymName);
700+
assert(COMDATSymbol && "COMDATSymbol is null");
700701
COMDATSymName = COMDATSymbol->getName();
701702
// A non-associative COMDAT is considered to define the COMDAT symbol. Check
702703
// the redefinition error.
703-
if (Selection != COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE && COMDATSymbol &&
704+
if (Selection != COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE &&
704705
COMDATSymbol->isDefined() &&
705706
(!COMDATSymbol->isInSection() ||
706707
cast<MCSectionCOFF>(COMDATSymbol->getSection()).getCOMDATSymbol() !=

0 commit comments

Comments
 (0)