diff options
author | Kaelyn Uhrain <rikka@google.com> | 2013-04-03 16:59:49 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2013-04-03 16:59:49 +0000 |
commit | 20a7cf4d782e32b2752e651a11ed3712d2debd65 (patch) | |
tree | 6508fae972481d70cb0a7a296ff79060e2204fa7 /lib/Sema/SemaLookup.cpp | |
parent | 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05 (diff) |
Give the default CorrectionCandidateCallback::ValidateCandidate some
smarts so that it doesn't approve of keywords and/or type names when it
knows (based on its flags) that those kinds of corrections are not
wanted.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 0fe3db1901..2b3ca3f0ef 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -4139,3 +4139,21 @@ std::string TypoCorrection::getAsString(const LangOptions &LO) const { return CorrectionName.getAsString(); } + +bool CorrectionCandidateCallback::ValidateCandidate(const TypoCorrection &candidate) { + if (!candidate.isResolved()) + return true; + + if (candidate.isKeyword()) + return WantTypeSpecifiers || WantExpressionKeywords || WantCXXNamedCasts || + WantRemainingKeywords || WantObjCSuper; + + for (TypoCorrection::const_decl_iterator CDecl = candidate.begin(), + CDeclEnd = candidate.end(); + CDecl != CDeclEnd; ++CDecl) { + if (!isa<TypeDecl>(*CDecl)) + return true; + } + + return WantTypeSpecifiers; +} |