aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r--lib/Sema/SemaLookup.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 966eb90306..06697b6a68 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -3207,7 +3207,10 @@ public:
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 @@ void TypoCorrectionConsumer::addCorrection(TypoCorrection Correction) {
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