[llvm] r284202 - Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to help
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 22:47:37 PDT 2016
Author: echristo
Date: Fri Oct 14 00:47:37 2016
New Revision: 284202
URL: http://llvm.org/viewvc/llvm-project?rev=284202&view=rev
Log:
Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to help
readability a bit.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/MC/ConstantPools.cpp
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCDwarf.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Oct 14 00:47:37 2016
@@ -157,7 +157,7 @@ void AsmPrinter::EmitToStreamer(MCStream
/// getCurrentSection() - Return the current section we are emitting to.
const MCSection *AsmPrinter::getCurrentSection() const {
- return OutStreamer->getCurrentSection().first;
+ return OutStreamer->getCurrentSectionOnly();
}
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
Modified: llvm/trunk/lib/MC/ConstantPools.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ConstantPools.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ConstantPools.cpp (original)
+++ llvm/trunk/lib/MC/ConstantPools.cpp Fri Oct 14 00:47:37 2016
@@ -79,7 +79,7 @@ void AssemblerConstantPools::emitAll(MCS
}
void AssemblerConstantPools::emitForCurrentSection(MCStreamer &Streamer) {
- MCSection *Section = Streamer.getCurrentSection().first;
+ MCSection *Section = Streamer.getCurrentSectionOnly();
if (ConstantPool *CP = getConstantPool(Section)) {
emitConstantPool(Streamer, Section, *CP);
}
@@ -88,7 +88,7 @@ void AssemblerConstantPools::emitForCurr
const MCExpr *AssemblerConstantPools::addEntry(MCStreamer &Streamer,
const MCExpr *Expr,
unsigned Size, SMLoc Loc) {
- MCSection *Section = Streamer.getCurrentSection().first;
+ MCSection *Section = Streamer.getCurrentSectionOnly();
return getOrCreateConstantPool(Section).addEntry(Expr, Streamer.getContext(),
Size, Loc);
}
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Oct 14 00:47:37 2016
@@ -749,7 +749,7 @@ static void PrintQuotedString(StringRef
}
void MCAsmStreamer::EmitBytes(StringRef Data) {
- assert(getCurrentSection().first &&
+ assert(getCurrentSectionOnly() &&
"Cannot emit contents before setting section!");
if (Data.empty()) return;
@@ -794,7 +794,7 @@ void MCAsmStreamer::EmitIntValue(uint64_
void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc) {
assert(Size <= 8 && "Invalid size");
- assert(getCurrentSection().first &&
+ assert(getCurrentSectionOnly() &&
"Cannot emit contents before setting section!");
const char *Directive = nullptr;
switch (Size) {
@@ -1580,8 +1580,9 @@ void MCAsmStreamer::AddEncodingComment(c
}
}
-void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) {
- assert(getCurrentSection().first &&
+void MCAsmStreamer::EmitInstruction(const MCInst &Inst,
+ const MCSubtargetInfo &STI) {
+ assert(getCurrentSectionOnly() &&
"Cannot emit contents before setting section!");
// Show the encoding in a comment if we have a code emitter.
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Fri Oct 14 00:47:37 2016
@@ -917,7 +917,7 @@ void MCGenDwarfLabelEntry::Make(MCSymbol
MCContext &context = MCOS->getContext();
// We won't create dwarf labels for symbols in sections that we are not
// generating debug info for.
- if (!context.getGenDwarfSectionSyms().count(MCOS->getCurrentSection().first))
+ if (!context.getGenDwarfSectionSyms().count(MCOS->getCurrentSectionOnly()))
return;
// The dwarf label's name does not have the symbol name's leading
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Fri Oct 14 00:47:37 2016
@@ -128,7 +128,7 @@ void MCObjectStreamer::EmitValueImpl(con
flushPendingLabels(DF, DF->getContents().size());
MCCVLineEntry::Make(this);
- MCDwarfLineEntry::Make(this, getCurrentSection().first);
+ MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
// Avoid fixups when possible.
int64_t AbsValue;
@@ -236,7 +236,7 @@ void MCObjectStreamer::EmitInstruction(c
// Now that a machine instruction has been assembled into this section, make
// a line entry for any .loc directive that has been seen.
MCCVLineEntry::Make(this);
- MCDwarfLineEntry::Make(this, getCurrentSection().first);
+ MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
// If this instruction doesn't need relaxation, just emit it as data.
MCAssembler &Assembler = getAssembler();
@@ -305,7 +305,7 @@ void MCObjectStreamer::EmitDwarfLocDirec
StringRef FileName) {
// In case we see two .loc directives in a row, make sure the
// first one gets a line entry.
- MCDwarfLineEntry::Make(this, getCurrentSection().first);
+ MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
Isa, Discriminator, FileName);
@@ -413,7 +413,7 @@ void MCObjectStreamer::EmitCVFileChecksu
void MCObjectStreamer::EmitBytes(StringRef Data) {
MCCVLineEntry::Make(this);
- MCDwarfLineEntry::Make(this, getCurrentSection().first);
+ MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
MCDataFragment *DF = getOrCreateDataFragment();
flushPendingLabels(DF, DF->getContents().size());
DF->getContents().append(Data.begin(), Data.end());
@@ -428,7 +428,7 @@ void MCObjectStreamer::EmitValueToAlignm
insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
// Update the maximum alignment on the current section if necessary.
- MCSection *CurSec = getCurrentSection().first;
+ MCSection *CurSec = getCurrentSectionOnly();
if (ByteAlignment > CurSec->getAlignment())
CurSec->setAlignment(ByteAlignment);
}
@@ -530,9 +530,7 @@ bool MCObjectStreamer::EmitRelocDirectiv
}
void MCObjectStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
- const MCSection *Sec = getCurrentSection().first;
- (void)Sec;
- assert(Sec && "need a section");
+ assert(getCurrentSectionOnly() && "need a section");
insert(new MCFillFragment(FillValue, NumBytes));
}
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Oct 14 00:47:37 2016
@@ -733,7 +733,7 @@ bool AsmParser::Run(bool NoInitialTextSe
// If we are generating dwarf for assembly source files save the initial text
// section and generate a .file directive.
if (getContext().getGenDwarfForAssembly()) {
- MCSection *Sec = getStreamer().getCurrentSection().first;
+ MCSection *Sec = getStreamer().getCurrentSectionOnly();
if (!Sec->getBeginSymbol()) {
MCSymbol *SectionStartSym = getContext().createTempSymbol();
getStreamer().EmitLabel(SectionStartSym);
@@ -829,7 +829,7 @@ bool AsmParser::Run(bool NoInitialTextSe
}
bool AsmParser::checkForValidSection() {
- if (!ParsingInlineAsm && !getStreamer().getCurrentSection().first) {
+ if (!ParsingInlineAsm && !getStreamer().getCurrentSectionOnly()) {
Out.InitSections(false);
return Error(getTok().getLoc(),
"expected section directive before assembly directive");
@@ -2014,7 +2014,7 @@ bool AsmParser::parseStatement(ParseStat
// directive for the instruction.
if (!ParseHadError && getContext().getGenDwarfForAssembly() &&
getContext().getGenDwarfSectionSyms().count(
- getStreamer().getCurrentSection().first)) {
+ getStreamer().getCurrentSectionOnly())) {
unsigned Line;
if (ActiveMacros.empty())
Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
@@ -3109,7 +3109,7 @@ bool AsmParser::parseDirectiveAlign(bool
// Check whether we should use optimal code alignment for this .align
// directive.
- const MCSection *Section = getStreamer().getCurrentSection().first;
+ const MCSection *Section = getStreamer().getCurrentSectionOnly();
assert(Section && "must have section to emit alignment");
bool UseCodeAlign = Section->UseCodeAlign();
if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) &&
Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Fri Oct 14 00:47:37 2016
@@ -525,8 +525,8 @@ bool COFFAsmParser::ParseDirectiveLinkOn
if (parseCOMDATType(Type))
return true;
- const MCSectionCOFF *Current = static_cast<const MCSectionCOFF*>(
- getStreamer().getCurrentSection().first);
+ const MCSectionCOFF *Current =
+ static_cast<const MCSectionCOFF *>(getStreamer().getCurrentSectionOnly());
if (Type == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE)
return Error(Loc, "cannot make section associative with .linkonce");
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Fri Oct 14 00:47:37 2016
@@ -468,8 +468,8 @@ bool DarwinAsmParser::parseDirectiveDesc
/// parseDirectiveIndirectSymbol
/// ::= .indirect_symbol identifier
bool DarwinAsmParser::parseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
- const MCSectionMachO *Current = static_cast<const MCSectionMachO*>(
- getStreamer().getCurrentSection().first);
+ const MCSectionMachO *Current = static_cast<const MCSectionMachO *>(
+ getStreamer().getCurrentSectionOnly());
MachO::SectionType SectionType = Current->getType();
if (SectionType != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
SectionType != MachO::S_LAZY_SYMBOL_POINTERS &&
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Fri Oct 14 00:47:37 2016
@@ -292,7 +292,7 @@ void MCStreamer::AssignFragment(MCSymbol
void MCStreamer::EmitLabel(MCSymbol *Symbol) {
assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
- assert(getCurrentSection().first && "Cannot emit before setting section!");
+ assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Oct 14 00:47:37 2016
@@ -10106,7 +10106,7 @@ bool ARMAsmParser::parseDirectiveLtorg(S
}
bool ARMAsmParser::parseDirectiveEven(SMLoc L) {
- const MCSection *Section = getStreamer().getCurrentSection().first;
+ const MCSection *Section = getStreamer().getCurrentSectionOnly();
if (getLexer().isNot(AsmToken::EndOfStatement)) {
TokError("unexpected token in directive");
@@ -10115,7 +10115,7 @@ bool ARMAsmParser::parseDirectiveEven(SM
if (!Section) {
getStreamer().InitSections(false);
- Section = getStreamer().getCurrentSection().first;
+ Section = getStreamer().getCurrentSectionOnly();
}
assert(Section && "must have section to emit alignment");
@@ -10369,7 +10369,7 @@ bool ARMAsmParser::parseDirectiveAlign(S
return true;
// '.align' is target specifically handled to mean 2**2 byte alignment.
- const MCSection *Section = getStreamer().getCurrentSection().first;
+ const MCSection *Section = getStreamer().getCurrentSectionOnly();
assert(Section && "must have section to emit alignment");
if (Section->UseCodeAlign())
getStreamer().EmitCodeAlignment(4, 0);
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=284202&r1=284201&r2=284202&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Oct 14 00:47:37 2016
@@ -2972,14 +2972,14 @@ bool X86AsmParser::ParseDirective(AsmTok
/// parseDirectiveEven
/// ::= .even
bool X86AsmParser::parseDirectiveEven(SMLoc L) {
- const MCSection *Section = getStreamer().getCurrentSection().first;
if (getLexer().isNot(AsmToken::EndOfStatement)) {
TokError("unexpected token in directive");
return false;
}
+ const MCSection *Section = getStreamer().getCurrentSectionOnly();
if (!Section) {
getStreamer().InitSections(false);
- Section = getStreamer().getCurrentSection().first;
+ Section = getStreamer().getCurrentSectionOnly();
}
if (Section->UseCodeAlign())
getStreamer().EmitCodeAlignment(2, 0);
More information about the llvm-commits
mailing list