mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-01 10:57:21 +00:00
Use Twine, instead of StringRef, for consistency.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
26028f27dd
commit
d77fdba573
@ -194,10 +194,10 @@ class NamedMDNode : public Value, public ilist_node<NamedMDNode> {
|
|||||||
|
|
||||||
void setParent(Module *M) { Parent = M; }
|
void setParent(Module *M) { Parent = M; }
|
||||||
protected:
|
protected:
|
||||||
explicit NamedMDNode(LLVMContext &C, StringRef N, MDNode*const *Vals,
|
explicit NamedMDNode(LLVMContext &C, const Twine &N, MDNode*const *Vals,
|
||||||
unsigned NumVals, Module *M = 0);
|
unsigned NumVals, Module *M = 0);
|
||||||
public:
|
public:
|
||||||
static NamedMDNode *Create(LLVMContext &C, StringRef N,
|
static NamedMDNode *Create(LLVMContext &C, const Twine &N,
|
||||||
MDNode *const *MDs,
|
MDNode *const *MDs,
|
||||||
unsigned NumMDs, Module *M = 0) {
|
unsigned NumMDs, Module *M = 0) {
|
||||||
return new NamedMDNode(C, N, MDs, NumMDs, M);
|
return new NamedMDNode(C, N, MDs, NumMDs, M);
|
||||||
@ -229,7 +229,7 @@ public:
|
|||||||
void addOperand(MDNode *M);
|
void addOperand(MDNode *M);
|
||||||
|
|
||||||
/// setName - Set the name of this named metadata.
|
/// setName - Set the name of this named metadata.
|
||||||
void setName(StringRef Name);
|
void setName(const Twine &NewName);
|
||||||
|
|
||||||
/// getName - Return a constant reference to this named metadata's name.
|
/// getName - Return a constant reference to this named metadata's name.
|
||||||
StringRef getName() const;
|
StringRef getName() const;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "SymbolTableListTraitsImpl.h"
|
#include "SymbolTableListTraitsImpl.h"
|
||||||
#include "llvm/Support/ValueHandle.h"
|
#include "llvm/Support/ValueHandle.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -263,7 +264,7 @@ static SmallVector<WeakVH, 4> &getNMDOps(void *Operands) {
|
|||||||
return *(SmallVector<WeakVH, 4>*)Operands;
|
return *(SmallVector<WeakVH, 4>*)Operands;
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedMDNode::NamedMDNode(LLVMContext &C, StringRef N,
|
NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N,
|
||||||
MDNode *const *MDs,
|
MDNode *const *MDs,
|
||||||
unsigned NumMDs, Module *ParentModule)
|
unsigned NumMDs, Module *ParentModule)
|
||||||
: Value(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) {
|
: Value(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) {
|
||||||
@ -322,11 +323,23 @@ void NamedMDNode::dropAllReferences() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// setName - Set the name of this named metadata.
|
/// setName - Set the name of this named metadata.
|
||||||
void NamedMDNode::setName(StringRef N) {
|
void NamedMDNode::setName(const Twine &NewName) {
|
||||||
assert (!N.empty() && "Invalid named metadata name!");
|
assert (!NewName.isTriviallyEmpty() && "Invalid named metadata name!");
|
||||||
Name = N.str();
|
|
||||||
|
SmallString<256> NameData;
|
||||||
|
NewName.toVector(NameData);
|
||||||
|
|
||||||
|
const char *NameStr = NameData.data();
|
||||||
|
unsigned NameLen = NameData.size();
|
||||||
|
|
||||||
|
StringRef NameRef = StringRef(NameStr, NameLen);
|
||||||
|
// Name isn't changing?
|
||||||
|
if (getName() == NameRef)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Name = NameRef.str();
|
||||||
if (Parent)
|
if (Parent)
|
||||||
Parent->getMDSymbolTable().insert(N, this);
|
Parent->getMDSymbolTable().insert(NameRef, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getName - Return a constant reference to this named metadata's name.
|
/// getName - Return a constant reference to this named metadata's name.
|
||||||
|
Loading…
Reference in New Issue
Block a user