[PATCH] D73176: [ARM] Fix dropped dollar sign from symbols in branch targets

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 06:59:03 PST 2020


chill added inline comments.


================
Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:6051
+    // $42 -> immediate
+    // $foo -> symbol name
     S = Parser.getTok().getLoc();
----------------
chill wrote:
> pratlucas wrote:
> > pratlucas wrote:
> > > chill wrote:
> > > > What if we have here  `$ foo`, i.e. whitespace after the dollar? We should not paste together two separate tokens `$` and `<whatever>` to form an identifier,  `$foo`, `$12` are identifiers, but `$ 12` is not.
> > > > 
> > > > 
> > > From what I've checked, `parseExpression(...)` takes care of this scenario:
> > > ```
> > > <stdin>:36:11: error: invalid token in expression
> > >         b $ foo
> > >           ^
> > > ```
> > > The change is not binding the two actual tokens together, but only refraining from removing the $ token from the expression.
> > > Please let me know if you believe a more active handling of this scenario is necessary.
> > Checking the behavior without the changes from the patch, expressions like `b $ foo` are currently accepted by the parser with no errors, as the $ token is dropped from the expression.
> Well, if we have two separate tokens (`AsmToken::Dollar` and `AsmToken::Idenrifier`), but somehow end up with symbol name `$foo`, something must be combining those tokens into one.
> 
> That happens in `AsmParser::parseIdentifier` (https://github.com/llvm/llvm-project/blob/master/llvm/lib/MC/MCParser/AsmParser.cpp#L2844), but (unfortunately?) this function does not handle
> a non-identifier immediately  following the `$`.
(Indeed it check tokens are adjacent).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73176/new/

https://reviews.llvm.org/D73176





More information about the llvm-commits mailing list