This is an archive of the discontinued LLVM Phabricator instance.

Fix a couple of self-assignments using memcpy.
ClosedPublic

Authored by hintonda on Nov 2 2017, 4:03 PM.

Details

Summary

These two methods are essentially assignents, but don't check
for self-assignment and use memcpy for member variables.

Since they aren't actually operator=(), it's unclear what should be done:

  • check and shortcut
  • assert
  • allow but s/memcpy/memmove/

Diff Detail

Repository
rL LLVM

Event Timeline

hintonda created this revision.Nov 2 2017, 4:03 PM
clayborg requested changes to this revision.Nov 13 2017, 10:11 AM

First change looks good. Second one we can probably avoid doing anything in Value::AppendDataToHostBuffer and return 0. No need to copy data over itself.

source/Core/Value.cpp
146–147 ↗(On Diff #121405)

Should probably return 0 if this == &rhs?

This revision now requires changes to proceed.Nov 13 2017, 10:11 AM
hintonda updated this revision to Diff 122730.Nov 13 2017, 2:26 PM
hintonda edited edge metadata.
  • Address comments.
clayborg accepted this revision.Nov 14 2017, 9:13 AM
This revision is now accepted and ready to land.Nov 14 2017, 9:13 AM
This revision was automatically updated to reflect the committed changes.