diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-10 01:29:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-10 01:29:27 +0000 |
commit | 00685bb5cf791fcda9fa0ceb42a6a62a07478461 (patch) | |
tree | 5fa431cebcf1afd74051ff7d85a0fa179e6cebed /lib/MC/MCContext.cpp | |
parent | d85fc6e0b1750907bacf1cd7309e85e777b23a4d (diff) |
eliminate MCContext::CreateSymbol and CreateTemporarySymbol.
Add a new GetOrCreateTemporarySymbol method and a version that
takes a twine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r-- | lib/MC/MCContext.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 45d2c02536..63264f63c4 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -23,16 +23,8 @@ MCContext::~MCContext() { // we don't need to free them here. } -MCSymbol *MCContext::CreateSymbol(StringRef Name) { - assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!"); - - // Create and bind the symbol, and ensure that names are unique. - MCSymbol *&Entry = Symbols[Name]; - assert(!Entry && "Duplicate symbol definition!"); - return Entry = new (*this) MCSymbol(Name, false); -} - MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) { + assert(!Name.empty() && "Normal symbols cannot be unnamed!"); MCSymbol *&Entry = Symbols[Name]; if (Entry) return Entry; @@ -46,17 +38,24 @@ MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) { } -MCSymbol *MCContext::CreateTemporarySymbol(StringRef Name) { +MCSymbol *MCContext::GetOrCreateTemporarySymbol(StringRef Name) { // If unnamed, just create a symbol. if (Name.empty()) new (*this) MCSymbol("", true); // Otherwise create as usual. MCSymbol *&Entry = Symbols[Name]; - assert(!Entry && "Duplicate symbol definition!"); + if (Entry) return Entry; return Entry = new (*this) MCSymbol(Name, true); } +MCSymbol *MCContext::GetOrCreateTemporarySymbol(const Twine &Name) { + SmallString<128> NameSV; + Name.toVector(NameSV); + return GetOrCreateTemporarySymbol(NameSV.str()); +} + + MCSymbol *MCContext::LookupSymbol(StringRef Name) const { return Symbols.lookup(Name); } |