r180669 - Use LLVM's preferred current_path API instead of calling getcwd(3) directly.
Chad Rosier
mcrosier at apple.com
Mon Apr 29 09:04:46 PDT 2013
Thanks, Ben.
On Apr 27, 2013, at 1:12 AM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sat Apr 27 03:12:29 2013
> New Revision: 180669
>
> URL: http://llvm.org/viewvc/llvm-project?rev=180669&view=rev
> Log:
> 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.
>
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=180669&r1=180668&r2=180669&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Apr 27 03:12:29 2013
> @@ -1775,9 +1775,6 @@ static bool shouldUseLeafFramePointer(co
> 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 Arg
> 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));
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130429/2cf0d371/attachment.html>
More information about the cfe-commits
mailing list