aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-04-27 08:42:33 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-04-27 08:42:33 +0000
commit99d2eb487f8d9fbb4e74d0b7154eff5b2232e10f (patch)
treeb607d76ba1804e65c0d1b81b8f0dca24997fe87d /lib
parent6089adc7310e5e70ac42b5d942344cddb8a48f55 (diff)
Exit early when $PWD isn't set. Remove unused unistd.h include.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Driver/Tools.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 7e3ed2461a..fb5bad4f24 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include <sys/stat.h>
-#include <unistd.h>
#include "Tools.h"
#include "InputInfo.h"
#include "SanitizerArgs.h"
@@ -1780,9 +1779,11 @@ static bool shouldUseLeafFramePointer(const ArgList &Args,
static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
struct stat StatPWDBuf, StatDotBuf;
- const char *pwd;
- if ((pwd = ::getenv("PWD")) != 0 &&
- llvm::sys::path::is_absolute(pwd) &&
+ const char *pwd = ::getenv("PWD");
+ if (!pwd)
+ return;
+
+ if (llvm::sys::path::is_absolute(pwd) &&
stat(pwd, &StatPWDBuf) == 0 &&
stat(".", &StatDotBuf) == 0 &&
StatPWDBuf.st_ino == StatDotBuf.st_ino &&