llvm.org GIT mirror llvm / f64903b
Fixed subtle bug in Deserializer::JumpTo when jumping when the block-nesting information matching did not exactly match the underlying stream's scoping information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44470 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 12 years ago
2 changed file(s) with 30 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
124124 llvm::SmallVector BlockStack;
125125 unsigned AbbrevNo;
126126 unsigned RecordCode;
127 Location StreamStart;
127 uint64_t StreamStart;
128128
129129 //===----------------------------------------------------------===//
130130 // Public Interface.
347347
348348 bool FinishedBlock(Location BlockLoc);
349349 bool JumpTo(const Location& BlockLoc);
350 void Rewind() { JumpTo(StreamStart); }
350 void Rewind();
351351
352352 bool AtEnd();
353353 bool inRecord();
2020
2121 Deserializer::Deserializer(BitstreamReader& stream)
2222 : Stream(stream), RecIdx(0), FreeList(NULL), AbbrevNo(0), RecordCode(0) {
23
24 AdvanceStream();
25 if (!AtEnd()) StreamStart = BlockStack.back();
23
24 StreamStart = Stream.GetCurrentBitNo();
2625 }
2726
2827 Deserializer::~Deserializer() {
164163
165164 assert (!inRecord());
166165
167 // AdvanceStream();
168
169 // assert (AbbrevNo == bitc::ENTER_SUBBLOCK);
166 AdvanceStream();
167
170168 assert (!BlockStack.empty() || AtEnd());
171169
172 uint64_t LastBPos = StreamStart.BitNo;
170 uint64_t LastBPos = StreamStart;
173171
174172 while (!BlockStack.empty()) {
175173
182180 // destroy any accumulated context within the block scope. We then
183181 // jump to the position of the block and enter it.
184182 Stream.JumpToBit(LastBPos);
183
184 if (BlockStack.size() == Stream.BlockScope.size())
185 Stream.PopBlockScope();
186
185187 BlockStack.pop_back();
186 Stream.PopBlockScope();
187188
188189 AbbrevNo = 0;
189190 AdvanceStream();
194195 }
195196
196197 // This block does not contain the block we are looking for. Pop it.
198 if (BlockStack.size() == Stream.BlockScope.size())
199 Stream.PopBlockScope();
200
197201 BlockStack.pop_back();
198 Stream.PopBlockScope();
202
199203 }
200204
201205 // Check if we have popped our way to the outermost scope. If so,
202206 // we need to adjust our position.
203207 if (BlockStack.empty()) {
204 Stream.JumpToBit(Loc.BitNo < LastBPos ? StreamStart.BitNo : LastBPos);
208 assert (Stream.BlockScope.empty());
209
210 Stream.JumpToBit(Loc.BitNo < LastBPos ? StreamStart : LastBPos);
205211 AbbrevNo = 0;
206212 AdvanceStream();
207213 }
228234 return true;
229235 }
230236
237 void Deserializer::Rewind() {
238 while (!Stream.BlockScope.empty())
239 Stream.PopBlockScope();
240
241 while (!BlockStack.empty())
242 BlockStack.pop_back();
243
244 Stream.JumpToBit(StreamStart);
245 AbbrevNo = 0;
246 }
247
248
231249 unsigned Deserializer::getCurrentBlockID() {
232250 if (!inRecord())
233251 AdvanceStream();