Avoid keeping internal string_views in Twine.
authorSterling Augustine <saugustine@google.com>
Fri, 16 Jul 2021 20:17:16 +0000 (13:17 -0700)
committerSterling Augustine <saugustine@google.com>
Tue, 20 Jul 2021 15:46:53 +0000 (08:46 -0700)
commitbbbc4f110e35ac709b943efaa1c4c99ec073da30
treea54ae0a13daebf236d4afd81ad9d29552b3ae79c
parent84877a098ab065ca2e3775ea4c69b22cae0403b1
Avoid keeping internal string_views in Twine.

This is a follow-up to https://reviews.llvm.org/D103935

A Twine's internal layout should not depend on which version of the
C++ standard is in use. Dynamically linking binaries compiled with two
different layouts (eg, --std=c++14 vs --std=c++17) ends up
problematic.

This change avoids that issue by immediately converting a
string_view to a pointer-and-length at the cost of an extra eight-bytes
in Twine.

Differential Revision: https://reviews.llvm.org/D106186
llvm/include/llvm/ADT/Twine.h
llvm/lib/Support/Twine.cpp
llvm/unittests/ADT/TwineTest.cpp