Get rid of dead code: SelectAtomic64 in X86ISelDAGtoDAG.cpp
[oota-llvm.git] / include / llvm / Support / StringSaver.h
1 //===- llvm/Support/StringSaver.h - Stable storage for strings --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_SUPPORT_STRINGSAVER_H
11 #define LLVM_SUPPORT_STRINGSAVER_H
12
13 #include "llvm/Support/Allocator.h"
14 #include <cstring>
15
16 namespace llvm {
17
18 /// \brief Saves strings in stable storage that it owns.
19 class StringSaver {
20   BumpPtrAllocator Alloc;
21
22 public:
23   const char *saveCStr(const char *CStr) {
24     auto Len = std::strlen(CStr) + 1; // Don't forget the NUL!
25     char *Buf = Alloc.Allocate<char>(Len);
26     std::memcpy(Buf, CStr, Len);
27     return Buf;
28   }
29 };
30
31 } // end namespace llvm
32
33 #endif