r179879 - Emit the underlying type in the debug info for all kinds of fixed enums

Eric Christopher echristo at gmail.com
Fri Apr 19 13:29:47 PDT 2013

I'm not sure I'm in favor of this change - at least not for c++.

In dwarf4 it's a "may" and not a must. For C++ the type is an
appropriate integral type from the literal values. For the code from
your test:

enum struct Colour { grey };

we don't actually need anything more than:

0x0000004a:   DW_TAG_enumeration_type [4] *
0x0000004f:     DW_AT_enum_class [DW_FORM_flag] (0x01)
0x00000050:     DW_AT_name [DW_FORM_strp]       (
.debug_str[0x00000072] = "Colour")
0x00000054:     DW_AT_byte_size [DW_FORM_data1] (0x04)
0x00000055:     DW_AT_decl_file [DW_FORM_data1] (0x01)
0x00000056:     DW_AT_decl_line [DW_FORM_data1] (0x01)

0x00000057:     DW_TAG_enumerator [5]
0x00000058:       DW_AT_name [DW_FORM_strp]     (
.debug_str[0x00000069] = "grey")
0x0000005c:       DW_AT_const_value [DW_FORM_sdata]     (0)

to full represent the size and underlying type I believe? That's also
what the DW_AT_enum_class attribute is doing since it's actually type
safe here.

Can you go into more detail on your thoughts here and why we need the
underlying type always emitted?

Few comments on the actual patch:

> Modified: cfe/trunk/test/CodeGenCXX/scoped-enums.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/scoped-enums.cpp?rev=179879&r1=179878&r2=179879&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/scoped-enums.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/scoped-enums.cpp Fri Apr 19 14:56:39 2013
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s
> +// RUN: %clang_cc1 -std=c++11 -emit-llvm -g -o - %s

Maybe put this in another testcase, no need for the scoped enums
testcase to depend on debug info being generated?

> +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -g -emit-llvm -Werror -o - %s | FileCheck %s
> +

Unlikely a need for Werror here.

> +// The DWARF standard says the underlying data type of an enum may be
> +// stored in an DW_AT_type() entry in the enum DIE.
> +

Or parens on DW_AT_type.

More information about the cfe-commits mailing list