From 99d2eb487f8d9fbb4e74d0b7154eff5b2232e10f Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 27 Apr 2013 08:42:33 +0000 Subject: [PATCH] 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 --- lib/Driver/Tools.cpp | 9 +++++---- 1 file 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 -#include #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 && -- 2.40.0