llvm.org GIT mirror llvm / 3f932a7
Simplify array bound checks and clarify comments. One element array can have same non-zero number as lower bound as well as upper bound. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129170 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 9 years ago
2 changed file(s) with 9 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
707707 composite type. The low value defines
708708 the lower bounds typically zero for C/C++. The high value is the upper
709709 bounds. Values are 64 bit. High - low + 1 is the size of the array. If low
710 > high the array will be unbounded.

710 > high the array bounds are not included in generated debugging information.
711

711712
712713
713714
12411241 int64_t L = SR.getLo();
12421242 int64_t H = SR.getHi();
12431243
1244 // The L value defines the lower bounds typically zero for C/C++. The H
1245 // value is the upper bounds. Values are 64 bit. H - L + 1 is the size
1246 // of the array. If L > H the array will be unbounded. If the L is
1247 // non zero and same is H then also the array will be unbounded. If L is
1248 // zero and H is zero then the array has one element and in such case do
1249 // not emit lower bound.
1250
1251 if (L > H || (L == H && L != 0)) {
1252 // This is an unbounded subrange.
1244 // The L value defines the lower bounds which is typically zero for C/C++. The
1245 // H value is the upper bounds. Values are 64 bit. H - L + 1 is the size
1246 // of the array. If L > H then do not emit DW_AT_lower_bound and
1247 // DW_AT_upper_bound attributes. If L is zero and H is also zero then the
1248 // array has one element and in such case do not emit lower bound.
1249
1250 if (L > H) {
12531251 Buffer.addChild(DW_Subrange);
12541252 return;
12551253 }
1256
12571254 if (L)
12581255 addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
12591256 addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);