<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 22, 2016, at 9:30 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Tue, Mar 22, 2016 at 9:17 AM, David Blaikie<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Tue, Mar 22, 2016 at 9:02 AM, Mehdi AMINI via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">joker.eph added a comment.<br class=""><span class=""><br class="">> std::unordered_map::emplace returns the classic <iterator, bool> pair. Perhaps emplace_second should do the same? Rather than relying on being able to detect the invalid default constructed state of the key?<br class=""><br class=""><br class=""></span>I don't understand what you mean: `std::pair<iterator, bool> emplace_second(StringRef Key, ArgsTy &&... Args) `<br class=""></blockquote></span><div class=""><br class="">Right, to match/parallel with:<br class=""><br class=""><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 221); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">template</span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 128); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class=""><</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""> </span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 221); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">class</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class="">... </span><span style="line-height: 14.08px; margin: 0px; padding: 0px; font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">Args</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""> </span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 128); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">></span><br style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""><a href="http://en.cppreference.com/w/cpp/utility/pair" target="_blank" style="text-decoration: none; color: rgb(0, 48, 128); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap; background-image: none; background-repeat: initial initial;" class=""><span style="line-height: 1.1em; margin: 0px; padding: 0px;" class="">std::<span style="line-height: 1.1em; margin: 0px; padding: 0px;" class="">pair</span></span></a><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 128); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class=""><</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class="">iterator,</span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 255); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">bool</span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 128); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">></span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""> emplace</span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 128, 0); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">(</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""> Args</span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 0, 64); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">&&</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class="">... </span><span style="line-height: 14.08px; margin: 0px; padding: 0px; font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">args</span><span style="font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; line-height: 14.08px; white-space: nowrap;" class=""> </span><span style="line-height: 14.08px; margin: 0px; padding: 0px; color: rgb(0, 128, 0); font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-size: 12.8px; white-space: nowrap;" class="">)</span></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Sorry - my mistake, I see (as you pointed out on IRC) that emplace_second already returns the expected pair.<br class=""><br class="">I'd just hastily misread the code in MDString::get (seeing the access of the value before if test and then misread/assumed the value was used in the if test, instead of the bool in the pair - not an uncommon idiom (when the value has an obvious default value that's not valid for the use case))<br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""> </div><span class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class=""><br class=""><br class="">================<br class="">Comment at: include/llvm/IR/Metadata.h:595<br class="">@@ -594,3 +594,3 @@<br class="">   MDString() : Metadata(MDStringKind, Uniqued), Entry(nullptr) {}<br class="">-  MDString(MDString &&) : Metadata(MDStringKind, Uniqued) {}<br class="">+  MDString(MDString &&R) = default;<br class=""><br class="">----------------<br class=""></span><span class="">dblaikie wrote:<br class="">> Why do we need a move ctor at all if we're supporting emplace? Can we just delete it? (even if we omit it, it should be removed implicitly - same with the move assignment above, I think)<br class=""></span>StringMap requires movable types (for std::pair I think).<br class=""></blockquote><div class=""><br class=""></div></span><div class="">If we're supporting emplace, it's usually because the identity of the object is important from the moment of construction - so perhaps we should be making sure that identity is actually preserved, same as the standard emplace.<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Still interested in this ^</div></div></div></blockquote><div><br class=""></div><div>So, the move ctor is need by the StringMap for other purpose than emplace_second(). Here I fix the move ctor to be actually a move which it was not. </div><div>I could move this to a separate patch, the only reason it is here is that in the original implementation I had to make it public, and I moved it back to private but left the "implementation" change.</div><div><br class=""></div><div>-- </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""></div><span class=""><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class=""><div class=""><br class=""><br class=""><br class=""><a href="http://reviews.llvm.org/D17920" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D17920</a><br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></div></div></blockquote></span></div></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>