<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 25, 2016, at 10:05 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 Fri, Mar 25, 2016 at 9:36 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;">Author: mehdi_amini<br class="">Date: Fri Mar 25 11:36:00 2016<br class="">New Revision: 264418<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=264418&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=264418&view=rev</a><br class="">Log:<br class="">Improve StringMap unittests: reintroduce move count, but shield against std::pair internals<br class=""><br class="">From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>><br class=""><br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/unittests/ADT/StringMapTest.cpp<br class=""><br class="">Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=264418&r1=264417&r2=264418&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=264418&r1=264417&r2=264418&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)<br class="">+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Fri Mar 25 11:36:00 2016<br class="">@@ -391,14 +391,21 @@ TEST(StringMapCustomTest, InitialSizeTes<br class=""> for (auto Size : {1, 32, 67}) {<br class=""> StringMap<CountCtorCopyAndMove> Map(Size);<br class=""> auto NumBuckets = Map.getNumBuckets();<br class="">+<br class="">+ // Prepare the elts in a vector. We do this as a pre-step to shield us<br class="">+ // against the internals of std::pair which can introduce spurious move/copy<br class="">+ std::vector<std::pair<std::string, CountCtorCopyAndMove>> Elts;<br class="">+ for (int i = 0; i < Size; ++i)<br class="">+ Elts.emplace_back(Twine(i).str(), CountCtorCopyAndMove());<br class="">+<br class=""> CountCtorCopyAndMove::Move = 0;<br class=""> CountCtorCopyAndMove::Copy = 0;<br class=""> for (int i = 0; i < Size; ++i)<br class="">- Map.insert(std::make_pair(Twine(i).str(), CountCtorCopyAndMove()));<br class="">- // This relies on move-construction elision, and cannot be reliably tested.<br class="">- // EXPECT_EQ((unsigned)Size * 3, CountCtorCopyAndMove::Move);<br class="">- // No copy is expected.<br class="">- EXPECT_EQ(0u, CountCtorCopyAndMove::Copy);<br class="">+ Map.insert(Elts[i]);<br class=""></blockquote><div class=""><br class="">TBH I'd probably favor the piecewise_construct option - seems (to me) to be a more direct representation of what's required, avoids extra storage, complexity, etc, no?<br class=""></div></div></div></blockquote><div><br class=""></div><div>Have a look at r264475 and let me know!</div><div><br class=""></div><div>-- </div><div>Mehdi</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;">+ // After the inital copy, the map will move the Elts in the Entry.<br class="">+ EXPECT_EQ((unsigned)Size, CountCtorCopyAndMove::Move);<br class="">+ // We copy once the pair from the Elts vector<br class="">+ EXPECT_EQ((unsigned)Size, CountCtorCopyAndMove::Copy);<br class=""> // Check that the map didn't grow<br class=""> EXPECT_EQ(Map.getNumBuckets(), NumBuckets);<br class=""> }<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" 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></blockquote></div></div></blockquote></div><br class=""></body></html>