Skip to content

Commit 5e6c085

Browse files
committed
[MCParser] Clean up onEndOfFile
and modernize NumOfMacroInstantiations
1 parent e3e9c5c commit 5e6c085

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class AsmParser : public MCAsmParser {
150150
unsigned MacrosEnabledFlag : 1;
151151

152152
/// Keeps track of how many .macro's have been instantiated.
153-
unsigned NumOfMacroInstantiations;
153+
unsigned NumOfMacroInstantiations = 0;
154154

155155
/// The values from the last parsed cpp hash file line comment if any.
156156
struct CppHashInfoTy {
@@ -821,8 +821,6 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
821821
PlatformParser->Initialize(*this);
822822
initializeDirectiveKindMap();
823823
initializeCVDefRangeTypeMap();
824-
825-
NumOfMacroInstantiations = 0;
826824
}
827825

828826
AsmParser::~AsmParser() {
@@ -1019,8 +1017,6 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
10191017
// All errors should have been emitted.
10201018
assert(!hasPendingError() && "unexpected error from parseStatement");
10211019

1022-
getTargetParser().flushPendingInstructions(getStreamer());
1023-
10241020
if (TheCondState.TheCond != StartingCondState.TheCond ||
10251021
TheCondState.Ignore != StartingCondState.Ignore)
10261022
printError(getTok().getLoc(), "unmatched .ifs or .elses");

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ class ARMAsmParser : public MCTargetAsmParser {
288288

289289
SmallVector<MCInst, 4> PendingConditionalInsts;
290290

291+
void onEndOfFile() override {
292+
flushPendingInstructions(getParser().getStreamer());
293+
}
294+
291295
void flushPendingInstructions(MCStreamer &Out) override {
292296
if (!inImplicitITBlock()) {
293297
assert(PendingConditionalInsts.size() == 0);

0 commit comments

Comments
 (0)