Skip to content

Commit e9f6dea

Browse files
committed
[MCAsmParser] .irpc: correctly handle quoted string
The quotes should be stripped. Improve the test to check all of Identifier, Integer, and String. GNU assembler also supports `.irpc c,"" a` but there is no real world use case. So don't implement it.
1 parent 5e231ff commit e9f6dea

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5780,7 +5780,8 @@ bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) {
57805780
SmallString<256> Buf;
57815781
raw_svector_ostream OS(Buf);
57825782

5783-
StringRef Values = A.front().front().getString();
5783+
StringRef Values = A[0][0].is(AsmToken::String) ? A[0][0].getStringContents()
5784+
: A[0][0].getString();
57845785
for (std::size_t I = 0, End = Values.size(); I != End; ++I) {
57855786
MCAsmMacroArgument Arg;
57865787
Arg.emplace_back(AsmToken::Identifier, Values.slice(I, I + 1));

llvm/test/MC/AsmParser/macro-irpc.s

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
// RUN: llvm-mc -triple x86_64-unknown-unknown %s | FileCheck %s
22

3-
.irpc foo,123
3+
.irpc foo,"123"
44
.long \foo
55
.endr
6+
.irpc foo,ab
7+
.long 0x\foo
8+
.endr
9+
.irpc foo,""
10+
.endr
611

712
// CHECK: long 1
813
// CHECK: long 2
914
// CHECK: long 3
15+
// CHECK: long 10
16+
// CHECK: long 11
17+
// CHECK-NOT: long
1018

1119
.irpc foo,123
1220
.irpc bar,45

0 commit comments

Comments
 (0)