Skip to content

[MC] Merge MCAsmLexer.{h,cpp} into AsmLexer.{h,cpp} #134207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Apr 3, 2025

2b11c7d introduced llvm/include/llvm/MC/MCAsmLexer.h and made AsmLexer inherit from MCAsmLexer, likely to allow target-specific parsers to depend solely on MCAsmLexer. However, this separation now seems unnecessary and confusing.

MCAsmLexer defines virtual functions with AsmLexer as its only implementation, and AsmLexer itself has few extra public methods.

To simplify the codebase, this change merges MCAsmLexer.{h,cpp} into AsmLexer.{h,cpp}. MCAsmLexer.h is temporarily kept as a forwarder.

Note: I doubt that a downstream lexer handling an assembly syntax significantly different from the standard GNU Assembler syntax would want to inherit from MCAsmLexer. Instead, it's more likely they'd extend AsmLexer by adding new states and modifying its internal logic, as seen with variables for MASM, M68k, and HLASM.

@llvmbot llvmbot added the mc Machine (object) code label Apr 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2025

@llvm/pr-subscribers-mc

Author: Fangrui Song (MaskRay)

Changes

2b11c7d introduced llvm/include/llvm/MC/MCAsmLexer.h and made AsmLexer inherit from MCAsmLexer, likely to allow target-specific parsers to depend solely on MCAsmLexer. However, this separation now seems unnecessary and confusing.

MCAsmLexer defines virtual functions with AsmLexer as its only implementation, and AsmLexer itself has few extra public methods.

To simplify the codebase, this change merges MCAsmLexer.{h,cpp} into AsmLexer.{h,cpp}. MCAsmLexer.h is temporarily kept as a forwarder.

Note: I doubt that a downstream lexer handling an assembly syntax significantly different from the standard GNU Assembler syntax would want to inherit from MCAsmLexer. Instead, it's more likely they'd extend AsmLexer by adding new states and modifying its internal logic, as seen with variables for MASM, M68k, and HLASM.


Patch is 22.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134207.diff

6 Files Affected:

  • (modified) llvm/include/llvm/MC/MCParser/AsmLexer.h (+168-2)
  • (modified) llvm/include/llvm/MC/MCParser/MCAsmLexer.h (+1-184)
  • (modified) llvm/lib/MC/MCParser/AsmLexer.cpp (+86)
  • (modified) llvm/lib/MC/MCParser/CMakeLists.txt (-1)
  • (removed) llvm/lib/MC/MCParser/MCAsmLexer.cpp (-105)
  • (modified) llvm/utils/gn/secondary/llvm/lib/MC/MCParser/BUILD.gn (-1)
diff --git a/llvm/include/llvm/MC/MCParser/AsmLexer.h b/llvm/include/llvm/MC/MCParser/AsmLexer.h
index 735b0c114f2aa..d1599dc47e76b 100644
--- a/llvm/include/llvm/MC/MCParser/AsmLexer.h
+++ b/llvm/include/llvm/MC/MCParser/AsmLexer.h
@@ -13,16 +13,182 @@
 #ifndef LLVM_MC_MCPARSER_ASMLEXER_H
 #define LLVM_MC_MCPARSER_ASMLEXER_H
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/MC/MCAsmMacro.h"
+#include <cassert>
+#include <cstddef>
 #include <string>
+#include <utility>
 
 namespace llvm {
 
 class MCAsmInfo;
 
+/// A callback class which is notified of each comment in an assembly file as
+/// it is lexed.
+class AsmCommentConsumer {
+public:
+  virtual ~AsmCommentConsumer() = default;
+
+  /// Callback function for when a comment is lexed. Loc is the start of the
+  /// comment text (excluding the comment-start marker). CommentText is the text
+  /// of the comment, excluding the comment start and end markers, and the
+  /// newline for single-line comments.
+  virtual void HandleComment(SMLoc Loc, StringRef CommentText) = 0;
+};
+
+/// Generic assembler lexer interface, for use by target specific assembly
+/// lexers.
+class MCAsmLexer {
+  /// The current token, stored in the base class for faster access.
+  SmallVector<AsmToken, 1> CurTok;
+
+  /// The location and description of the current error
+  SMLoc ErrLoc;
+  std::string Err;
+
+protected: // Can only create subclasses.
+  const char *TokStart = nullptr;
+  bool SkipSpace = true;
+  bool AllowAtInIdentifier = false;
+  bool AllowHashInIdentifier = false;
+  bool IsAtStartOfStatement = true;
+  bool LexMasmHexFloats = false;
+  bool LexMasmIntegers = false;
+  bool LexMasmStrings = false;
+  bool LexMotorolaIntegers = false;
+  bool UseMasmDefaultRadix = false;
+  unsigned DefaultRadix = 10;
+  bool LexHLASMIntegers = false;
+  bool LexHLASMStrings = false;
+  AsmCommentConsumer *CommentConsumer = nullptr;
+
+  MCAsmLexer();
+
+  virtual AsmToken LexToken() = 0;
+
+  void SetError(SMLoc errLoc, const std::string &err) {
+    ErrLoc = errLoc;
+    Err = err;
+  }
+
+public:
+  MCAsmLexer(const MCAsmLexer &) = delete;
+  MCAsmLexer &operator=(const MCAsmLexer &) = delete;
+  virtual ~MCAsmLexer();
+
+  /// Consume the next token from the input stream and return it.
+  ///
+  /// The lexer will continuously return the end-of-file token once the end of
+  /// the main input file has been reached.
+  const AsmToken &Lex() {
+    assert(!CurTok.empty());
+    // Mark if we parsing out a EndOfStatement.
+    IsAtStartOfStatement = CurTok.front().getKind() == AsmToken::EndOfStatement;
+    CurTok.erase(CurTok.begin());
+    // LexToken may generate multiple tokens via UnLex but will always return
+    // the first one. Place returned value at head of CurTok vector.
+    if (CurTok.empty()) {
+      AsmToken T = LexToken();
+      CurTok.insert(CurTok.begin(), T);
+    }
+    return CurTok.front();
+  }
+
+  void UnLex(AsmToken const &Token) {
+    IsAtStartOfStatement = false;
+    CurTok.insert(CurTok.begin(), Token);
+  }
+
+  bool isAtStartOfStatement() { return IsAtStartOfStatement; }
+
+  virtual StringRef LexUntilEndOfStatement() = 0;
+
+  /// Get the current source location.
+  SMLoc getLoc() const;
+
+  /// Get the current (last) lexed token.
+  const AsmToken &getTok() const { return CurTok[0]; }
+
+  /// Look ahead at the next token to be lexed.
+  const AsmToken peekTok(bool ShouldSkipSpace = true) {
+    AsmToken Tok;
+
+    MutableArrayRef<AsmToken> Buf(Tok);
+    size_t ReadCount = peekTokens(Buf, ShouldSkipSpace);
+
+    assert(ReadCount == 1);
+    (void)ReadCount;
+
+    return Tok;
+  }
+
+  /// Look ahead an arbitrary number of tokens.
+  virtual size_t peekTokens(MutableArrayRef<AsmToken> Buf,
+                            bool ShouldSkipSpace = true) = 0;
+
+  /// Get the current error location
+  SMLoc getErrLoc() { return ErrLoc; }
+
+  /// Get the current error string
+  const std::string &getErr() { return Err; }
+
+  /// Get the kind of current token.
+  AsmToken::TokenKind getKind() const { return getTok().getKind(); }
+
+  /// Check if the current token has kind \p K.
+  bool is(AsmToken::TokenKind K) const { return getTok().is(K); }
+
+  /// Check if the current token has kind \p K.
+  bool isNot(AsmToken::TokenKind K) const { return getTok().isNot(K); }
+
+  /// Set whether spaces should be ignored by the lexer
+  void setSkipSpace(bool val) { SkipSpace = val; }
+
+  bool getAllowAtInIdentifier() { return AllowAtInIdentifier; }
+  void setAllowAtInIdentifier(bool v) { AllowAtInIdentifier = v; }
+
+  void setAllowHashInIdentifier(bool V) { AllowHashInIdentifier = V; }
+
+  void setCommentConsumer(AsmCommentConsumer *CommentConsumer) {
+    this->CommentConsumer = CommentConsumer;
+  }
+
+  /// Set whether to lex masm-style binary (e.g., 0b1101) and radix-specified
+  /// literals (e.g., 0ABCh [hex], 576t [decimal], 77o [octal], 1101y [binary]).
+  void setLexMasmIntegers(bool V) { LexMasmIntegers = V; }
+
+  /// Set whether to use masm-style default-radix integer literals. If disabled,
+  /// assume decimal unless prefixed (e.g., 0x2c [hex], 077 [octal]).
+  void useMasmDefaultRadix(bool V) { UseMasmDefaultRadix = V; }
+
+  unsigned getMasmDefaultRadix() const { return DefaultRadix; }
+  void setMasmDefaultRadix(unsigned Radix) { DefaultRadix = Radix; }
+
+  /// Set whether to lex masm-style hex float literals, such as 3f800000r.
+  void setLexMasmHexFloats(bool V) { LexMasmHexFloats = V; }
+
+  /// Set whether to lex masm-style string literals, such as 'Can''t find file'
+  /// and "This ""value"" not found".
+  void setLexMasmStrings(bool V) { LexMasmStrings = V; }
+
+  /// Set whether to lex Motorola-style integer literals, such as $deadbeef or
+  /// %01010110.
+  void setLexMotorolaIntegers(bool V) { LexMotorolaIntegers = V; }
+
+  /// Set whether to lex HLASM-flavour integers. For now this is only [0-9]*
+  void setLexHLASMIntegers(bool V) { LexHLASMIntegers = V; }
+
+  /// Set whether to "lex" HLASM-flavour character and string literals. For now,
+  /// setting this option to true, will disable lexing for character and string
+  /// literals.
+  void setLexHLASMStrings(bool V) { LexHLASMStrings = V; }
+};
+
 /// AsmLexer - Lexer class for assembly files.
-class AsmLexer : public MCAsmLexer {
+class AsmLexer final : public MCAsmLexer {
   const MCAsmInfo &MAI;
 
   const char *CurPtr = nullptr;
diff --git a/llvm/include/llvm/MC/MCParser/MCAsmLexer.h b/llvm/include/llvm/MC/MCParser/MCAsmLexer.h
index 61b89b9a103f4..0b004537be4fc 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmLexer.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmLexer.h
@@ -6,187 +6,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_MC_MCPARSER_MCASMLEXER_H
-#define LLVM_MC_MCPARSER_MCASMLEXER_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/MC/MCAsmMacro.h"
-#include <cassert>
-#include <cstddef>
-#include <string>
-#include <utility>
-
-namespace llvm {
-
-/// A callback class which is notified of each comment in an assembly file as
-/// it is lexed.
-class AsmCommentConsumer {
-public:
-  virtual ~AsmCommentConsumer() = default;
-
-  /// Callback function for when a comment is lexed. Loc is the start of the
-  /// comment text (excluding the comment-start marker). CommentText is the text
-  /// of the comment, excluding the comment start and end markers, and the
-  /// newline for single-line comments.
-  virtual void HandleComment(SMLoc Loc, StringRef CommentText) = 0;
-};
-
-
-/// Generic assembler lexer interface, for use by target specific assembly
-/// lexers.
-class MCAsmLexer {
-  /// The current token, stored in the base class for faster access.
-  SmallVector<AsmToken, 1> CurTok;
-
-  /// The location and description of the current error
-  SMLoc ErrLoc;
-  std::string Err;
-
-protected: // Can only create subclasses.
-  const char *TokStart = nullptr;
-  bool SkipSpace = true;
-  bool AllowAtInIdentifier = false;
-  bool AllowHashInIdentifier = false;
-  bool IsAtStartOfStatement = true;
-  bool LexMasmHexFloats = false;
-  bool LexMasmIntegers = false;
-  bool LexMasmStrings = false;
-  bool LexMotorolaIntegers = false;
-  bool UseMasmDefaultRadix = false;
-  unsigned DefaultRadix = 10;
-  bool LexHLASMIntegers = false;
-  bool LexHLASMStrings = false;
-  AsmCommentConsumer *CommentConsumer = nullptr;
-
-  MCAsmLexer();
-
-  virtual AsmToken LexToken() = 0;
-
-  void SetError(SMLoc errLoc, const std::string &err) {
-    ErrLoc = errLoc;
-    Err = err;
-  }
-
-public:
-  MCAsmLexer(const MCAsmLexer &) = delete;
-  MCAsmLexer &operator=(const MCAsmLexer &) = delete;
-  virtual ~MCAsmLexer();
-
-  /// Consume the next token from the input stream and return it.
-  ///
-  /// The lexer will continuously return the end-of-file token once the end of
-  /// the main input file has been reached.
-  const AsmToken &Lex() {
-    assert(!CurTok.empty());
-    // Mark if we parsing out a EndOfStatement.
-    IsAtStartOfStatement = CurTok.front().getKind() == AsmToken::EndOfStatement;
-    CurTok.erase(CurTok.begin());
-    // LexToken may generate multiple tokens via UnLex but will always return
-    // the first one. Place returned value at head of CurTok vector.
-    if (CurTok.empty()) {
-      AsmToken T = LexToken();
-      CurTok.insert(CurTok.begin(), T);
-    }
-    return CurTok.front();
-  }
-
-  void UnLex(AsmToken const &Token) {
-    IsAtStartOfStatement = false;
-    CurTok.insert(CurTok.begin(), Token);
-  }
-
-  bool isAtStartOfStatement() { return IsAtStartOfStatement; }
-
-  virtual StringRef LexUntilEndOfStatement() = 0;
-
-  /// Get the current source location.
-  SMLoc getLoc() const;
-
-  /// Get the current (last) lexed token.
-  const AsmToken &getTok() const {
-    return CurTok[0];
-  }
-
-  /// Look ahead at the next token to be lexed.
-  const AsmToken peekTok(bool ShouldSkipSpace = true) {
-    AsmToken Tok;
-
-    MutableArrayRef<AsmToken> Buf(Tok);
-    size_t ReadCount = peekTokens(Buf, ShouldSkipSpace);
-
-    assert(ReadCount == 1);
-    (void)ReadCount;
-
-    return Tok;
-  }
-
-  /// Look ahead an arbitrary number of tokens.
-  virtual size_t peekTokens(MutableArrayRef<AsmToken> Buf,
-                            bool ShouldSkipSpace = true) = 0;
-
-  /// Get the current error location
-  SMLoc getErrLoc() {
-    return ErrLoc;
-  }
-
-  /// Get the current error string
-  const std::string &getErr() {
-    return Err;
-  }
-
-  /// Get the kind of current token.
-  AsmToken::TokenKind getKind() const { return getTok().getKind(); }
-
-  /// Check if the current token has kind \p K.
-  bool is(AsmToken::TokenKind K) const { return getTok().is(K); }
-
-  /// Check if the current token has kind \p K.
-  bool isNot(AsmToken::TokenKind K) const { return getTok().isNot(K); }
-
-  /// Set whether spaces should be ignored by the lexer
-  void setSkipSpace(bool val) { SkipSpace = val; }
-
-  bool getAllowAtInIdentifier() { return AllowAtInIdentifier; }
-  void setAllowAtInIdentifier(bool v) { AllowAtInIdentifier = v; }
-
-  void setAllowHashInIdentifier(bool V) { AllowHashInIdentifier = V; }
-
-  void setCommentConsumer(AsmCommentConsumer *CommentConsumer) {
-    this->CommentConsumer = CommentConsumer;
-  }
-
-  /// Set whether to lex masm-style binary (e.g., 0b1101) and radix-specified
-  /// literals (e.g., 0ABCh [hex], 576t [decimal], 77o [octal], 1101y [binary]).
-  void setLexMasmIntegers(bool V) { LexMasmIntegers = V; }
-
-  /// Set whether to use masm-style default-radix integer literals. If disabled,
-  /// assume decimal unless prefixed (e.g., 0x2c [hex], 077 [octal]).
-  void useMasmDefaultRadix(bool V) { UseMasmDefaultRadix = V; }
-
-  unsigned getMasmDefaultRadix() const { return DefaultRadix; }
-  void setMasmDefaultRadix(unsigned Radix) { DefaultRadix = Radix; }
-
-  /// Set whether to lex masm-style hex float literals, such as 3f800000r.
-  void setLexMasmHexFloats(bool V) { LexMasmHexFloats = V; }
-
-  /// Set whether to lex masm-style string literals, such as 'Can''t find file'
-  /// and "This ""value"" not found".
-  void setLexMasmStrings(bool V) { LexMasmStrings = V; }
-
-  /// Set whether to lex Motorola-style integer literals, such as $deadbeef or
-  /// %01010110.
-  void setLexMotorolaIntegers(bool V) { LexMotorolaIntegers = V; }
-
-  /// Set whether to lex HLASM-flavour integers. For now this is only [0-9]*
-  void setLexHLASMIntegers(bool V) { LexHLASMIntegers = V; }
-
-  /// Set whether to "lex" HLASM-flavour character and string literals. For now,
-  /// setting this option to true, will disable lexing for character and string
-  /// literals.
-  void setLexHLASMStrings(bool V) { LexHLASMStrings = V; }
-};
-
-} // end namespace llvm
-
-#endif // LLVM_MC_MCPARSER_MCASMLEXER_H
+#include "llvm/MC/MCParser/AsmLexer.h"
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index 8715f94d51fe5..489933649b624 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/raw_ostream.h"
 #include <cassert>
 #include <cctype>
 #include <cstdio>
@@ -31,6 +32,91 @@
 
 using namespace llvm;
 
+MCAsmLexer::MCAsmLexer() { CurTok.emplace_back(AsmToken::Space, StringRef()); }
+
+MCAsmLexer::~MCAsmLexer() = default;
+
+SMLoc MCAsmLexer::getLoc() const { return SMLoc::getFromPointer(TokStart); }
+
+SMLoc AsmToken::getLoc() const { return SMLoc::getFromPointer(Str.data()); }
+
+SMLoc AsmToken::getEndLoc() const {
+  return SMLoc::getFromPointer(Str.data() + Str.size());
+}
+
+SMRange AsmToken::getLocRange() const { return SMRange(getLoc(), getEndLoc()); }
+
+void AsmToken::dump(raw_ostream &OS) const {
+  switch (Kind) {
+  case AsmToken::Error:
+    OS << "error";
+    break;
+  case AsmToken::Identifier:
+    OS << "identifier: " << getString();
+    break;
+  case AsmToken::Integer:
+    OS << "int: " << getString();
+    break;
+  case AsmToken::Real:
+    OS << "real: " << getString();
+    break;
+  case AsmToken::String:
+    OS << "string: " << getString();
+    break;
+
+    // clang-format off
+  case AsmToken::Amp:                OS << "Amp"; break;
+  case AsmToken::AmpAmp:             OS << "AmpAmp"; break;
+  case AsmToken::At:                 OS << "At"; break;
+  case AsmToken::BackSlash:          OS << "BackSlash"; break;
+  case AsmToken::BigNum:             OS << "BigNum"; break;
+  case AsmToken::Caret:              OS << "Caret"; break;
+  case AsmToken::Colon:              OS << "Colon"; break;
+  case AsmToken::Comma:              OS << "Comma"; break;
+  case AsmToken::Comment:            OS << "Comment"; break;
+  case AsmToken::Dollar:             OS << "Dollar"; break;
+  case AsmToken::Dot:                OS << "Dot"; break;
+  case AsmToken::EndOfStatement:     OS << "EndOfStatement"; break;
+  case AsmToken::Eof:                OS << "Eof"; break;
+  case AsmToken::Equal:              OS << "Equal"; break;
+  case AsmToken::EqualEqual:         OS << "EqualEqual"; break;
+  case AsmToken::Exclaim:            OS << "Exclaim"; break;
+  case AsmToken::ExclaimEqual:       OS << "ExclaimEqual"; break;
+  case AsmToken::Greater:            OS << "Greater"; break;
+  case AsmToken::GreaterEqual:       OS << "GreaterEqual"; break;
+  case AsmToken::GreaterGreater:     OS << "GreaterGreater"; break;
+  case AsmToken::Hash:               OS << "Hash"; break;
+  case AsmToken::HashDirective:      OS << "HashDirective"; break;
+  case AsmToken::LBrac:              OS << "LBrac"; break;
+  case AsmToken::LCurly:             OS << "LCurly"; break;
+  case AsmToken::LParen:             OS << "LParen"; break;
+  case AsmToken::Less:               OS << "Less"; break;
+  case AsmToken::LessEqual:          OS << "LessEqual"; break;
+  case AsmToken::LessGreater:        OS << "LessGreater"; break;
+  case AsmToken::LessLess:           OS << "LessLess"; break;
+  case AsmToken::Minus:              OS << "Minus"; break;
+  case AsmToken::MinusGreater:       OS << "MinusGreater"; break;
+  case AsmToken::Percent:            OS << "Percent"; break;
+  case AsmToken::Pipe:               OS << "Pipe"; break;
+  case AsmToken::PipePipe:           OS << "PipePipe"; break;
+  case AsmToken::Plus:               OS << "Plus"; break;
+  case AsmToken::Question:           OS << "Question"; break;
+  case AsmToken::RBrac:              OS << "RBrac"; break;
+  case AsmToken::RCurly:             OS << "RCurly"; break;
+  case AsmToken::RParen:             OS << "RParen"; break;
+  case AsmToken::Slash:              OS << "Slash"; break;
+  case AsmToken::Space:              OS << "Space"; break;
+  case AsmToken::Star:               OS << "Star"; break;
+  case AsmToken::Tilde:              OS << "Tilde"; break;
+    // clang-format on
+  }
+
+  // Print the token string.
+  OS << " (\"";
+  OS.write_escaped(getString());
+  OS << "\")";
+}
+
 AsmLexer::AsmLexer(const MCAsmInfo &MAI) : MAI(MAI) {
   // For COFF targets, this is true, while for ELF targets, it should be false.
   // Currently, @specifier parsing depends on '@' being included in the token.
diff --git a/llvm/lib/MC/MCParser/CMakeLists.txt b/llvm/lib/MC/MCParser/CMakeLists.txt
index d3fa2675a255e..008a50e9da660 100644
--- a/llvm/lib/MC/MCParser/CMakeLists.txt
+++ b/llvm/lib/MC/MCParser/CMakeLists.txt
@@ -6,7 +6,6 @@ add_llvm_component_library(LLVMMCParser
   GOFFAsmParser.cpp
   DarwinAsmParser.cpp
   ELFAsmParser.cpp
-  MCAsmLexer.cpp
   MCAsmParser.cpp
   MCAsmParserExtension.cpp
   MCTargetAsmParser.cpp
diff --git a/llvm/lib/MC/MCParser/MCAsmLexer.cpp b/llvm/lib/MC/MCParser/MCAsmLexer.cpp
deleted file mode 100644
index 8bdba218aa9c0..0000000000000
--- a/llvm/lib/MC/MCParser/MCAsmLexer.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//===- MCAsmLexer.cpp - Abstract Asm Lexer Interface ----------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/MC/MCParser/MCAsmLexer.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/SMLoc.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-MCAsmLexer::MCAsmLexer() {
-  CurTok.emplace_back(AsmToken::Space, StringRef());
-}
-
-MCAsmLexer::~MCAsmLexer() = default;
-
-SMLoc MCAsmLexer::getLoc() const {
-  return SMLoc::getFromPointer(TokStart);
-}
-
-SMLoc AsmToken::getLoc() const {
-  return SMLoc::getFromPointer(Str.data());
-}
-
-SMLoc AsmToken::getEndLoc() const {
-  return SMLoc::getFromPointer(Str.data() + Str.size());
-}
-
-SMRange AsmToken::getLocRange() const {
-  return SMRange(getLoc(), getEndLoc());
-}
-
-void AsmToken::dump(raw_ostream &OS) const {
-  switch (Kind) {
-  case AsmToken::Error:
-    OS << "error";
-    break;
-  case AsmToken::Identifier:
-    OS << "identifier: " << getString();
-    break;
-  case AsmToken::Integer:
-    OS << "int: " << getString();
-    break;
-  case AsmToken::Real:
-    OS << "real: " << getString();
-    break;
-  case AsmToken::String:
-    OS << "string: " << getString();
-    break;
-
-  case AsmToken::Amp:                OS << "Amp"; break;
-  case AsmToken::AmpAmp:             OS << "AmpAmp"; break;
-  case AsmToken::At:                 OS << "At"; break;
-  case AsmToken::BackSlash:          OS << "BackSlash"; break;
-  case AsmToken::BigNum:             OS << "BigNum"; break;
-  case AsmToken::Caret:              OS << "Caret"; break;
-  case AsmToken::Colon:              OS << "Colon"; break;
-  case AsmToken::Comma:              OS << "Comma"; break;
-  case AsmToken::Comment:            OS << "Comment"; break;
-  case AsmToken::Dollar:             OS << "Dollar"; break;
-  case AsmToken::Dot:                OS << "Dot"; break;
-  case AsmToken::EndOfStatement:     OS << "EndOfStatement"; break;
-  case AsmToken::Eof:                OS << "Eof"; break;
-  case AsmToken::Equal:              OS << "Equal"; break;
-  case AsmToken::EqualEqual:         OS << "EqualEqual"; break;
-  case AsmToken::Exclaim:            OS << "Exclaim"; break;
-  case AsmToken::Excla...
[truncated]

Copy link
Contributor

@ericastor ericastor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an excellent idea & cleanup. Thanks!

2b11c7d introduced
`llvm/include/llvm/MC/MCAsmLexer.h` and made `AsmLexer` inherit from
`MCAsmLexer`, likely to allow target-specific parsers to depend
solely on `MCAsmLexer`. However, this separation now seems unnecessary
and confusing.

`MCAsmLexer` defines virtual functions with `AsmLexer` as its only
implementation, and `AsmLexer` itself has few extra public methods.

To simplify the codebase, this change merges MCAsmLexer.{h,cpp} into
AsmLexer.{h,cpp}. MCAsmLexer.h is temporarily kept as a forwarder.
MCAsmLexer will be merged into AsmLexer and MCAsmLexer will become
a type alias.

Note: I doubt that a downstream lexer handling an assembly syntax
significantly different from the standard GNU Assembler syntax would
want to inherit from `MCAsmLexer`. Instead, it's more likely they'd extend
`AsmLexer` by adding new states and modifying its internal logic, as seen
with variables for MASM, M68k, and HLASM.

Pull Request: llvm#134208
@MaskRay MaskRay merged commit c9f6d26 into llvm:main Apr 4, 2025
6 of 11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 4, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux running on sanitizer-buildbot7 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/13802

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[182/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[183/186] Generating Msan-aarch64-with-call-Test
[184/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[185/186] Generating Msan-aarch64-Test
[185/186] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 6015 tests, 72 workers --
Testing:  0.. 10.. 20.
FAIL: HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp (1589 of 6015)
******************** TEST 'HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp; mkdir /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp # RUN: at line 1
+ rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp
+ mkdir /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow # RUN: at line 2
+ /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 16 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER0 # RUN: at line 3
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 16
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER0
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 17 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1 # RUN: at line 4
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 17
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -1 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE1 # RUN: at line 5
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -1
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE1
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -17 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE17 # RUN: at line 6
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -17
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE17
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 1016 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1000 # RUN: at line 7
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 1016
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1000
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp:21:12: error: CHECK: expected string not found in input
 // CHECK: Potentially referenced stack object:
           ^
Step 14 (test compiler-rt default) failure: test compiler-rt default (failure)
...
[182/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[183/186] Generating Msan-aarch64-with-call-Test
[184/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[185/186] Generating Msan-aarch64-Test
[185/186] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 6015 tests, 72 workers --
Testing:  0.. 10.. 20.
FAIL: HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp (1589 of 6015)
******************** TEST 'HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp; mkdir /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp # RUN: at line 1
+ rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp
+ mkdir /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow # RUN: at line 2
+ /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 16 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER0 # RUN: at line 3
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 16
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER0
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 17 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1 # RUN: at line 4
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 17
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -1 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE1 # RUN: at line 5
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -1
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE1
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -17 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE17 # RUN: at line 6
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow -17
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,BEFORE17
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 1016 2>&1 | /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index | FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1000 # RUN: at line 7
+ env HWASAN_OPTIONS=disable_allocator_tagging=1:random_tags=0:fail_without_syscall_abi=0:symbolize=0 not /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow 1016
+ /home/b/sanitizer-aarch64-linux/build/build_default/bin/hwasan_symbolize --symbols /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp --index
+ FileCheck /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp --check-prefixes=CHECK,AFTER1000
Could not find symbols for lib/aarch64-linux-gnu/libc.so.6
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp:21:12: error: CHECK: expected string not found in input
 // CHECK: Potentially referenced stack object:
           ^

MaskRay added a commit that referenced this pull request Apr 4, 2025
Follow-up to #134207

Both classes define `IsAtStartOfStatement` but the semantics are
confusingly different. Rename the base class one.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 4, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2640

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/82/95' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-9928-82-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=82 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants