r184695 - DebugInfo: ensure negative enumerators are emitted as such

Jordan Rose jordan_rose at apple.com
Mon Jun 24 09:17:57 PDT 2013


Couldn't this create problems for very big positive enums, i.e. those larger than 2^63? Not that this isn't strictly better than what we had before.


On Jun 24, 2013, at 0:13 , David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Mon Jun 24 02:13:13 2013
> New Revision: 184695
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=184695&view=rev
> Log:
> DebugInfo: ensure negative enumerators are emitted as such
> 
> There's still a problem here - since we're not appropriately using the
> signedness/range of the enum to chooset the encoding and emission of
> enumerators, but GCC has some bugs around this too so I assume that's
> not /such/ a high priority though I may get to it soon out of
> completeness.
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>    cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=184695&r1=184694&r2=184695&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jun 24 02:13:13 2013
> @@ -1803,7 +1803,7 @@ llvm::DIType CGDebugInfo::CreateEnumType
>        Enum != EnumEnd; ++Enum) {
>     Enumerators.push_back(
>       DBuilder.createEnumerator(Enum->getName(),
> -                                Enum->getInitVal().getZExtValue()));
> +                                Enum->getInitVal().getSExtValue()));
>   }
> 
>   // Return a CompositeType for the enum itself.
> 
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp?rev=184695&r1=184694&r2=184695&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp Mon Jun 24 02:13:13 2013
> @@ -1,7 +1,7 @@
> // RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
> 
> // CHECK: [[ENUMS:![0-9]*]], {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}} ; [ DW_TAG_compile_unit ]
> -// CHECK: [[ENUMS]] = metadata !{metadata [[E1:![0-9]*]], metadata [[E2:![0-9]*]]}
> +// CHECK: [[ENUMS]] = metadata !{metadata [[E1:![0-9]*]], metadata [[E2:![0-9]*]], metadata [[E3:![0-9]*]]}
> 
> namespace test1 {
> // CHECK: [[E1]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST1:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS:![0-9]*]], {{[^,]*}}, {{[^,]*}}} ; [ DW_TAG_enumeration_type ] [e]
> @@ -23,3 +23,14 @@ bool func(int i) {
>   return i == E;
> }
> }
> +
> +namespace test3 {
> +// CHECK: [[E3]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST3_ENUMS:![0-9]*]], {{[^,]*}}, {{[^,]*}}} ; [ DW_TAG_enumeration_type ] [e]
> +// CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3]
> +// CHECK: [[TEST3_ENUMS]] = metadata !{metadata [[TEST3_E:![0-9]*]]}
> +// CHECK: [[TEST3_E]] = {{.*}}, metadata !"E", i64 -1} ; [ DW_TAG_enumerator ] [E :: -1]
> +enum e { E = -1 };
> +void func() {
> +  e x;
> +}
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list