diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-10-01 00:56:55 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-10-01 00:56:55 +0000 |
| commit | 32b0f365a2f428e4f2b92f38474d1eccf70fd7d4 (patch) | |
| tree | 91c7c535d5aeb8da5af240f6ca7eac75000470a8 /llvm/lib/CodeGen/AsmPrinter | |
| parent | 05d8c8e682f02b6644789c968df67b25c89469ad (diff) | |
| download | bcm5719-llvm-32b0f365a2f428e4f2b92f38474d1eccf70fd7d4.tar.gz bcm5719-llvm-32b0f365a2f428e4f2b92f38474d1eccf70fd7d4.zip | |
Implement DW_TAG_subrange_type with DW_AT_count rather than DW_AT_upper_bound
This allows proper disambiguation of unbounded arrays and arrays of zero
bound ("struct foo { int x[]; };" and "struct foo { int x[0]; }"). GCC
instead produces an upper bound of -1 in the latter situation, but count
seems tidier. This way lower_bound is provided if it's not the language
default and count is provided if the count is known, otherwise it's
omitted. Simple.
If someone wants to look at rdar://problem/12566646 and see if this
change is acceptable to that bug/fix, that might be helpful (see the
empty-and-one-elem-array.ll test case which cites that radar).
llvm-svn: 218726
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index b6514e6b5d6..806b0e76fc6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1748,9 +1748,7 @@ void DwarfUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy) { // The LowerBound value defines the lower bounds which is typically zero for // C/C++. The Count value is the number of elements. Values are 64 bit. If // Count == -1 then the array is unbounded and we do not emit - // DW_AT_lower_bound and DW_AT_upper_bound attributes. If LowerBound == 0 and - // Count == 0, then the array has zero elements in which case we do not emit - // an upper bound. + // DW_AT_lower_bound and DW_AT_count attributes. int64_t LowerBound = SR.getLo(); int64_t DefaultLowerBound = getDefaultLowerBound(); int64_t Count = SR.getCount(); @@ -1758,11 +1756,10 @@ void DwarfUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy) { if (DefaultLowerBound == -1 || LowerBound != DefaultLowerBound) addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound); - if (Count != -1 && Count != 0) + if (Count != -1) // FIXME: An unbounded array should reference the expression that defines // the array. - addUInt(DW_Subrange, dwarf::DW_AT_upper_bound, None, - LowerBound + Count - 1); + addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count); } /// constructArrayTypeDIE - Construct array type DIE from DICompositeType. |

