[PATCH] D41264: Fix faulty assertion for void type in debug info

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 08:49:31 PST 2017


aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Looks like CGDebugInfo::CreateType creates void as nullptr. If me modify the testcase to use the typedef

  class A {
    typedef void _Nodeptr;
    _Nodeptr * n;
  };

we can force it to be emitted even in DWARF:

  0x00000068:     DW_TAG_typedef
                    DW_AT_name	("_Nodeptr")
                    DW_AT_decl_file	("/tmp/t.cpp")
                    DW_AT_decl_line	(2)
  
  0x0000006f:     NULL

this also looks weird, but is apparently sort of legal DWARF:

> For example, in C and C++ the language implementation can provide an unspecified type entry with the name “void” which can be referenced by the type attribute of pointer types and typedef declarations for ’void’.

although it would be nicer to use DW_TAG_unspecified_type instead.

Based on this it looks like we should allow this case.



================
Comment at: llvm/test/DebugInfo/void-typedef.ll:34
+; Function Attrs: noinline nounwind optnone
+define x86_thiscallcc zeroext i1 @"\01?m_fn1 at B@@AAE_NXZ"(%class.B* %this) #0 align 2 !dbg !9 {
+entry:
----------------
We may not even need the function for the testcase to work, you might get away with removing the function, adding the type to the retained types in the CU and then running the file through `llvm-as - | llvm-dis` to get rid of all unreachable MDNodes.


https://reviews.llvm.org/D41264





More information about the llvm-commits mailing list