[cfe-commits] r154707 - /cfe/trunk/lib/Sema/SemaLookup.cpp
Benjamin Kramer
benny.kra at googlemail.com
Fri Apr 13 16:09:10 PDT 2012
Author: d0k
Date: Fri Apr 13 18:09:10 2012
New Revision: 154707
URL: http://llvm.org/viewvc/llvm-project?rev=154707&view=rev
Log:
Delete the TypoResultsMap when erasing the pointer to it.
This manual deleting is error-prone, but we can't just put an OwningPtr in a
std::map :(
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=154707&r1=154706&r2=154707&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Apr 13 18:09:10 2012
@@ -3207,7 +3207,10 @@
typedef TypoEditDistanceMap::iterator distance_iterator;
distance_iterator begin() { return BestResults.begin(); }
distance_iterator end() { return BestResults.end(); }
- void erase(distance_iterator I) { BestResults.erase(I); }
+ void erase(distance_iterator I) {
+ delete I->second;
+ BestResults.erase(I);
+ }
unsigned size() const { return BestResults.size(); }
bool empty() const { return BestResults.empty(); }
@@ -3289,12 +3292,8 @@
CurrentCorrection.getAsString(SemaRef.getLangOpts()))
CurrentCorrection = Correction;
- while (BestResults.size() > MaxTypoDistanceResultSets) {
- TypoEditDistanceMap::iterator Last = BestResults.end();
- --Last;
- delete Last->second;
- BestResults.erase(Last);
- }
+ while (BestResults.size() > MaxTypoDistanceResultSets)
+ erase(llvm::prior(BestResults.end()));
}
// Fill the supplied vector with the IdentifierInfo pointers for each piece of
More information about the cfe-commits
mailing list