diff options
author | Kaelyn Uhrain <rikka@google.com> | 2012-01-12 22:32:39 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2012-01-12 22:32:39 +0000 |
commit | 3b4b047ff0ebaefeaed0a5f545b4fa91f18e6cdb (patch) | |
tree | e1325d62a1a4933f4bbbc260ecc1e153d53ad56e /lib/Sema/SemaCXXScopeSpec.cpp | |
parent | f2b4f7b6772ccba2ea8aae411ea09d8d32d90015 (diff) |
Convert SemaCXXScopeSpec.cpp to pass a callback object to CorrectTypo,
improvng the typo correction results in certain situations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 93f83256b0..31e33dda08 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -363,6 +363,25 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, return false; } +namespace { + +// Callback to only accept typo corrections that can be a valid C++ member +// intializer: either a non-static field member or a base class. +class NestedNameSpecifierValidatorCCC : public CorrectionCandidateCallback { + public: + explicit NestedNameSpecifierValidatorCCC(Sema &SRef) + : SRef(SRef) {} + + virtual bool ValidateCandidate(const TypoCorrection &candidate) { + return SRef.isAcceptableNestedNameSpecifier(candidate.getCorrectionDecl()); + } + + private: + Sema &SRef; +}; + +} + /// \brief Build a new nested-name-specifier for "identifier::", as described /// by ActOnCXXNestedNameSpecifier. /// @@ -478,12 +497,12 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, // We haven't found anything, and we're not recovering from a // different kind of error, so look for typos. DeclarationName Name = Found.getLookupName(); + NestedNameSpecifierValidatorCCC Validator(*this); TypoCorrection Corrected; Found.clear(); if ((Corrected = CorrectTypo(Found.getLookupNameInfo(), - Found.getLookupKind(), S, &SS, LookupCtx, - EnteringContext, CTC_NoKeywords)) && - isAcceptableNestedNameSpecifier(Corrected.getCorrectionDecl())) { + Found.getLookupKind(), S, &SS, &Validator, + LookupCtx, EnteringContext))) { std::string CorrectedStr(Corrected.getAsString(getLangOptions())); std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions())); if (LookupCtx) |