This is an archive of the discontinued LLVM Phabricator instance.

Fix Mips Parser error reporting
ClosedPublic

Authored by niravd on May 4 2016, 12:20 PM.

Details

Summary

[mips] On error, ParseDirective should always return false to signify that the
directive was understood.

Diff Detail

Event Timeline

niravd updated this revision to Diff 56186.May 4 2016, 12:20 PM
niravd retitled this revision from to Fix Mips Parser error reporting.
niravd updated this object.
niravd added reviewers: dsanders, sdardis.
niravd added a subscriber: llvm-commits.
dsanders accepted this revision.May 5 2016, 2:49 AM
dsanders edited edge metadata.

LGTM with a few small changes.

Could you format this the way clang-format would? In particular there should be a space after the '//' in comments and before the '{' on the if-statements.

Could you also add a test case? Something that checks we don't emit the 'unknown directive' error for one of the incorrect directives is sufficient.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
4884

If they're going to have the same name then I agree that they should be consistent in behaviour. From their usage it looks like we ought to have both behaviours available so I think it's best to rename one of them. We should leave that for another patch though.

6039–6041

I disagree with this comment as it's written since most errors are reported because we didn't (fully) understand the directive. However, the caller of ParseDirective() phrases it as "It will return 'true' if it isn't interested in this directive." which I read as "it recognized the first token of the directive and decided to handle it". I think this is what you mean and I agree we don't comply with this at the moment.

I'm thinking it might be better phrased as something like:

This returns false if this function recognizes the directive regardless of whether it is successfully handled or reports an error. Otherwise it returns true to give the generic parser a chance at recognizing it.

This revision is now accepted and ready to land.May 5 2016, 2:49 AM
niravd marked 2 inline comments as done.May 5 2016, 7:09 AM
niravd added inline comments.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
4884

Either that or merge them into a single. Regardless, I've added a bit more text to be a bit clearer.

niravd updated this revision to Diff 56282.May 5 2016, 7:11 AM
niravd marked an inline comment as done.
niravd edited edge metadata.

Add test case and cleanup

This revision was automatically updated to reflect the committed changes.