<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - DW_AT_decl_file for DW_TAG_imported_declaration is bogus"
   href="https://bugs.llvm.org/show_bug.cgi?id=33822">33822</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DW_AT_decl_file for DW_TAG_imported_declaration is bogus
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aprantl@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>DIImportedEntity has a line number, but not a file field. To determine the
decl_line/decl_file we combine the line number from the DIImportedEntity with
the file from the DIImportedEntity's scope.


DIE *DwarfCompileUnit::constructImportedEntityDIE(
    const DIImportedEntity *Module) {
  ...
  addSourceLine(*IMDie, Module->getLine(), Module->getScope()->getFilename(),
                Module->getScope()->getDirectory());
  ...
}

This has odd effects. For example:

-------------------------------------------------------------
$ cat using.ii
#line 100 "abc.h"
namespace N { class A; }
#line 200 "using.h"
using N::A;

$ clang++ -g -c using.ii -o using.o
$ dwarfdump using.o
0x00000029:     TAG_imported_declaration [4]  
                 AT_decl_file( "using.ii" )
                 AT_decl_line( 200 )
                 AT_import( {0x00000023} )


-------------------------------------------------------------
similarly:

#line 100 "abc.h"
namespace N { class A; }
#line 200 "using.cpp"
namespace M {
using N::A;
}

-->

!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6,
line: 201)
!5 = !DINamespace(name: "M", scope: null)
!6 = !DICompositeType(tag: DW_TAG_class_type, name: "A", ...)
!8 = !DINamespace(name: "N", scope: null)

-->

0x0000001e:     TAG_namespace [2] *
                 AT_name( "M" )

0x00000023:         TAG_imported_declaration [3]  
                     AT_decl_file( "<stdin>" ) <-- DINamespace has no file/line
                     AT_decl_line( 201 )
                     AT_import( {0x00000031} )
-------------------------------------------------------------

I think that the correct fix for this is to add a `file:` field to
DIImportedEntity.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>