aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorLucas Prates <lucas.prates@arm.com>2020-02-10 16:48:25 +0000
committerLucas Prates <lucas.prates@arm.com>2020-03-06 16:27:51 +0000
commit0ba553d153e65b283c7934c3f061ad0487f03ba6 (patch)
tree91f835b95d2d09c8819865c3314dd117c8e85c9c /llvm/lib
parentaf1c2e561e5fbd584093b1200cf364fe1b7ec7c4 (diff)
downloadllvm-0ba553d153e65b283c7934c3f061ad0487f03ba6.zip
llvm-0ba553d153e65b283c7934c3f061ad0487f03ba6.tar.gz
llvm-0ba553d153e65b283c7934c3f061ad0487f03ba6.tar.bz2
[MC] Allowing the use of $-prefixed integer as asm identifiers
Summary: Dollar signed prefixed integers were not allowed by the AsmParser to be used as Identifiers, differing from the GNU assembler behavior. This patch updates the parsing of Identifiers to consider such cases as valid, where the identifier string includes the $ prefix itself. As the Lexer currently splits these occurrences into separate tokens, those need to be combined by the AsmParser itself. Reviewers: efriedma, chill Reviewed By: efriedma Subscribers: sdardis, hiraditya, jrtc27, atanasyan, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75111
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index a3d2d9f..c5c44a7 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2854,18 +2854,18 @@ bool AsmParser::parseIdentifier(StringRef &Res) {
AsmToken Buf[1];
Lexer.peekTokens(Buf, false);
- if (Buf[0].isNot(AsmToken::Identifier))
+ if (Buf[0].isNot(AsmToken::Identifier) && Buf[0].isNot(AsmToken::Integer))
return true;
- // We have a '$' or '@' followed by an identifier, make sure they are adjacent.
+ // We have a '$' or '@' followed by an identifier or integer token, make
+ // sure they are adjacent.
if (PrefixLoc.getPointer() + 1 != Buf[0].getLoc().getPointer())
return true;
// eat $ or @
Lexer.Lex(); // Lexer's Lex guarantees consecutive token.
// Construct the joined identifier and consume the token.
- Res =
- StringRef(PrefixLoc.getPointer(), getTok().getIdentifier().size() + 1);
+ Res = StringRef(PrefixLoc.getPointer(), getTok().getString().size() + 1);
Lex(); // Parser Lex to maintain invariants.
return false;
}