[cfe-commits] [cfe-dev] Make namespace typo correction always deterministic
nlewycky at google.com
Tue Jun 28 15:31:36 PDT 2011
On 28 June 2011 15:11, Kaelyn Uhrain <rikka at google.com> wrote:
> Without this patch, if there are two different but valid namespace
> qualifiers for reaching the same decl, which one was used was determined by
> the (undefined) order the namespaces were checked for the identifer. This
> patch adds a simple heuristic that keeps whichever version would come first
+ TypoResultsMap::iterator elt = Map->find(Name);
+ if (elt == Map->end() || Correction.getAsString(SemaRef.getLangOptions())
+ (*Map)[Name] = Correction;
This effectively does Map->find(name) twice, once to get elt and once to set
it to Correction (the operator will run it again).
Would this work?
TypoCorrection &BestCorrection = (*Map)[Name];
if (!BestCorrection || Correction.getAsString(SemaRef.getLangOptions()) <
BestCorrection = Correction;
It might not if there's no copy/assignment on TypoCorrection.
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits