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.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index 23ec0bb12d..d206dd9f50 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -21,6 +21,7 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h"
using namespace llvm;
@@ -32,13 +33,15 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
const MCObjectFileInfo *mofi, const SourceMgr *mgr,
- bool DoAutoInitializationFinalization ) :
+ bool DoAutoReset ) :
SrcMgr(mgr), MAI(mai), MRI(mri), MOFI(mofi),
Allocator(), Symbols(Allocator), UsedNames(Allocator),
NextUniqueID(0),
- CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
- AllowTemporaryLabels(true),
- AutoInitializationFinalization(DoAutoInitializationFinalization) {
+ CompilationDir(llvm::sys::Path::GetCurrentDirectory().str()),
+ CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
+ DwarfLocSeen(false), GenDwarfForAssembly(false), GenDwarfFileNumber(0),
+ AllowTemporaryLabels(true), AutoReset(DoAutoReset) {
+
MachOUniquingMap = 0;
ELFUniquingMap = 0;
COFFUniquingMap = 0;
@@ -47,14 +50,16 @@ MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
SecureLog = 0;
SecureLogUsed = false;
- if (AutoInitializationFinalization)
- doInitialization();
+ if (SrcMgr && SrcMgr->getNumBuffers() > 0)
+ MainFileName = SrcMgr->getMemoryBuffer(0)->getBufferIdentifier();
+ else
+ MainFileName = "";
}
MCContext::~MCContext() {
- if (AutoInitializationFinalization)
- doFinalization();
+ if (AutoReset)
+ reset();
// NOTE: The symbols are all allocated out of a bump pointer allocator,
// we don't need to free them here.
@@ -67,15 +72,7 @@ MCContext::~MCContext() {
// Module Lifetime Management
//===----------------------------------------------------------------------===//
-void MCContext::doInitialization() {
- NextUniqueID = 0;
- AllowTemporaryLabels = true;
- DwarfLocSeen = false;
- GenDwarfForAssembly = false;
- GenDwarfFileNumber = 0;
-}
-
-void MCContext::doFinalization() {
+void MCContext::reset() {
UsedNames.clear();
Symbols.clear();
Allocator.Reset();
@@ -95,6 +92,12 @@ void MCContext::doFinalization() {
MachOUniquingMap = 0;
ELFUniquingMap = 0;
COFFUniquingMap = 0;
+
+ NextUniqueID = 0;
+ AllowTemporaryLabels = true;
+ DwarfLocSeen = false;
+ GenDwarfForAssembly = false;
+ GenDwarfFileNumber = 0;
}
//===----------------------------------------------------------------------===//