[llvm-bugs] [Bug 33822] New: DW_AT_decl_file for DW_TAG_imported_declaration is bogus

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 17 12:04:22 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33822

            Bug ID: 33822
           Summary: DW_AT_decl_file for DW_TAG_imported_declaration is
                    bogus
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: aprantl at apple.com
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170717/5d1d4f8b/attachment.html>


More information about the llvm-bugs mailing list