From 454adf645480245725c74fdbe8840ceff039ef64 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 13 Jun 2015 12:49:52 +0000 Subject: Bring in a BumpPtrStringSaver from lld and simplify the interface. StringSaver now always saves to a BumpPtrAllocator. The only reason for having the virtual saveImpl is so lld can have a thread safe version. The reason for the distinct BumpPtrStringSaver class is to avoid the virtual destructor. llvm-svn: 239669 --- llvm/lib/Support/StringSaver.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 llvm/lib/Support/StringSaver.cpp (limited to 'llvm/lib/Support/StringSaver.cpp') diff --git a/llvm/lib/Support/StringSaver.cpp b/llvm/lib/Support/StringSaver.cpp new file mode 100644 index 00000000000..d6b84e53dcc --- /dev/null +++ b/llvm/lib/Support/StringSaver.cpp @@ -0,0 +1,19 @@ +//===-- StringSaver.cpp ---------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/StringSaver.h" + +using namespace llvm; + +const char *StringSaver::saveImpl(StringRef S) { + char *P = Alloc.Allocate(S.size() + 1); + memcpy(P, S.data(), S.size()); + P[S.size()] = '\0'; + return P; +} -- cgit v1.2.3