[PATCH] Handle properly somewhat special cases of -main-file-name
Richard Smith
richard at metafoo.co.uk
Sat Apr 12 16:12:04 PDT 2014
All of the -cc1 and -Xclang interface is internal.
On 4 Apr 2014 09:09, "Lubos Lunak" <l.lunak at centrum.cz> wrote:
> On Friday 04 of April 2014, David Blaikie wrote:
> > The comment in CGDebugInfo.cpp says that -main-file-name will contain
> > only the file name, with no path information. Are there cases where
> > that is not true when -main-file-name is passed from the Clang driver,
> > rather than by the user in your example below?
> >
> > If the driver provides this guarantee and the user violates it when
> > passing an undocumented flag manually, I don't see a need to support
> > it - but if there is such a need, it'd be good to
> > understand/documemnt/discuss it.
>
> I think the driver always only passes the filename, but I do pass it
> explicitly, since I feed the source from stdin and the source or even its
> directory don't exist (distributed compiling, the same way with the patch
> for -dwarf-split-file).
>
> And actually case 2) without using the option explicitly results in
> DW_AT_name becoming "/-" (I don't know why the driver doesn't simply pass
> the
> name as it is, which wouldn't need the code that attempts to rebuild it
> later).
>
> As for "undocumented", the documentation status of the option is about the
> same like with many others - it's just in the .td file including its
> description. The description says quite clearly what the option does, it
> doesn't say it's internal, it works fine (except for these small
> problems), I
> even checked the sources to be sure, and I don't see why Clang should
> forbid
> usage of the option if I know what I'm doing (and would have to resort to
> ugly hacks otherwise).
>
> > 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/20140412/1030fa81/attachment.html>
More information about the cfe-commits
mailing list