1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/lib/MC
Anirudh Prasad 129d906140 [AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start of string.
- Previously, https://reviews.llvm.org/D72680 introduced a new attribute called `AllowSymbolAtNameStart` (in relation to the MAsmParser changes) in `MCAsmInfo.h` which (according to the comment in the header) allows the following behaviour:

```
  /// This is true if the assembler allows $ @ ? characters at the start of
  /// symbol names. Defaults to false.
```

- However, the usage of this field in AsmLexer.cpp doesn't seem completely accurate* for a couple of reasons.

```
  default:
    if (MAI.doesAllowSymbolAtNameStart()) {
      // Handle Microsoft-style identifier: [a-zA-Z_$.@?][a-zA-Z0-9_$.@#?]*
      if (!isDigit(CurChar) &&
          isIdentifierChar(CurChar, MAI.doesAllowAtInName(),
                           AllowHashInIdentifier))
        return LexIdentifier();
    }
```

1. The Dollar and At tokens, when occurring at the start of the string, are treated as separate tokens (AsmToken::Dollar and AsmToken::At respectively) and not lexed as an Identifier.
2. I'm not too sure why `MAI.doesAllowAtInName()` is used when `AllowAtInIdentifier` could be used. For X86 platforms, afaict, this shouldn't be an issue, since the `CommentString` attribute isn't "@". (alternatively the call to the setter can be set anywhere else as needed). The `AllowAtInName` does have an additional important meaning, but in the context of AsmLexer, shouldn't mean anything different compared to `AllowAtInIdentifier`

My proposal is the following:

- Introduce 3 new fields called `AllowQuestionTokenAtStartOfString`, `AllowDollarTokenAtStartOfString` and `AllowAtTokenAtStartOfString` in MCAsmInfo.h which will encapsulate the previously documented behaviour of "allowing $, @, ? characters at the start of symbol names")
- Introduce these fields where "$", "@" are lexed, and treat them as identifiers depending on whether `Allow[Dollar|At]TokenAtStartOfString` is set.
- For the sole case of "?", append it to the existing logic for treating a "default" token as an Identifier.

z/OS (HLASM) will also make use of some of these fields in follow up patches.

completely accurate* - This was based on the comments and the intended behaviour the code. I might have completely misinterpreted it, and if that is the case my sincere apologies. We can close this patch if necessary, if there are no changes to be made :)

Depends on https://reviews.llvm.org/D99374

Reviewed By: Jonathan.Crowther

Differential Revision: https://reviews.llvm.org/D99889
2021-04-21 10:21:09 -04:00
..
MCDisassembler
MCParser [AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start of string. 2021-04-21 10:21:09 -04:00
CMakeLists.txt
ConstantPools.cpp
ELFObjectWriter.cpp [MC][ELF] Fix "enumeral and non-enumeral type in conditional expression" warning (NFC) 2021-03-10 11:27:15 +08:00
MachObjectWriter.cpp
MCAsmBackend.cpp
MCAsmInfo.cpp
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCAsmMacro.cpp
MCAsmStreamer.cpp [MC] Support .symver *, *, remove 2021-03-06 15:23:02 -08:00
MCAssembler.cpp
MCCodeEmitter.cpp
MCCodeView.cpp
MCContext.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCDwarf.cpp [Debug-Info] Add names for the debug line prologue. 2021-03-12 04:45:08 +00:00
MCELFObjectTargetWriter.cpp
MCELFStreamer.cpp [MC] Change ELFOSABI_NONE to ELFOSABI_GNU for SHF_GNU_RETAIN 2021-03-09 09:59:47 -08:00
MCExpr.cpp
MCFragment.cpp
MCInst.cpp
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCInstrDesc.cpp
MCInstrInfo.cpp
MCLabel.cpp
MCLinkerOptimizationHint.cpp
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp
MCNullStreamer.cpp
MCObjectFileInfo.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCObjectStreamer.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCObjectWriter.cpp
MCPseudoProbe.cpp
MCRegisterInfo.cpp
MCSchedule.cpp
MCSection.cpp
MCSectionCOFF.cpp
MCSectionELF.cpp
MCSectionMachO.cpp Support #pragma clang section directives on MachO targets 2021-02-25 09:30:10 -08:00
MCSectionWasm.cpp
MCSectionXCOFF.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCStreamer.cpp [CodeGen] Report a normal instead of fatal error for label redefinition 2021-03-09 10:54:41 +00:00
MCSubtargetInfo.cpp AMDGPU: Add target id and code object v4 support 2021-03-24 11:54:05 -04:00
MCSymbol.cpp
MCSymbolELF.cpp
MCSymbolXCOFF.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCTargetOptions.cpp
MCTargetOptionsCommandFlags.cpp
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp
MCWin64EH.cpp
MCWinCOFFStreamer.cpp
MCWinEH.cpp
MCXCOFFObjectTargetWriter.cpp
MCXCOFFStreamer.cpp
StringTableBuilder.cpp
SubtargetFeature.cpp
WasmObjectWriter.cpp [WebAssembly] Improve error messages regarding missing indirect function table. NFC 2021-04-07 07:58:43 -07:00
WinCOFFObjectWriter.cpp
XCOFFObjectWriter.cpp [AIX][TLS] Add support for TLS variables to XCOFF object writer 2021-04-06 10:46:07 -05:00