[PATCH] Handle properly somewhat special cases of -main-file-name
Richard Smith
richard at metafoo.co.uk
Tue May 20 18:54:33 PDT 2014
+ else if (!llvm::sys::path::is_absolute(MainFileName)) {
+ // The main file name provided via the "-fmain-file-name" option
contains just
+ // the file name itself with no path information.
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'.
+ std::string MainFileDir;
+ if (const FileEntry *MainFile =
SM.getFileEntryForID(SM.getMainFileID())) {
+ MainFileDir = MainFile->getDir()->getName();
+ if (MainFileDir != "." && MainFile->getName() !=
StringRef("<stdin>")) {
+ llvm::SmallString<1024> MainFileDirSS(MainFileDir);
Why the copying between a std::string and a SmallString? Can you just use
the SmallString from the start?
Please also provide a documentation update for this driver flag.
On Fri, May 2, 2014 at 4:29 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:
> On Friday 11 of April 2014, Eric Christopher wrote:
> > There's no guarantee that the option will continue to exist at all so
> > I'd really prefer that you not use it. Any time you have to use
> > -Xclang to set something then it's not an exposed option that you
> > should be using.
> >
> > That said, if we can come up with a structured set of uses for this
> > sort of compilation strategy rather than piecemeal then we should
> > discuss it and how it'll fit into the driver.
>
> So how about this patch?
>
> As said elsewhere, something like
>
> cd /output ; clang -c -g -gsplit-dwarf /source/a.cpp
>
> may need to be turned by a distributed build system into something like
>
> cd / ; clang -c -x c - -g -gsplit-dwarf -o /tmp/fhqtewdsg.o
>
> These options allow getting the same .o as with the first command by
> adding
>
> -fmain-file-name /source/a.cpp -fdebug-compilation-dir /output
> -fsplit-dwarf-file /output/a.dwo
>
> > >> On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak <l.lunak at centrum.cz>
> wrote:
> > >> > The handling of -main-file-name in CGDebugInfo::CreateCompileUnit()
> > >> > can result in incorrect DW_AT_name in somewhat special cases:
> > >> >
> > >> > 1)
> > >> > $ touch /tmp/a.cpp
> > >> > $
> > >> > clang++ -Wall -c /tmp/a.cpp -g -o /tmp/a.o -Xclang -main-file-name
> > >> > -Xclang /new/path/a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name
> > >> > <12> DW_AT_name : (indirect string, offset:
> > >> > 0x15): /tmp/new/path/a.cpp
> > >> >
> > >> > 2)
> > >> > $ touch /tmp/a.cpp
> > >> > $ cd /
> > >> > $ cat /tmp/a.cpp | clang++ -Wall -x
> > >> > c++ -c - -g -o /tmp/a.o -Xclang -main-file-name -Xclang a.cpp
> > >> > $ readelf -wi /tmp/a.o | grep DW_AT_name
> > >> > <12> DW_AT_name : (indirect string, offset: 0x15):
> /a.cpp
> > >> >
> > >> > The attached patch fixes those. Ok to commit?
>
> --
> Lubos Lunak
>
> _______________________________________________
> 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/20140520/8c610a40/attachment.html>
More information about the cfe-commits
mailing list