File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
llvm/lib/Analysis/DataStructure Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1116,8 +1116,17 @@ void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) {
1116
1116
const StructLayout *SL = TD.getStructLayout (CS->getType ());
1117
1117
for (unsigned i = 0 , e = CS->getNumOperands (); i != e; ++i) {
1118
1118
DSNode *NHN = NH.getNode ();
1119
- DSNodeHandle NewNH (NHN, NH.getOffset ()+(unsigned )SL->MemberOffsets [i]);
1120
- MergeConstantInitIntoNode (NewNH, cast<Constant>(CS->getOperand (i)));
1119
+ // Some programmers think ending a structure with a [0 x sbyte] is cute
1120
+ // This should be ok as the allocation type should grow this type when
1121
+ // it is merged in if it is bigger.
1122
+ if (SL->MemberOffsets [i] < SL->StructSize ) {
1123
+ DSNodeHandle NewNH (NHN, NH.getOffset ()+(unsigned )SL->MemberOffsets [i]);
1124
+ MergeConstantInitIntoNode (NewNH, cast<Constant>(CS->getOperand (i)));
1125
+ } else if (SL->MemberOffsets [i] == SL->StructSize ) {
1126
+ DEBUG (std::cerr << " Zero size element at end of struct\n " );
1127
+ } else {
1128
+ assert (0 && " type was smaller than offsets of of struct layout indicate" );
1129
+ }
1121
1130
}
1122
1131
} else if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) {
1123
1132
// Noop
You can’t perform that action at this time.
0 commit comments