This is an archive of the discontinued LLVM Phabricator instance.

Enable comparison between OperationName and StringLiteral (NFC)
Needs ReviewPublic

Authored by mehdi_amini on Jul 2 2021, 8:46 PM.

Details

Reviewers
jpienaar
rriddle
Summary

This allows to write:

if (op->getName() == "some.op")

instead of

if (op->getName().getStringRef() == "some.op")

Diff Detail

Event Timeline

mehdi_amini created this revision.Jul 2 2021, 8:46 PM
mehdi_amini requested review of this revision.Jul 2 2021, 8:46 PM

Isn't this a bit of a feature that doing the string comparison needs to be explicit? It is less efficient than the compares currently exposed. Well modulo getting an Identifier requires adding it to context, but the user has control and the choice is explicit. Would a wrapper class work here to both make the writing simpler and (potentially) cache for efficient further checking post first hit?

This revision is now accepted and ready to land.Jul 3 2021, 8:07 AM
This revision now requires review to proceed.Jul 3 2021, 8:21 PM