mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
19
lib/Support/StringSaver.cpp
Normal file
19
lib/Support/StringSaver.cpp
Normal file
@@ -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<char>(S.size() + 1);
|
||||
memcpy(P, S.data(), S.size());
|
||||
P[S.size()] = '\0';
|
||||
return P;
|
||||
}
|
Reference in New Issue
Block a user