[PATCH] D68586: Save a word in every StringSet entry

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 13:37:04 PDT 2019


dblaikie added a comment.

In D68586#1704684 <https://reviews.llvm.org/D68586#1704684>, @jordan_rose wrote:

> In D68586#1704530 <https://reviews.llvm.org/D68586#1704530>, @dblaikie wrote:
>
> > Any idea why MDString is friending an implementation detail like this? Should it be? Could we make it an actual private implementation detail so people can't do this?
>
>
> It's funky but I think reasonable: MDString is a move-none type since there will be direct pointers to it, and the canonical instance lives in the StringMap. Disallowing this friending would mean making MDString move-only and just assuming it'll never be misused.


Figured something like that. I think for standard containers, at least, that can now be achieved through a custom allocator ( https://en.cppreference.com/w/cpp/memory/allocator/construct - not sure why the non-default version was deprecated... well, one possible reason (below))

The other way to do it is with a private tagged parameter - have a private type in MDString, have a public ctor that takes an instance of that type as a parameter, and then no public user can call it because they can't name the type, but MDString's implementation can call into other code including templates that can handle that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68586/new/

https://reviews.llvm.org/D68586





More information about the llvm-commits mailing list