[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 29 14:09:43 PDT 2018

NoQ added a comment.

In https://reviews.llvm.org/D51393#1217644, @aprantl wrote:

> Just for consideration: The raw pointers in dumps are sometimes useful while in a debugger session, because you can cast a pointer and dump the object in the debugger.

Yup, i use that as well from time to time, so i guess we can either dump both or make a flag.

Comment at: llvm/include/llvm/Support/Allocator.h:290
+  /// Returns an empty optional if the pointer is not found in the allocator.
+  llvm::Optional<std::pair<size_t, long>> identifyObject(const void *Ptr) {
+    const char *P = reinterpret_cast<const char *>(Ptr);
I'd much rather have the first element signed, because it's the only one that can actually carry "negative" values. Maybe just let's do two `int64_t`s or `intptr_t`s?

Comment at: llvm/include/llvm/Support/Allocator.h:295
+      if (P >= S && P < S + computeSlabSize(Idx))
+        return std::make_pair(Idx, P - S);
+    }
aprantl wrote:
> `return {Idx, P - S};`
And, well, let's make integral casts explicit here.


More information about the cfe-commits mailing list