[cfe-commits] r134038 - /cfe/trunk/lib/Sema/SemaLookup.cpp
Chandler Carruth
chandlerc at gmail.com
Tue Jun 28 15:48:40 PDT 2011
Author: chandlerc
Date: Tue Jun 28 17:48:40 2011
New Revision: 134038
URL: http://llvm.org/viewvc/llvm-project?rev=134038&view=rev
Log:
Fix non-determinism in selecting between equal-length names which refer
to the same declaration when correcting typos. This is done by
essentially sorting the corrections as they're added.
Original patch by Kaelyn Uhrain, but modified for style and correctness
by accounting for more than just the textual spelling.
This still is a bit of a WIP hack to make this deterministic. Kaelyn
(and myself) are working on a more principled solution going forward.
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=134038&r1=134037&r2=134038&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Jun 28 17:48:40 2011
@@ -3178,7 +3178,15 @@
TypoResultsMap *& Map = BestResults[Correction.getEditDistance()];
if (!Map)
Map = new TypoResultsMap;
- (*Map)[Name] = Correction;
+
+ TypoCorrection &CurrentCorrection = (*Map)[Name];
+ if (!CurrentCorrection ||
+ // FIXME: The following should be rolled up into an operator< on
+ // TypoCorrection with a more principled definition.
+ CurrentCorrection.isKeyword() < Correction.isKeyword() ||
+ Correction.getAsString(SemaRef.getLangOptions()) <
+ CurrentCorrection.getAsString(SemaRef.getLangOptions()))
+ CurrentCorrection = Correction;
while (BestResults.size() > MaxTypoDistanceResultSets) {
TypoEditDistanceMap::iterator Last = BestResults.end();
More information about the cfe-commits
mailing list