[PATCH] D83305: [ADT] Fix join_impl using the wrong size when calculating total length
Nathan James via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 03:37:02 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGceb9379a90f5: [ADT] Fix join_impl using the wrong size when calculating total length (authored by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83305/new/
https://reviews.llvm.org/D83305
Files:
llvm/include/llvm/ADT/StringExtras.h
Index: llvm/include/llvm/ADT/StringExtras.h
===================================================================
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -384,13 +384,16 @@
size_t Len = (std::distance(Begin, End) - 1) * Separator.size();
for (IteratorT I = Begin; I != End; ++I)
- Len += (*Begin).size();
+ Len += I->size();
S.reserve(Len);
+ size_t PrevCapacity = S.capacity();
+ (void)PrevCapacity;
S += (*Begin);
while (++Begin != End) {
S += Separator;
S += (*Begin);
}
+ assert(PrevCapacity == S.capacity() && "String grew during building");
return S;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83305.316360.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210113/99739233/attachment.bin>
More information about the llvm-commits
mailing list