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 | 989b7ca0922104157e76bc8520cc1bc1affb0304 (patch) | |
tree | 8286e790cc6dfe051a276b2f5813f5e964b3fb40 /clang/lib/Sema/SemaLookup.cpp | |
parent | 80031d9fc45f9d647a1462d74a44d8070da672bb (diff) | |
download | bcm5719-llvm-989b7ca0922104157e76bc8520cc1bc1affb0304.tar.gz bcm5719-llvm-989b7ca0922104157e76bc8520cc1bc1affb0304.zip |
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.
llvm-svn: 178668
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 0fe3db1901f..2b3ca3f0ef7 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/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; +} |