From db48f1a1764023f8efeb055e343b967d1eb37d19 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 27 Jun 2024 22:37:36 -0700 Subject: [MC] Remove nullable getCurrentSectionOnly use from AsmParser We will implement getCurrentSectionOnly with `CurFrag->getParent()`, which is non-null. Eliminate a nullable use. --- llvm/lib/MC/MCStreamer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'llvm/lib/MC/MCStreamer.cpp') diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index c0879fd..91adc42 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -118,6 +118,12 @@ ArrayRef MCStreamer::getDwarfFrameInfos() const { return DwarfFrameInfos; } +MCFragment *MCStreamer::getCurrentFragment() const { + assert(!getCurrentSection().first || + CurFrag->getParent() == getCurrentSection().first); + return CurFrag; +} + void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {} void MCStreamer::addExplicitComment(const Twine &T) {} @@ -1218,7 +1224,9 @@ void MCStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) {} void MCStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) {} -void MCStreamer::changeSection(MCSection *, uint32_t) {} +void MCStreamer::changeSection(MCSection *Section, uint32_t) { + CurFrag = &Section->getDummyFragment(); +} void MCStreamer::emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} void MCStreamer::emitBytes(StringRef Data) {} void MCStreamer::emitBinaryData(StringRef Data) { emitBytes(Data); } -- cgit v1.1