Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the 'count' attribute instead of the 'upper_bound' attribute.
If we have a type 'int a[1]' and a type 'int b[0]', the generated DWARF is the same for both of them because we use the 'upper_bound' attribute. Instead use the 'count' attrbute, which gives the correct number of elements in the array. <rdar://problem/12566646> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167807 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
3 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s | ||
|
||
// <rdar://problem/12566646> | ||
|
||
// The subrange for a type 'int[1]' and 'int[0]' should be different. Use the | ||
// 'count' attribute instead of the 'upper_bound' attribute do disabmiguate the | ||
// DIE. | ||
|
||
struct foo { | ||
int a; | ||
int b[1]; | ||
}; | ||
|
||
struct bar { | ||
int a; | ||
int b[0]; | ||
}; | ||
|
||
int main() | ||
{ | ||
struct foo my_foo; | ||
struct bar my_bar; | ||
|
||
my_foo.a = 3; | ||
my_bar.a = 5; | ||
|
||
return my_foo.a + my_bar.a; | ||
} | ||
|
||
// The third metadata operand is the count. | ||
// | ||
// CHECK: metadata !{i32 786465, i64 0, i64 0, i64 1} ; [ DW_TAG_subrange_type ] | ||
// CHECK: metadata !{i32 786465, i64 0, i64 0, i64 0} ; [ DW_TAG_subrange_type ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters