From 989b7ca0922104157e76bc8520cc1bc1affb0304 Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Wed, 3 Apr 2013 16:59:49 +0000 Subject: 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 --- clang/lib/Sema/SemaLookup.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'clang/lib/Sema/SemaLookup.cpp') 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(*CDecl)) + return true; + } + + return WantTypeSpecifiers; +} -- cgit v1.2.3