summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-10-27 18:07:34 +0000
committerKaelyn Takata <rikka@google.com>2014-10-27 18:07:34 +0000
commit0d6a3edccedde68f8042026dfee6ed772796d0d9 (patch)
tree4be9bf21bfeabd71964ff352ea0b77380c205376 /clang/lib/Sema/SemaLookup.cpp
parent89c881b548753639e4abf8a6edf30edf22190275 (diff)
downloadbcm5719-llvm-0d6a3edccedde68f8042026dfee6ed772796d0d9.tar.gz
bcm5719-llvm-0d6a3edccedde68f8042026dfee6ed772796d0d9.zip
Have TypoCorrectionConsumer remember the TypoCorrections it returned.
Two additional methods are provided: one to return the current correction (the last correction returned by getNextCorrection), and one to "reset" the state so that getNextCorrection will return the previous corrections before returning any new corrections. Also ensure that all TypoCorrections have valid source ranges. llvm-svn: 220694
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index aef1dc2d5e4..e0d530a55e6 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3444,7 +3444,11 @@ void TypoCorrectionConsumer::addNamespaces(
}
}
-TypoCorrection TypoCorrectionConsumer::getNextCorrection() {
+const TypoCorrection &TypoCorrectionConsumer::getNextCorrection() {
+ if (++CurrentTCIndex < ValidatedCorrections.size())
+ return ValidatedCorrections[CurrentTCIndex];
+
+ CurrentTCIndex = ValidatedCorrections.size();
while (!CorrectionResults.empty()) {
auto DI = CorrectionResults.begin();
if (DI->second.empty()) {
@@ -3460,16 +3464,20 @@ TypoCorrection TypoCorrectionConsumer::getNextCorrection() {
}
TypoCorrection TC = RI->second.pop_back_val();
- if (TC.isResolved() || resolveCorrection(TC))
- return TC;
+ if (TC.isResolved() || resolveCorrection(TC)) {
+ ValidatedCorrections.push_back(TC);
+ return ValidatedCorrections[CurrentTCIndex];
+ }
}
- return TypoCorrection();
+ return ValidatedCorrections[0]; // The empty correction.
}
bool TypoCorrectionConsumer::resolveCorrection(TypoCorrection &Candidate) {
IdentifierInfo *Name = Candidate.getCorrectionAsIdentifierInfo();
DeclContext *TempMemberContext = MemberContext;
CXXScopeSpec *TempSS = SS;
+ if (Candidate.getCorrectionRange().isInvalid())
+ Candidate.setCorrectionRange(TempSS, Result.getLookupNameInfo());
retry_lookup:
LookupPotentialTypoResult(SemaRef, Result, Name, S, TempSS, TempMemberContext,
EnteringContext,
OpenPOWER on IntegriCloud