Page MenuHomePhabricator

[MC] Prevent out of order HashDirective lexing in AsmLexer.
ClosedPublic

Authored by niravd on Sep 22 2016, 12:12 PM.

Details

Summary

To lex hash directives we peek ahead to find component tokens, create a
unified token, and unlex the peeked tokens so the parser does not need
to parse the tokens then. Make sure we do not to lex another hash
directive during peek operation.

This fixes PR28921.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd updated this revision to Diff 72201.Sep 22 2016, 12:12 PM
niravd retitled this revision from to [MC] Prevent out of order HashDirective lexing in AsmLexer..
niravd added reviewers: rnk, loladiro.
niravd updated this object.
niravd added a subscriber: llvm-commits.
vchuravy removed a subscriber: vchuravy.
rnk added inline comments.Sep 30 2016, 10:07 AM
include/llvm/MC/MCParser/AsmLexer.h
30–35 ↗(On Diff #72201)

We should give all these scalars default member initializers and delete the assignments in the ctor.

lib/MC/MCParser/AsmLexer.cpp
496 ↗(On Diff #72201)

Do you think this would be improved with our SaveAndRestore<bool> RAII helper? Same for the rest of the saved local copies.

niravd updated this revision to Diff 73143.Sep 30 2016, 2:32 PM
niravd marked 2 inline comments as done.

cei
Resolve comments

rnk accepted this revision.Sep 30 2016, 3:15 PM
rnk edited edge metadata.

lgtm

include/llvm/MC/MCParser/AsmLexer.h
30–35 ↗(On Diff #72201)

No, I mean C++11 default member initializers, so we don't have to repeat all the scalar members in the ctor:

class AsmLexer ... {
  ...
  const char *CurPtr = nullptr;
  bool IsAtStartOfLine = true;
  bool IsPeeking = false;
  ...
This revision is now accepted and ready to land.Sep 30 2016, 3:15 PM
This revision was automatically updated to reflect the committed changes.