ARMAsmParser was incorrectly dropping a leading dollar sign character
from symbol names in targets of branch instructions. This was caused by
an incorrect assumption that the contents following the dollar sign
token should be handled as a constant immediate, similarly to the #
token.
This patch avoids the operand parsing from consuming the dollar sign
token when it is followed by an identifier, making sure it is properly
parsed as part of the expression.
clang-format: please reformat the code
- // #42 -> immediate - // $ 42 -> immediate - // $foo -> symbol name - // $42 -> symbol name - S = Parser.getTok().getLoc(); - - // Favor the interpretation of $-prefixed operands as symbol names. - // Cases where immediates are explicitly expected are handled by their - // specific ParseMethod implementations. - auto AdjacentToken = getLexer().peekTok(/*ShouldSkipSpace=*/false); - bool ExpectIdentifier = Parser.getTok().is(AsmToken::Dollar) && - (AdjacentToken.is(AsmToken::Identifier) || - AdjacentToken.is(AsmToken::String) || - AdjacentToken.is(AsmToken::Integer)); - if (!ExpectIdentifier) { - // Token is not part of identifier. Drop leading $ or # before parsing expression. - Parser.Lex(); - } + // #42 -> immediate + // $ 42 -> immediate + // $foo -> symbol name + // $42 -> symbol name + S = Parser.getTok().getLoc();