aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCELFStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-06-27 22:37:36 -0700
committerFangrui Song <i@maskray.me>2024-06-27 22:37:37 -0700
commitdb48f1a1764023f8efeb055e343b967d1eb37d19 (patch)
tree39f6a4fdb655fa3a42cb1f6e6553d3d71434d92c /llvm/lib/MC/MCELFStreamer.cpp
parent52216349b6faf41351f4bd370439031c416b8f9b (diff)
downloadllvm-db48f1a1764023f8efeb055e343b967d1eb37d19.zip
llvm-db48f1a1764023f8efeb055e343b967d1eb37d19.tar.gz
llvm-db48f1a1764023f8efeb055e343b967d1eb37d19.tar.bz2
[MC] Remove nullable getCurrentSectionOnly use from AsmParser
We will implement getCurrentSectionOnly with `CurFrag->getParent()`, which is non-null. Eliminate a nullable use.
Diffstat (limited to 'llvm/lib/MC/MCELFStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCELFStreamer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index b88a572..6d30f2e 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -107,13 +107,14 @@ static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
}
void MCELFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
- MCSection *CurSection = getCurrentSectionOnly();
- if (CurSection && isBundleLocked())
- report_fatal_error("Unterminated .bundle_lock when changing a section");
-
MCAssembler &Asm = getAssembler();
- // Ensure the previous section gets aligned if necessary.
- setSectionAlignmentForBundling(Asm, CurSection);
+ if (auto *F = getCurrentFragment()) {
+ if (isBundleLocked())
+ report_fatal_error("Unterminated .bundle_lock when changing a section");
+
+ // Ensure the previous section gets aligned if necessary.
+ setSectionAlignmentForBundling(Asm, F->getParent());
+ }
auto *SectionELF = static_cast<const MCSectionELF *>(Section);
const MCSymbol *Grp = SectionELF->getGroup();
if (Grp)