aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-25 04:41:11 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-25 04:41:11 +0000
commit6e0d1cb30957a636c53158d3089e6fb88348a57a (patch)
tree1efda7d33cf044d4f99e4a44fdfc6f9328671cc5
parenta66297af3048c9f03ae79d1995dc6bdecfbc46c0 (diff)
Initial update to VMCore to use Twines for string arguments.
- The only meat here is in Value.{h,cpp} the rest is essential 'const std::string &' -> 'const Twine &'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77048 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/ProgrammersManual.html106
-rw-r--r--docs/ReleaseNotes-2.6.html8
-rw-r--r--include/llvm/Argument.h3
-rw-r--r--include/llvm/BasicBlock.h6
-rw-r--r--include/llvm/Function.h4
-rw-r--r--include/llvm/GlobalValue.h4
-rw-r--r--include/llvm/GlobalVariable.h4
-rw-r--r--include/llvm/InstrTypes.h68
-rw-r--r--include/llvm/Instructions.h258
-rw-r--r--include/llvm/Value.h5
-rw-r--r--lib/Linker/LinkModules.cpp4
-rw-r--r--lib/Transforms/Scalar/GVNPRE.cpp3
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp6
-rw-r--r--lib/VMCore/BasicBlock.cpp4
-rw-r--r--lib/VMCore/Function.cpp4
-rw-r--r--lib/VMCore/Globals.cpp4
-rw-r--r--lib/VMCore/Instructions.cpp160
-rw-r--r--lib/VMCore/Value.cpp7
-rw-r--r--lib/VMCore/Verifier.cpp10
19 files changed, 392 insertions, 276 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index dba7213697..1931a68060 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -29,6 +29,12 @@
<ul>
<li><a href="#isa">The <tt>isa&lt;&gt;</tt>, <tt>cast&lt;&gt;</tt>
and <tt>dyn_cast&lt;&gt;</tt> templates</a> </li>
+ <li><a href="#string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</li>
+ <ul>
+ <li><a href="#StringRef">The <tt>StringRef</tt> class</a> </li>
+ <li><a href="#Twine">The <tt>Twine</tt> class</a> </li>
+ </ul>
<li><a href="#DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt>
option</a>
<ul>
@@ -424,6 +430,106 @@ are lots of examples in the LLVM source base.</p>
</div>
+
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</a>
+</div>
+
+<div class="doc_text">
+
+<p>Although LLVM generally does not do much string manipulation, we do have
+several important APIs which take string. Several important examples are the
+Value class -- which has names for instructions, functions, etc. -- and the
+StringMap class which is used extensively in LLVM and Clang.</p>
+
+<p>These are generic classes, and they need to be able to accept strings which
+may have embedded null characters. Therefore, they cannot simply take
+a <tt>const char *</tt>, and taking a <tt>const std::string&</tt> requires
+clients to perform a heap allocation which is usually unnecessary. Instead,
+many LLVM APIs use a <tt>const StringRef&</tt> or a <tt>const Twine&</tt> for
+passing strings efficiently.</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="StringRef">The <tt>StringRef</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>StringRef</tt> data type represents a reference to a constant string
+(a character array and a length) and supports the common operations available
+on <tt>std:string</tt>, but does not require heap allocation.</p>
+
+It can be implicitly constructed using either a C style null-terminated string
+or an <tt>std::string</tt>, or explicitly with a character pointer and length.
+For example, the <tt>StringRef</tt> find function is declared as:</p>
+<div class="doc_code">
+ iterator find(const StringRef &Key);
+</div>
+
+<p>and clients can call it using any one of:</p>
+
+<div class="doc_code">
+<pre>
+ Map.find("foo"); <i>// Lookup "foo"</i>
+ Map.find(std::string("bar")); <i>// Lookup "bar"</i>
+ Map.find(StringRef("\0baz", 4)); <i>// Lookup "\0baz"</i>
+</pre>
+</div>
+
+<p>Similarly, APIs which need to return a string may return a <tt>StringRef</tt>
+instance, which can be used directly or converted to an <tt>std::string</tt>
+using the <tt>str</tt> member function. See
+"<tt><a href="/doxygen/classllvm_1_1StringRef_8h-source.html">llvm/ADT/StringRef.h</a></tt>"
+for more information.</p>
+
+<p>You should rarely use the <tt>StringRef</tt> class directly, because it contains
+pointers to external memory it is not generally safe to store an instance of the
+class (since the external storage may be freed).</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="Twine">The <tt>Twine</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>Twine</tt> class is an efficient way for APIs to accept concatenated
+strings. For example, a common LLVM paradigm is to name one instruction based on
+the name of another instruction with a suffix, for example:</p>
+
+<div class="doc_code">
+<pre>
+ New = CmpInst::Create(<i>...</i>, SO->getName() + ".cmp");
+</pre>
+</div>
+
+<p>The <tt>Twine</tt> class is effectively a
+lightweight <a href="http://en.wikipedia.org/wiki/Rope_(computer_science)">rope</a>
+which points to temporary (stack allocated) objects. Twines can be implicitly
+constructed as the result of the plus operator applied to strings (i.e., a C
+strings, an <tt>std::string</tt>, or a <tt>StringRef</tt>). The twine delays the
+actual concatentation of strings until it is actually required, at which point
+it can be efficiently rendered directly into a character array. This avoids
+unnecessary heap allocation involved in constructing the temporary results of
+string concatenation. See
+"<tt><a href="/doxygen/classllvm_1_1Twine_8h-source.html">llvm/ADT/Twine.h</a></tt>"
+for more information.</p></tt>
+
+<p>As with a <tt>StringRef</tt>, <tt>Twine</tt> objects point to external memory
+and should almost never be stored or mentioned directly. They are intended
+solely for use when defining a function which should be able to efficiently
+accept concatenated strings.</p>
+
+</div>
+
+
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt> option</a>
diff --git a/docs/ReleaseNotes-2.6.html b/docs/ReleaseNotes-2.6.html
index f1b8852fe0..b6b6724e98 100644
--- a/docs/ReleaseNotes-2.6.html
+++ b/docs/ReleaseNotes-2.6.html
@@ -460,8 +460,14 @@ API changes are:</p>
<li><tt>SCEVHandle</tt> no longer exists, because reference counting is no
longer done for <tt>SCEV*</tt> objects, instead <tt>const SCEV*</tt> should be
used.</li>
+<li>Many APIs, notably <tt>llvm::Value</tt>, now use the <tt>StringRef</tt>
+and <tt>Twine</tt> classes instead of passing <tt>const char*</tt>
+or <tt>std::string</tt>, as described in
+the <a href="ProgrammersManual.html#string_apis">Programmer's Manual</a>. Most
+clients should be uneffected by this transition.</li>
<li>llvm-dis now fails if output file exists, instead of dumping to stdout.
-FIXME: describe any other tool changes due to the raw_fd_ostream change</li>
+FIXME: describe any other tool changes due to the raw_fd_ostream change. FIXME:
+This is not an API change, maybe there should be a tool changes section?</li>
<li>temporarely due to Context API change passes should call doInitialization()
method of the pass they inherit from, otherwise Context is NULL.
FIXME: remove this entry when this is no longer needed.<li>
diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h
index 9c06367798..3a846c2899 100644
--- a/include/llvm/Argument.h
+++ b/include/llvm/Argument.h
@@ -38,8 +38,7 @@ public:
/// Argument ctor - If Function argument is specified, this argument is
/// inserted at the end of the argument list for the function.
///
- explicit Argument(const Type *Ty, const std::string &Name = "",
- Function *F = 0);
+ explicit Argument(const Type *Ty, const Twine &Name = "", Function *F = 0);
inline const Function *getParent() const { return Parent; }
inline Function *getParent() { return Parent; }
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index a20309fa84..eabc1a0d2b 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -83,7 +83,7 @@ private:
/// is automatically inserted at either the end of the function (if
/// InsertBefore is null), or before the specified basic block.
///
- explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
+ explicit BasicBlock(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0);
public:
/// getContext - Get the context in which this basic block lives,
@@ -97,7 +97,7 @@ public:
/// Create - Creates a new BasicBlock. If the Parent parameter is specified,
/// the basic block is automatically inserted at either the end of the
/// function (if InsertBefore is 0), or before the specified basic block.
- static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
+ static BasicBlock *Create(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0) {
return new BasicBlock(Name, Parent, InsertBefore);
}
@@ -232,7 +232,7 @@ public:
/// cause a degenerate basic block to be formed, having a terminator inside of
/// the basic block).
///
- BasicBlock *splitBasicBlock(iterator I, const std::string &BBName = "");
+ BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "");
};
} // End llvm namespace
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 3bf65ff475..57ebfb10a5 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -114,11 +114,11 @@ private:
/// the module.
///
Function(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0);
+ const Twine &N = "", Module *M = 0);
public:
static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0) {
+ const Twine &N = "", Module *M = 0) {
return new(0) Function(Ty, Linkage, N, M);
}
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index b897f9f6bb..d53d49bfec 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -56,10 +56,10 @@ public:
protected:
GlobalValue(const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps,
- LinkageTypes linkage, const std::string &name = "")
+ LinkageTypes linkage, const Twine &Name = "")
: Constant(ty, vty, Ops, NumOps), Parent(0),
Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) {
- if (!name.empty()) setName(name);
+ setName(Name);
}
Module *Parent;
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index 28eaa624e9..f18554d53b 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -52,13 +52,13 @@ public:
/// automatically inserted into the end of the specified modules global list.
GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant,
LinkageTypes Linkage,
- Constant *Initializer = 0, const std::string &Name = "",
+ Constant *Initializer = 0, const Twine &Name = "",
bool ThreadLocal = false, unsigned AddressSpace = 0);
/// GlobalVariable ctor - This creates a global and inserts it before the
/// specified other global.
GlobalVariable(Module &M, const Type *Ty, bool isConstant,
LinkageTypes Linkage, Constant *Initializer,
- const std::string &Name,
+ const Twine &Name,
GlobalVariable *InsertBefore = 0, bool ThreadLocal = false,
unsigned AddressSpace = 0);
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index c3c48af53f..43fe664003 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -144,9 +144,9 @@ class BinaryOperator : public Instruction {
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore);
+ const Twine &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
@@ -162,7 +162,7 @@ public:
/// Instruction is allowed to be a dereferenced end iterator.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name = "",
+ const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Create() - Construct a binary instruction, given the opcode and the two
@@ -170,27 +170,26 @@ public:
/// BasicBlock specified.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
- BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
/// Create* - These methods just forward to Create, and are useful when you
/// statically know what type of instruction you're going to create. These
/// helpers just save some typing.
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name = "") {\
+ const Twine &Name = "") {\
return Create(Instruction::OPC, V1, V2, Name);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, BasicBlock *BB) {\
+ const Twine &Name, BasicBlock *BB) {\
return Create(Instruction::OPC, V1, V2, Name, BB);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, Instruction *I) {\
+ const Twine &Name, Instruction *I) {\
return Create(Instruction::OPC, V1, V2, Name, I);\
}
#include "llvm/Instruction.def"
@@ -203,22 +202,22 @@ public:
/// instructions out of SUB and XOR instructions.
///
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
/// isNeg, isFNeg, isNot - Check if the given Value is a
@@ -288,13 +287,13 @@ class CastInst : public UnaryInstruction {
protected:
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr = "", Instruction *InsertBefore = 0)
+ const Twine &NameStr = "", Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, iType, S, InsertBefore) {
setName(NameStr);
}
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, iType, S, InsertAtEnd) {
setName(NameStr);
}
@@ -309,7 +308,7 @@ public:
Instruction::CastOps, ///< The opcode of the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
/// Provides a way to construct any of the CastInst subclasses using an
@@ -322,7 +321,7 @@ public:
Instruction::CastOps, ///< The opcode for the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -330,7 +329,7 @@ public:
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -338,7 +337,7 @@ public:
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -346,7 +345,7 @@ public:
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -354,7 +353,7 @@ public:
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -362,7 +361,7 @@ public:
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -370,7 +369,7 @@ public:
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -379,7 +378,7 @@ public:
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -388,7 +387,7 @@ public:
Value *S, ///< The integer value to be casted (operand 0)
const Type *Ty, ///< The integer type to which operand is casted
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -396,7 +395,7 @@ public:
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -404,7 +403,7 @@ public:
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -412,7 +411,7 @@ public:
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -420,7 +419,7 @@ public:
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -520,11 +519,11 @@ class CmpInst: public Instruction {
CmpInst(); // do not implement
protected:
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name = "",
+ Value *LHS, Value *RHS, const Twine &Name = "",
Instruction *InsertBefore = 0);
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
@@ -579,7 +578,7 @@ public:
/// @brief Create a CmpInst
static CmpInst *Create(LLVMContext &Context, OtherOps Op,
unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name = "",
+ Value *S2, const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Construct a compare instruction, given the opcode, the predicate and the
@@ -587,8 +586,7 @@ public:
/// the BasicBlock specified.
/// @brief Create a CmpInst
static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name,
- BasicBlock *InsertAtEnd);
+ Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
/// @brief Get the opcode casted to the right type
OtherOps getOpcode() const {
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 1afcc5fc05..2b53fac465 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -41,10 +41,10 @@ class LLVMContext;
class AllocationInst : public UnaryInstruction {
protected:
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name = "",
+ unsigned iTy, unsigned Align, const Twine &Name = "",
Instruction *InsertBefore = 0);
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name,
+ unsigned iTy, unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
// Out of line virtual method, so the vtable, etc. has a home.
@@ -102,28 +102,28 @@ class MallocInst : public AllocationInst {
MallocInst(const MallocInst &MI);
public:
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Malloc,
0, NameStr, InsertBefore) {}
MallocInst(const Type *Ty, Value *ArraySize,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc,
Align, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize,
Malloc, Align, NameStr, InsertBefore) {}
@@ -152,29 +152,29 @@ class AllocaInst : public AllocationInst {
public:
explicit AllocaInst(const Type *Ty,
Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
0, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty,
- Value *ArraySize, const std::string &NameStr,
+ Value *ArraySize, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertAtEnd) {}
@@ -246,15 +246,15 @@ class LoadInst : public UnaryInstruction {
}
void AssertOK();
public:
- LoadInst(Value *Ptr, const std::string &NameStr, Instruction *InsertBefore);
- LoadInst(Value *Ptr, const std::string &NameStr, BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile = false,
+ LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
+ LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
@@ -399,12 +399,12 @@ static inline const Type *checkType(const Type *Ty) {
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(Value *Ptr, Value *Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(Value *Ptr, Value *Idx, const Twine &NameStr);
template<typename InputIterator>
void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -451,25 +451,25 @@ class GetElementPtrInst : public Instruction {
inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// Constructors - These two constructors are convenience methods because one
/// and two index getelementptr instructions are so common.
- GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &NameStr = "",
+ GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
@@ -479,7 +479,7 @@ public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,