summaryrefslogtreecommitdiff
path: root/include
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
commite15c1079cb4942f8975cf318b5deb87ed31c250a (patch)
treeac2b4dc2c9bebaf2286b995da954267ba58ecee3 /include
parent7a70a1bdaa1ef6d29807257fbc1c13210f65c9c1 (diff)
downloadllvm-e15c1079cb4942f8975cf318b5deb87ed31c250a.tar.gz
llvm-e15c1079cb4942f8975cf318b5deb87ed31c250a.tar.bz2
llvm-e15c1079cb4942f8975cf318b5deb87ed31c250a.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/MCContext.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index c8b66261bf..17a37ed3b9 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -278,6 +278,7 @@ namespace llvm {
/// This can be overridden by clients which want to control the reported
/// compilation directory and have it be something other than the current
/// working directory.
+ /// Returns an empty string if the current directory cannot be determined.
StringRef getCompilationDir() const { return CompilationDir; }
/// \brief Set the compilation directory for DW_AT_comp_dir