1 Pull in r201784 from upstream llvm trunk (by Benjamin Kramer):
3 AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
5 There is code in the wild that relies on $0 not being expanded.
7 This fixes some cases of using $ signs in literals being incorrectly
10 Reported by: Richard Henderson
11 Upstream PR: http://llvm.org/PR21500
13 Introduced here: http://svnweb.freebsd.org/changeset/base/274286
15 Index: lib/MC/MCParser/AsmParser.cpp
16 ===================================================================
17 --- lib/MC/MCParser/AsmParser.cpp
18 +++ lib/MC/MCParser/AsmParser.cpp
19 @@ -1695,7 +1695,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
20 const MCAsmMacroParameters &Parameters,
21 const MCAsmMacroArguments &A, const SMLoc &L) {
22 unsigned NParameters = Parameters.size();
23 - if (NParameters != 0 && NParameters != A.size())
24 + if ((!IsDarwin || NParameters != 0) && NParameters != A.size())
25 return Error(L, "Wrong number of arguments");
27 // A macro without parameters is handled differently on Darwin:
28 @@ -1705,7 +1705,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
29 std::size_t End = Body.size(), Pos = 0;
30 for (; Pos != End; ++Pos) {
31 // Check for a substitution or escape.
33 + if (IsDarwin && !NParameters) {
34 // This macro has no parameters, look for $0, $1, etc.
35 if (Body[Pos] != '$' || Pos + 1 == End)
37 @@ -1728,7 +1728,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
42 + if (IsDarwin && !NParameters) {
43 switch (Body[Pos + 1]) {
46 Index: test/MC/AsmParser/exprs.s
47 ===================================================================
48 --- test/MC/AsmParser/exprs.s
49 +++ test/MC/AsmParser/exprs.s
51 -// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
52 +// RUN: llvm-mc -triple i386-apple-darwin %s