From 337462b36512cc001891a98fb98fa5693651722f Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 11 Oct 2017 23:33:06 +0000 Subject: [ADT] Make Twine's copy constructor private. There's a lot of misuse of Twine scattered around LLVM. This ranges in severity from benign (returning a Twine from a function by value that is just a string literal) to pretty sketchy (storing a Twine by value in a class). While there are some uses for copying Twines, most of the very compelling ones are confined to the Twine class implementation itself, and other uses are either dubious or easily worked around. This patch makes Twine's copy constructor private, and fixes up all callsites. Differential Revision: https://reviews.llvm.org/D38767 llvm-svn: 315530 --- llvm/lib/Support/Twine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Support/Twine.cpp') diff --git a/llvm/lib/Support/Twine.cpp b/llvm/lib/Support/Twine.cpp index d17cd4e6643..bf434f34e43 100644 --- a/llvm/lib/Support/Twine.cpp +++ b/llvm/lib/Support/Twine.cpp @@ -120,12 +120,10 @@ void Twine::printOneChildRepr(raw_ostream &OS, Child Ptr, << Ptr.cString << "\""; break; case Twine::StdStringKind: - OS << "std::string:\"" - << Ptr.stdString << "\""; + OS << "std::string:\"" << *Ptr.stdString << "\""; break; case Twine::StringRefKind: - OS << "stringref:\"" - << Ptr.stringRef << "\""; + OS << "stringref:\"" << *Ptr.stringRef << "\""; break; case Twine::SmallStringKind: OS << "smallstring:\"" << *Ptr.smallString << "\""; -- cgit v1.2.3