summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2014-03-21 21:54:25 +0000
committerKaelyn Uhrain <rikka@google.com>2014-03-21 21:54:25 +0000
commitec2629964ed81ad17748c2055e7f22ea54ffe547 (patch)
tree37f8869235bba7cb7dd02556abc4fcc28e1a43f1 /clang/lib/Sema/SemaLookup.cpp
parentbbfc05727bf2e07312eca37683e1ae881bdc6bf9 (diff)
downloadbcm5719-llvm-ec2629964ed81ad17748c2055e7f22ea54ffe547.tar.gz
bcm5719-llvm-ec2629964ed81ad17748c2055e7f22ea54ffe547.zip
Be a bit smarter about what nested name qualifiers to allow when
performing typo correction on very short (1 or 2 char) identifiers. llvm-svn: 204525
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 0dd0260a5b4..020fafa8f56 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -4209,13 +4209,17 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
IEnd = DI->second.end();
I != IEnd; /* Increment in loop. */) {
// If we only want nested name specifier corrections, ignore potential
- // corrections that have a different base identifier from the typo.
- if (AllowOnlyNNSChanges &&
- I->second.front().getCorrectionAsIdentifierInfo() != Typo) {
- TypoCorrectionConsumer::result_iterator Prev = I;
- ++I;
- DI->second.erase(Prev);
- continue;
+ // corrections that have a different base identifier from the typo or
+ // which have a normalized edit distance longer than the typo itself.
+ if (AllowOnlyNNSChanges) {
+ TypoCorrection &TC = I->second.front();
+ if (TC.getCorrectionAsIdentifierInfo() != Typo ||
+ TC.getEditDistance(true) > TypoLen) {
+ TypoCorrectionConsumer::result_iterator Prev = I;
+ ++I;
+ DI->second.erase(Prev);
+ continue;
+ }
}
// If the item already has been looked up or is a keyword, keep it.
OpenPOWER on IntegriCloud