diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2015-03-17 09:51:17 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2015-03-17 09:51:17 +0000 |
commit | 1ee89fc432ded040593e59844efa621b4189a7c3 (patch) | |
tree | 14eac32a31a8d2e7c2180ff3ecaa3830aeb93c5d /llvm/lib/MC/MCContext.cpp | |
parent | e458ab45774966c263817fdd63613faf28cf843c (diff) | |
download | bcm5719-llvm-1ee89fc432ded040593e59844efa621b4189a7c3.tar.gz bcm5719-llvm-1ee89fc432ded040593e59844efa621b4189a7c3.zip |
Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases.
http://reviews.llvm.org/D6372
llvm-svn: 232465
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 82f1da2c15f..608d958fc8e 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -98,13 +98,15 @@ void MCContext::reset() { // Symbol Manipulation //===----------------------------------------------------------------------===// -MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) { - assert(!Name.empty() && "Normal symbols cannot be unnamed!"); +MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) { + SmallString<128> NameSV; + StringRef NameRef = Name.toStringRef(NameSV); - MCSymbol *&Sym = Symbols[Name]; + assert(!NameRef.empty() && "Normal symbols cannot be unnamed!"); + MCSymbol *&Sym = Symbols[NameRef]; if (!Sym) - Sym = CreateSymbol(Name); + Sym = CreateSymbol(NameRef); return Sym; } @@ -168,11 +170,6 @@ MCSymbol *MCContext::createTempSymbol(const Twine &Name) { return CreateSymbol(NameSV); } -MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) { - SmallString<128> NameSV; - return GetOrCreateSymbol(Name.toStringRef(NameSV)); -} - MCSymbol *MCContext::CreateLinkerPrivateTempSymbol() { SmallString<128> NameSV; raw_svector_ostream(NameSV) |