[cfe-commits] r67877 - /cfe/trunk/lib/AST/ASTContext.cpp
Douglas Gregor
dgregor at apple.com
Fri Mar 27 16:25:45 PDT 2009
Author: dgregor
Date: Fri Mar 27 18:25:45 2009
New Revision: 67877
URL: http://llvm.org/viewvc/llvm-project?rev=67877&view=rev
Log:
Perform a very, very ugly song-and-dance number to free the
NestedNameSpecifiers without causing problems for the FoldingSet that
contains them.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=67877&r1=67876&r2=67877&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar 27 18:25:45 2009
@@ -78,17 +78,22 @@
}
// 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);
More information about the cfe-commits
mailing list