Use StringRef to construct MDString.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-10-22 00:22:05 +00:00
parent 7f23958aa4
commit 921bdaaa98
2 changed files with 4 additions and 3 deletions

View File

@ -57,8 +57,8 @@ class MDString : public MetadataBase {
StringRef Str;
protected:
explicit MDString(LLVMContext &C, const char *begin, unsigned l)
: MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(begin, l) {}
explicit MDString(LLVMContext &C, StringRef S)
: MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(S) {}
public:
static MDString *get(LLVMContext &Context, StringRef Str);

View File

@ -33,7 +33,8 @@ MDString *MDString::get(LLVMContext &Context, StringRef Str) {
MDString *&S = Entry.getValue();
if (S) return S;
return S = new MDString(Context, Entry.getKeyData(), Entry.getKeyLength());
return S =
new MDString(Context, StringRef(Entry.getKeyData(), Entry.getKeyLength()));
}
//===----------------------------------------------------------------------===//