summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-04-27 08:12:29 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-04-27 08:12:29 +0000
commit698d7c86f0223ac40360415e5e032449a94a06a5 (patch)
treea85b17bb7556f663a839abfcb67193c00e57f628 /clang/lib/Driver/Tools.cpp
parentb33b6cb84aa473d85397af32dde4a49d1a480c4d (diff)
downloadbcm5719-llvm-698d7c86f0223ac40360415e5e032449a94a06a5.tar.gz
bcm5719-llvm-698d7c86f0223ac40360415e5e032449a94a06a5.zip
Use LLVM's preferred current_path API instead of calling getcwd(3) directly.
The existing code also failed to allocate a buffer for it so getcwd corrupted the stack. sys::fs::current_path takes care of the memory management. llvm-svn: 180669
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 40aebd4d100..7e3ed2461aa 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -1775,9 +1775,6 @@ static bool shouldUseLeafFramePointer(const ArgList &Args,
return true;
}
-// FIXME: This is a temporary hack until I can find a fix that works for all
-// platforms.
-#define MAXPATHLEN 4096
/// If the PWD environment variable is set, add a CC1 option to specify the
/// debug compilation directory.
static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
@@ -1794,9 +1791,10 @@ static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
CmdArgs.push_back(Args.MakeArgString(pwd));
return;
}
+
// Fall back to using getcwd.
- char *cwd;
- if (pwd && ::getcwd(cwd, MAXPATHLEN)) {
+ SmallString<128> cwd;
+ if (!llvm::sys::fs::current_path(cwd)) {
CmdArgs.push_back("-fdebug-compilation-dir");
CmdArgs.push_back(Args.MakeArgString(cwd));
}
OpenPOWER on IntegriCloud