}
// Destroy nested-name-specifiers.
- for (llvm::FoldingSet<NestedNameSpecifier>::iterator
- NNS = NestedNameSpecifiers.begin(),
- NNSEnd = NestedNameSpecifiers.end();
- NNS != NNSEnd; ) {
- // This loop iterates, then destroys so that it doesn't cause invalid
- // reads.
- // FIXME: Find a less fragile way to do this!
- NestedNameSpecifier* N = &*NNS;
- ++NNS;
- N->Destroy(*this);
- }
+ llvm::SmallVector<NestedNameSpecifier *, 16> NestedNameSpecs;
+ {
+ for (llvm::FoldingSet<NestedNameSpecifier>::iterator
+ NNS = NestedNameSpecifiers.begin(),
+ NNSEnd = NestedNameSpecifiers.end();
+ NNS != NNSEnd;
+ ++NNS)
+ NestedNameSpecs.push_back(&*NNS);
+ }
+ NestedNameSpecifiers.clear();
+ for (llvm::SmallVector<NestedNameSpecifier *, 16>::iterator
+ NNS = NestedNameSpecs.begin(),
+ NNSEnd = NestedNameSpecs.end();
+ NNS != NNSEnd;
+ ++NNS)
+ (*NNS)->Destroy(*this);
if (GlobalNestedNameSpecifier)
GlobalNestedNameSpecifier->Destroy(*this);