llvm.org GIT mirror llvm / 68f89a6
MC assembly parser handling for trailing comma in macro instantiation. A trailing comma means no argument at all (i.e., as if the comma were not present), not an empty argument to the invokee. rdar://11252521 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154863 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Grosbach 7 years ago
2 changed file(s) with 29 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
15261526 }
15271527 Lex();
15281528 }
1529 // If there weren't any arguments, erase the token vector so everything
1530 // else knows that. Leaving around the vestigal empty token list confuses
1531 // things.
1532 if (MacroArguments.size() == 1 && MacroArguments.back().empty())
1533 MacroArguments.clear();
1529 // If the last argument didn't end up with any tokens, it's not a real
1530 // argument and we should remove it from the list. This happens with either
1531 // a tailing comma or an empty argument list.
1532 if (MacroArguments.back().empty())
1533 MacroArguments.pop_back();
15341534
15351535 // Macro instantiation is lexical, unfortunately. We construct a new buffer
15361536 // to hold the macro body with substitutions.
1717
1818 // CHECK: .long 3
1919 // CHECK: .long 0
20
21
22 .macro top
23 middle _$0, $1
24 .endm
25 .macro middle
26 $0:
27 .if $n > 1
28 bottom $1
29 .endif
30 .endm
31 .macro bottom
32 .set fred, $0
33 .endm
34
35 .text
36
37 top foo
38 top bar, 42
39
40 // CHECK: _foo:
41 // CHECK-NOT: fred
42 // CHECK: _bar
43 // CHECK-NEXT: fred = 42