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 | b37f29b6f316ece56e3879c1e2560eb2c46ec372 (patch) | |
tree | 70f9a44e9f1afb64eeafb6287739e65bd880f427 /llvm/lib | |
parent | fc0264a38e3d2e24d5cd44a6f028e2283f8b71ca (diff) | |
download | bcm5719-llvm-b37f29b6f316ece56e3879c1e2560eb2c46ec372.tar.gz bcm5719-llvm-b37f29b6f316ece56e3879c1e2560eb2c46ec372.zip |
create sections with MCSection::Create instead of Context->getOrCreateSection.
This is needed to allow polymorphic sections.
llvm-svn: 77680
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 6c74dcd9ecf..5f3f1251696 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/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!"); |