This is an archive of the discontinued LLVM Phabricator instance.

TableGen: More helpful error messages
ClosedPublic

Authored by nhaehnle on Mar 5 2018, 12:18 PM.

Details

Summary

Change-Id: Ic78afd0cd765fdb4cf1b7ecfb6bba22653ce6d29

Diff Detail

Event Timeline

nhaehnle created this revision.Mar 5 2018, 12:18 PM
tra accepted this revision.Mar 5 2018, 7:15 PM

One nit. LGTM otherwise.

lib/TableGen/Record.cpp
1839

You are constructing a std::string only to use it to build another Twine. Why not just use Twine here?

This revision is now accepted and ready to land.Mar 5 2018, 7:15 PM
nhaehnle added inline comments.Mar 7 2018, 2:10 AM
lib/TableGen/Record.cpp
1839

Because of Twine lifetime limitations. Twine works by chaining together temporary node objects to represent the string concatenations. So changing Type to type Twine can't work, because the temporary node objects would be destroyed again immediately, before they are passed to PrintFatalError.

(The compiler actually prevents attempts to do this, since Twine::operator= is deleted.)

I think it would work to "inline" Type in the argument to PrintFatalError, guarding it with a ternary ?: operator, but that seemed uglier to me.

tra added inline comments.Mar 7 2018, 10:07 AM
lib/TableGen/Record.cpp
1839

Thank you for the explanation. Reading ADT/Twine.h was enlightening. Now std::string makes sense to me.

nhaehnle closed this revision.Mar 14 2018, 3:47 AM

r327118