In addition to Doug's concerns which I share (chdir seems *really* heavy handed inside the driver...) I have some more basic technical problems here.<br><br><div class="gmail_quote">On Fri, Sep 23, 2011 at 1:33 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel@zuster.org">daniel@zuster.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">+  // Honor --working-directory. Eventually we want to handle this completely<br>
+  // internally to support good use as a library, but for now we just change our<br>
+  // working directory.<br>
+  if (const Arg *A = Args->getLastArg(options::OPT__working_directory)) {<br>
+    ::chdir(A->getValue(*Args));<br></blockquote><div><br></div><div>Why aren't you checking this for errors??</div><div><br></div><div>As a result of this not being checked, the test (which isn't in this commit? please put test cases in the same commit when possible, it makes it harder to review patches) doesn't actually test anything:</div>
<div><br></div><div><div>% cat tools/clang/test/Driver/Output/working-directory.c.script</div><div>touch .../build/tools/clang/test/Driver/Output/working-directory.c.tmp.h &&</div><div>echo '#include ".../build/tools/clang/test/Driver/Output/working-directory.c.tmp.h"' > .../build/tools/clang/test/Driver/Output/working-directory.c.tmp.c &&</div>
<div>.../build/bin/./clang  --working-directory .../build/tools/clang/test/Driver/Output/working-directory.c.tmp -fsyntax-only .../build/tools/clang/test/Driver/Output/working-directory.c.tmp.c</div></div><div><br></div><div>
(paths munged for readability, but '...' is an absolute path)</div><div><br></div><div>'working-directory.c.tmp' is a non-existent file, its not a directory at all.</div><div><br></div><div>Also, the include uses an absolute path, and the clang commandline does too, this test would pass with Clang run from *any* working directory... I think you want to have a source file in the Input subdirectory, and run the compile with a relative path to that file, and a working directory inside the Input subdirectory.</div>
</div>