[PATCH] Handle properly somewhat special cases of -main-file-name

David Blaikie dblaikie at gmail.com
Fri Apr 4 08:13:19 PDT 2014


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.

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
>



More information about the cfe-commits mailing list