diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-31 16:43:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-31 16:43:49 +0000 |
commit | fcdbf4ecc33d6d9a197c88ac06218741a9228375 (patch) | |
tree | 7f0fda95732aa8d3fd7e751f8ca5825313203209 /lib/MC/MCContext.cpp | |
parent | 82987bfe9b6ae85a8836c9f2d2e9f0ef9866edb1 (diff) |
create sections with MCSection::Create instead of Context->getOrCreateSection.
This is needed to allow polymorphic sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77680 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r-- | lib/MC/MCContext.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 6c74dcd9ec..5f3f125169 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -14,22 +14,29 @@ #include "llvm/MC/MCValue.h" using namespace llvm; -MCContext::MCContext() -{ +MCContext::MCContext() { } MCContext::~MCContext() { } -MCSection *MCContext::GetSection(const StringRef &Name) { - MCSection *&Entry = Sections[Name]; - - if (!Entry) - Entry = new (*this) MCSection(Name); +MCSection *MCContext::GetSection(const StringRef &Name) const { + StringMap<MCSection*>::const_iterator I = Sections.find(Name); + return I != Sections.end() ? I->second : 0; +} + - return Entry; +MCSection::MCSection(const StringRef &_Name, MCContext &Ctx) : Name(_Name) { + MCSection *&Entry = Ctx.Sections[Name]; + assert(Entry == 0 && "Multiple sections with the same name created"); + Entry = this; } +MCSection *MCSection::Create(const StringRef &Name, MCContext &Ctx) { + return new (Ctx) MCSection(Name, Ctx); +} + + MCSymbol *MCContext::CreateSymbol(const StringRef &Name) { assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!"); |