This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Add support for compound assignment for ChangeStatus
ClosedPublic

Authored by tianshilei1992 on Jul 15 2021, 4:28 PM.

Details

Summary

A common use of ChangeStatus is as follows:

ChangeStatus Changed = ChangeStatus::UNCHANGED;
Changed |= foo();

where foo returns ChangeStatus as well. Currently ChangeStatus doesn't
support compound assignment, we have to write as

Changed = Changed | foo();

which is not that convenient.

This patch add the support for compound assignment for ChangeStatus. Compound
assignment is usually implemented as a member function, and binary arithmetic
operator is therefore implemented using compound assignment. However, unlike
regular C++ class, enum class doesn't support member functions. As a result, they
can only be implemented in the way shown in the patch.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jul 15 2021, 4:28 PM
tianshilei1992 requested review of this revision.Jul 15 2021, 4:28 PM
Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert accepted this revision.Jul 15 2021, 4:57 PM

LG

Can you update the AttributorAttributes.cpp file too?

This revision is now accepted and ready to land.Jul 15 2021, 4:57 PM

Can you update the AttributorAttributes.cpp file too?

Didn't find any similar usage in AttributorAttributes.cpp?

This revision was landed with ongoing or failed builds.Jul 15 2021, 8:51 PM
This revision was automatically updated to reflect the committed changes.