mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Add constructor to create MDString using std::string
llvm-svn: 74133
This commit is contained in:
parent
9832095b30
commit
715a8c1154
@ -865,6 +865,7 @@ public:
|
||||
/// get() - Static factory methods - Return objects of the specified value.
|
||||
///
|
||||
static MDString *get(const char *StrBegin, const char *StrEnd);
|
||||
static MDString *get(const std::string &Str);
|
||||
|
||||
/// size() - The length of this string.
|
||||
///
|
||||
|
@ -1803,6 +1803,17 @@ MDString *MDString::get(const char *StrBegin, const char *StrEnd) {
|
||||
return S;
|
||||
}
|
||||
|
||||
MDString *MDString::get(const std::string &Str) {
|
||||
sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
|
||||
StringMapEntry<MDString *> &Entry = MDStringCache->GetOrCreateValue(
|
||||
Str.data(), Str.data() + Str.size());
|
||||
MDString *&S = Entry.getValue();
|
||||
if (!S) S = new MDString(Entry.getKeyData(),
|
||||
Entry.getKeyData() + Entry.getKeyLength());
|
||||
|
||||
return S;
|
||||
}
|
||||
|
||||
void MDString::destroyConstant() {
|
||||
sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
|
||||
MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd));
|
||||
|
Loading…
Reference in New Issue
Block a user