[PATCH] D98124: [RISCV] Clean up parsing fence arguments

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 7 11:35:01 PST 2021


jrtc27 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1688
+  SMLoc S = getLoc();
+  SMLoc E = SMLoc::getFromPointer(S.getPointer() - 1);
+  const MCExpr *Res;
----------------
craig.topper wrote:
> jrtc27 wrote:
> > craig.topper wrote:
> > > I see this SMLoc::getFromPointer(S.getPointer() - 1) repeated a lot in the assembly parser. Is this doing something I don't understand and setting a valid end location or are we just frequently setting an invalid end location?
> > Hm, indeed, this seems to be a consistent misunderstanding in the parser here. Normally you'd lex and _then_ get E based on the _new_ location, but this creates a -1-sized range. The -1 itself is also odd, though seems to be rather pervasive across the backends; SMRange is meant to be half-open, so the -1 is already accounted for.
> You don't even need to Lex the next token. There's a getEndLoc() on the Token class.
In this case, yeah, though some cases in this file are more complex and so would likely need to use that kind of pattern instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98124



More information about the llvm-commits mailing list