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

Lubos Lunak l.lunak at centrum.cz
Fri Apr 4 05:02:18 PDT 2014


 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-handle-properly-somewhat-special-cases-of-main-file-.patch
Type: text/x-diff
Size: 2472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140404/7e281f50/attachment.patch>


More information about the cfe-commits mailing list