aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r--lib/MC/MCContext.cpp23
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!");