[llvm] 5e6c085 - [MCParser] Clean up onEndOfFile

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 1 15:58:24 PST 2025


Author: Fangrui Song
Date: 2025-03-01T15:58:19-08:00
New Revision: 5e6c0853fd121fa9179fd5edda9ac8649b70aff6

URL: https://github.com/llvm/llvm-project/commit/5e6c0853fd121fa9179fd5edda9ac8649b70aff6
DIFF: https://github.com/llvm/llvm-project/commit/5e6c0853fd121fa9179fd5edda9ac8649b70aff6.diff

LOG: [MCParser] Clean up onEndOfFile

and modernize NumOfMacroInstantiations

Added: 
    

Modified: 
    llvm/lib/MC/MCParser/AsmParser.cpp
    llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index ffd4611c883ae..c1ca690df95f9 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -150,7 +150,7 @@ class AsmParser : public MCAsmParser {
   unsigned MacrosEnabledFlag : 1;
 
   /// Keeps track of how many .macro's have been instantiated.
-  unsigned NumOfMacroInstantiations;
+  unsigned NumOfMacroInstantiations = 0;
 
   /// The values from the last parsed cpp hash file line comment if any.
   struct CppHashInfoTy {
@@ -821,8 +821,6 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
   PlatformParser->Initialize(*this);
   initializeDirectiveKindMap();
   initializeCVDefRangeTypeMap();
-
-  NumOfMacroInstantiations = 0;
 }
 
 AsmParser::~AsmParser() {
@@ -1019,8 +1017,6 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
   // All errors should have been emitted.
   assert(!hasPendingError() && "unexpected error from parseStatement");
 
-  getTargetParser().flushPendingInstructions(getStreamer());
-
   if (TheCondState.TheCond != StartingCondState.TheCond ||
       TheCondState.Ignore != StartingCondState.Ignore)
     printError(getTok().getLoc(), "unmatched .ifs or .elses");

diff  --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 6cc95b7e1cd2a..7c24dc8b3268f 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -288,6 +288,10 @@ class ARMAsmParser : public MCTargetAsmParser {
 
   SmallVector<MCInst, 4> PendingConditionalInsts;
 
+  void onEndOfFile() override {
+    flushPendingInstructions(getParser().getStreamer());
+  }
+
   void flushPendingInstructions(MCStreamer &Out) override {
     if (!inImplicitITBlock()) {
       assert(PendingConditionalInsts.size() == 0);


        


More information about the llvm-commits mailing list