summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-12-10 04:39:09 +0000
committerAndrew Trick <atrick@apple.com>2013-12-10 04:39:09 +0000
commit32591d3111fb0ee78c606d44cde75cf41ececf99 (patch)
tree631e11a159f524293eebe07c0f96e669b25293ad /llvm/lib/MC/MCContext.cpp
parent1c6a4c3d6142e33b677ddb0eda4551275288bc26 (diff)
downloadbcm5719-llvm-32591d3111fb0ee78c606d44cde75cf41ececf99.tar.gz
bcm5719-llvm-32591d3111fb0ee78c606d44cde75cf41ececf99.zip
Fix a crash that occurs when PWD is invalid.
MCJIT needs to be able to run in hostile environments, even when PWD is invalid. There's no need to crash MCJIT in this case. The obvious fix is to simply leave MCContext's CompilationDir empty when PWD can't be determined. This way, MCJIT clients, and other clients that link with LLVM don’t need a valid working directory. If we do want to guarantee valid CompilationDir, that should be done only for clients of getCompilationDir(). This is as simple as checking for an empty string. The only current use of getCompilationDir is EmitGenDwarfInfo, which won’t conceivably run with an invalid working dir. However, in the purely hypothetically and untestable case that this happens, the AT_comp_dir will be omitted from the compilation_unit DIE. llvm-svn: 196874
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index bd5793cbb9f..42056c951ca 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -47,8 +47,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
AllowTemporaryLabels(true), DwarfCompileUnitID(0), AutoReset(DoAutoReset) {
error_code EC = llvm::sys::fs::current_path(CompilationDir);
- assert(!EC && "Could not determine the current directory");
- (void)EC;
+ if (EC)
+ CompilationDir.clear();
MachOUniquingMap = 0;
ELFUniquingMap = 0;
OpenPOWER on IntegriCloud