1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/include/llvm/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][SystemZ][z/OS] Add support to AsmLexer to accept HLASM style integers 2021-04-13 15:29:37 -04:00
ConstantPools.h
LaneBitmask.h
MachineLocation.h
MCAsmBackend.h
MCAsmInfo.h [AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start of string. 2021-04-21 10:21:09 -04:00
MCAsmInfoCOFF.h
MCAsmInfoDarwin.h
MCAsmInfoELF.h
MCAsmInfoWasm.h
MCAsmInfoXCOFF.h
MCAsmLayout.h
MCAsmMacro.h
MCAssembler.h [MC] Support .symver *, *, remove 2021-03-06 15:23:02 -08:00
MCCodeEmitter.h
MCCodeView.h
MCContext.h [LTO][MC] Discard non-prevailing defined symbols in module-level assembly 2021-03-18 15:33:42 -07:00
MCDirectives.h
MCDwarf.h [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCELFObjectWriter.h
MCELFStreamer.h [MC] Support .symver *, *, remove 2021-03-06 15:23:02 -08:00
MCExpr.h
MCFixedLenDisassembler.h
MCFixup.h
MCFixupKindInfo.h
MCFragment.h
MCInst.h [MC] Delete unused MCOperand::{create,is,get}FPImm 2021-03-17 00:30:38 -07:00
MCInstBuilder.h
MCInstPrinter.h
MCInstrAnalysis.h
MCInstrDesc.h [MC] MCInstrDesc.h - remove unnecessary <string> include. NFCI. 2021-04-21 15:07:00 +01:00
MCInstrInfo.h
MCInstrItineraries.h
MCLabel.h
MCLinkerOptimizationHint.h
MCMachObjectWriter.h
MCObjectFileInfo.h
MCObjectStreamer.h [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCObjectWriter.h [MC] Change ELFOSABI_NONE to ELFOSABI_GNU for SHF_GNU_RETAIN 2021-03-09 09:59:47 -08:00
MCPseudoProbe.h [CSSPGO] Introducing dangling pseudo probes. 2021-03-03 22:44:41 -08:00
MCRegister.h
MCRegisterInfo.h Add register size info back to MCRegisterClass 2021-03-23 15:04:44 -07:00
MCSchedule.h [MCA] Add support for in-order CPUs 2021-03-04 14:08:19 +03:00
MCSection.h
MCSectionCOFF.h
MCSectionELF.h
MCSectionMachO.h Support #pragma clang section directives on MachO targets 2021-02-25 09:30:10 -08:00
MCSectionWasm.h
MCSectionXCOFF.h [AIX][TLS] Add assert check of valid csect type for the storage mapping class XCOFF::XMC_UL 2021-03-08 14:18:57 -06:00
MCStreamer.h fix comment typos to cycle bots 2021-04-14 22:12:56 -04:00
MCSubtargetInfo.h AMDGPU: Add target id and code object v4 support 2021-03-24 11:54:05 -04:00
MCSymbol.h
MCSymbolCOFF.h
MCSymbolELF.h
MCSymbolMachO.h
MCSymbolWasm.h [WebAssembly][MC] Record limit constraints for table sizes 2021-03-24 09:44:22 +01:00
MCSymbolXCOFF.h
MCTargetOptions.h
MCTargetOptionsCommandFlags.h
MCValue.h
MCWasmObjectWriter.h [WebAssembly] Add new relocation for location relative data 2021-03-08 11:34:10 -08:00
MCWasmStreamer.h
MCWin64EH.h
MCWinCOFFObjectWriter.h
MCWinCOFFStreamer.h
MCWinEH.h
MCXCOFFObjectWriter.h
MCXCOFFStreamer.h
SectionKind.h [AIX][TLS] Generate TLS variables in assembly files 2021-03-02 18:22:48 -06:00
StringTableBuilder.h
SubtargetFeature.h