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 | fb96ec76ffc6d6062ada3618b6b314565b49a995 (patch) | |
| tree | 554fee9307492203b337db48335b395c0e7b3409 /clang/lib | |
| parent | e74d47ed03d6377b373623361eb22244660a3ea3 (diff) | |
| download | bcm5719-llvm-fb96ec76ffc6d6062ada3618b6b314565b49a995.tar.gz bcm5719-llvm-fb96ec76ffc6d6062ada3618b6b314565b49a995.zip | |
Convert SemaCXXScopeSpec.cpp to pass a callback object to CorrectTypo,
improvng the typo correction results in certain situations.
llvm-svn: 148052
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 93f83256b01..31e33dda08a 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/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) |

