This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Fix PointerEmbeddedInt when the underlying type is uintptr_t.
ClosedPublic

Authored by jordan_rose on Feb 12 2016, 11:58 AM.

Details

Reviewers
chandlerc
Summary

...and when you try to store negative values in it. Seems pretty straightforward.

(Background: I'm replacing uses of Swift's similar type Fixnum with PointerEmbeddedInt.)

Diff Detail

Event Timeline

jordan_rose retitled this revision from to [ADT] Fix PointerEmbeddedInt when the underlying type is uintptr_t. .
jordan_rose updated this object.
jordan_rose added a reviewer: chandlerc.
jordan_rose set the repository for this revision to rL LLVM.
jordan_rose added a subscriber: llvm-commits.
chandlerc added inline comments.Feb 12 2016, 12:39 PM
include/llvm/ADT/PointerEmbeddedInt.h
48–50

Rather than this, use an empty struct? That's a better tag type as it is literally not passed in the ABI, just changes the overload resolution at compile time.

The _t suffix is also not terribly common in LLVM. I'd go with 'RawValueTag' personally.

62–65

These isInt and isUInt predicates are... really confusingly named. "Of course its an integer! Oh, it's asserting how many bits are in the integer..."

Anyways, if you feel like it, maybe a follow-up patch to name these predicates better? Definitely not relevant for this patch.

unittests/ADT/PointerEmbeddedIntTest.cpp
53–54

Rather than all of the scopes, just use different names for the different types? Makes it much easier to read IMO.

jordan_rose added inline comments.Feb 12 2016, 12:49 PM
include/llvm/ADT/PointerEmbeddedInt.h
48–50

Good point. I was trying to avoid the weirdness of creating a nonce value, but that's doable with a constexpr member.

jordan_rose removed rL LLVM as the repository for this revision.

Updated to address feedback.

chandlerc accepted this revision.Feb 18 2016, 12:49 PM
chandlerc edited edge metadata.

LGTM

include/llvm/ADT/PointerEmbeddedInt.h
48–50

Watch for buildbot complaints about this constexpr. If necessary, I'd rather the good calling convention and a nonce value with a definition in the .cpp file than using enums. But hopefully this just works. =]

This revision is now accepted and ready to land.Feb 18 2016, 12:49 PM
jordan_rose closed this revision.Feb 18 2016, 1:28 PM

Committed in r261259 with a slightly more conservative RawValue definition. Will be watching bots.

Scaled back even further on being clever in r261268.