This is an archive of the discontinued LLVM Phabricator instance.

[MC] Cleanup Error Handling in AsmParser
ClosedPublic

Authored by niravd on Jul 13 2016, 12:00 PM.

Details

Summary

Add parseToken and compatriot functions to stitch error checks in
straight linear code. As part of this fix some erronous handling of
directives where the EndOfStatement token either was not checked or
Lexed on termination.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd updated this revision to Diff 63839.Jul 13 2016, 12:00 PM
niravd retitled this revision from to [MC] Cleanup Assembly directive parsing handling of newlines.
niravd added reviewers: rnk, majnemer.
niravd updated this object.
niravd added a subscriber: llvm-commits.
rnk added inline comments.Jul 13 2016, 12:34 PM
lib/MC/MCParser/AsmParser.cpp
2991–2993 ↗(On Diff #63839)

I'm surprised the MCParser doesn't have something like LLParser::ParseToken, which consumes the expected token if present and returns an error if not present.

Can you add that and use it?

niravd updated this revision to Diff 64182.Jul 15 2016, 12:33 PM
niravd marked an inline comment as done.

Add parseToken and obvious compatriot functions

niravd retitled this revision from [MC] Cleanup Assembly directive parsing handling of newlines to [MC] Cleanup Error Handling in AsmParser.Jul 15 2016, 12:34 PM
niravd updated this object.
rnk accepted this revision.Jul 15 2016, 1:19 PM
rnk edited edge metadata.

lgtm

Thanks!

lib/MC/MCParser/AsmParser.cpp
254 ↗(On Diff #64182)

Prevailing local conventions would make these and the 'i' local below upper case.

334 ↗(On Diff #64182)

upper case local variable names

lib/MC/MCParser/ELFAsmParser.cpp
634 ↗(On Diff #64182)

This can be parseToken, right?

This revision is now accepted and ready to land.Jul 15 2016, 1:19 PM
niravd marked an inline comment as done.Jul 15 2016, 1:33 PM
niravd added inline comments.
lib/MC/MCParser/ELFAsmParser.cpp
634 ↗(On Diff #64182)

Yes. I'm planning on doing a cleanup sweep of each of the AsmParser files in subsequent patches.

This revision was automatically updated to reflect the committed changes.