[llvm-bugs] [Bug 36541] New: dwarfdump mis-prints 'const' in a const pointer context

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 27 10:39:14 PST 2018


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

            Bug ID: 36541
           Summary: dwarfdump mis-prints 'const' in a const pointer
                    context
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-dwarfdump
          Assignee: unassignedbugs at nondot.org
          Reporter: paul_robinson at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org

Mentioned in passing in bug 36526 but deserving its own report:
llvm-dwarfdump prints the 'const' before the unqualified type name,
which is syntactically incorrect if the unqualified type name is a
pointer.  I didn't check but likely any other qualifier would have
the same problem (certainly 'volatile' and probably _Atomic or
however that one is spelled).



$ cat t.cpp
int i = 1;
const int j = 2;
int * const const_ptr_to_int = &i;
const int * ptr_to_const_int = &j;

int foo() {
  return *const_ptr_to_int + *ptr_to_const_int;
}
$ clang -c -g t.cpp
$ llvm-dwarfdump -debug-info t.o
...
0x00000046:   DW_TAG_variable
                DW_AT_name      ("ptr_to_const_int")
                DW_AT_type      (cu + 0x005b "const int*")
...
0x00000065:   DW_TAG_variable
                DW_AT_name      ("const_ptr_to_int")
                DW_AT_type      (cu + 0x0070 "const int*")
...



Entertainingly, "const int * const foo" comes out as "const const int*".

I could see wrapping the qualified type in parens, or just printing the
qualifier after the referenced type.  This means non-pointer types
would have the 'const' appearing on the right, which is a style favored
by some ('int const' rather than 'const int').

-- 
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/20180227/3b42a5f2/attachment.html>


More information about the llvm-bugs mailing list