<div dir="ltr"><div><div>+  else if (!llvm::sys::path::is_absolute(MainFileName)) {</div><div>+    // The main file name provided via the "-fmain-file-name" option contains just</div><div>+    // the file name itself with no path information.</div>
</div><div><br></div><div>That's not quite what is_absolute means, as far as I can see; the comment and the code seem to say different things about the treatment of '-fmain-file-name foo/bar.cc'.</div><div><br>
</div><div><br></div><div>+    std::string MainFileDir;</div><div>+    if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {</div><div>+      MainFileDir = MainFile->getDir()->getName();</div><div>
+      if (MainFileDir != "." && MainFile->getName() != StringRef("<stdin>")) {</div><div>+        llvm::SmallString<1024> MainFileDirSS(MainFileDir);</div><div><br></div><div>Why the copying between a std::string and a SmallString? Can you just use the SmallString from the start?</div>
<div><br></div><div><br></div><div>Please also provide a documentation update for this driver flag.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 2, 2014 at 4:29 AM, Lubos Lunak <span dir="ltr"><<a href="mailto:l.lunak@centrum.cz" target="_blank">l.lunak@centrum.cz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Friday 11 of April 2014, Eric Christopher wrote:<br>
> There's no guarantee that the option will continue to exist at all so<br>
> I'd really prefer that you not use it. Any time you have to use<br>
> -Xclang to set something then it's not an exposed option that you<br>
> should be using.<br>
><br>
> That said, if we can come up with a structured set of uses for this<br>
> sort of compilation strategy rather than piecemeal then we should<br>
> discuss it and how it'll fit into the driver.<br>
<br>
</div> So how about this patch?<br>
<br>
 As said elsewhere, something like<br>
<br>
 cd /output ; clang -c -g -gsplit-dwarf /source/a.cpp<br>
<br>
 may need to be turned by a distributed build system into something like<br>
<br>
 cd / ; clang -c -x c - -g -gsplit-dwarf -o /tmp/fhqtewdsg.o<br>
<br>
 These options allow getting the same .o as with the first command by adding<br>
<br>
 -fmain-file-name /source/a.cpp -fdebug-compilation-dir /output -fsplit-dwarf-file /output/a.dwo<br>
<div class="HOEnZb"><div class="h5"><br>
> >> On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak <<a href="mailto:l.lunak@centrum.cz">l.lunak@centrum.cz</a>> wrote:<br>
> >> >  The handling of -main-file-name in CGDebugInfo::CreateCompileUnit()<br>
> >> > can result in incorrect DW_AT_name in somewhat special cases:<br>
> >> ><br>
> >> > 1)<br>
> >> > $ touch /tmp/a.cpp<br>
> >> > $<br>
> >> > clang++ -Wall -c /tmp/a.cpp -g -o /tmp/a.o -Xclang -main-file-name<br>
> >> > -Xclang /new/path/a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name<br>
> >> >     <12>   DW_AT_name        : (indirect string, offset:<br>
> >> > 0x15): /tmp/new/path/a.cpp<br>
> >> ><br>
> >> > 2)<br>
> >> > $ touch /tmp/a.cpp<br>
> >> > $ cd /<br>
> >> > $ cat /tmp/a.cpp | clang++ -Wall -x<br>
> >> > c++ -c - -g -o /tmp/a.o -Xclang -main-file-name -Xclang a.cpp<br>
> >> > $ readelf -wi /tmp/a.o | grep DW_AT_name<br>
> >> >     <12>   DW_AT_name        : (indirect string, offset: 0x15): /a.cpp<br>
> >> ><br>
> >> >  The attached patch fixes those. Ok to commit?<br>
<br>
--<br>
 Lubos Lunak<br>
</div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>