This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Add error messages
ClosedPublic

Authored by Flakebi on Jun 3 2020, 3:02 AM.

Details

Summary

Print an error instead of crashing in two places.

If someone has a better error message for the first case, I would be glad to use it.

Diff Detail

Event Timeline

Flakebi created this revision.Jun 3 2020, 3:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2020, 3:02 AM
dsanders added inline comments.Jun 3 2020, 9:25 AM
llvm/utils/TableGen/SearchableTableEmitter.cpp
121–128

This one makes sense to me. The return statement ought to be updated to use Entry though:
return std::string(Entry->first)

602–604

I'm not sure this one should really be an error as having an empty table doesn't seem wrong as such. It probably wasn't intentional though so maybe a warning makes sense.

What breaks if the table is empty?

Flakebi updated this revision to Diff 268395.Jun 4 2020, 2:27 AM

Thank you for the fast review!

What breaks if the table is empty?

In the case where I encountered it, the types cannot be determined because the for loop is never executed and it crashed below, trying to access null types.
I guess you are right that empty tables can work if all types are specified, so I changed it to a warning as you suggested and throw a fatal error only if a type does not exist.

ping for review

friendly ping

This revision is now accepted and ready to land.Jun 22 2020, 9:56 AM
This revision was automatically updated to reflect the committed changes.