[Lldb-commits] [PATCH] D58167: Refactor user/group name resolving code

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 15 11:19:52 PST 2019


jingham added inline comments.


================
Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:439
   if (uid != UINT32_MAX) {
-    std::string name;
-    if (HostInfo::LookupUserName(uid, name)) {
+    if (auto name = HostInfo::GetUserIDResolver().GetUserName(uid)) {
       StreamString response;
----------------
labath wrote:
> jingham wrote:
> > Do we need auto here?  Since we have a bunch of API's returning StringRef's now when I see strings returned I get paranoid about their lifespan.  auto hides the fact that I don't need to worry...
> I've removed the auto, though I am not sure if that alleviates your fears, as the returned type is StringRef. There is still nothing to worry about though, as the backing storage is held by the resolver object.
So how do I reason about the lifespan of this StringRef, then?  Now I have to know that GetUserIDResolver doesn't make a temporary UserIDResolver, but a reference to one that persists - for how long again?


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

https://reviews.llvm.org/D58167





More information about the lldb-commits mailing list