diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 17e0f38e07d..72210757f34 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -62,24 +62,29 @@ namespace { class TypeNameValidatorCCC : public CorrectionCandidateCallback { public: - TypeNameValidatorCCC(bool AllowInvalid, bool WantClass=false) - : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass) { + TypeNameValidatorCCC(bool AllowInvalid, bool WantClass=false, + bool AllowTemplates=false) + : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass), + AllowClassTemplates(AllowTemplates) { WantExpressionKeywords = false; WantCXXNamedCasts = false; WantRemainingKeywords = false; } virtual bool ValidateCandidate(const TypoCorrection &candidate) { - if (NamedDecl *ND = candidate.getCorrectionDecl()) - return (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) && - (AllowInvalidDecl || !ND->isInvalidDecl()); - else - return !WantClassName && candidate.isKeyword(); + if (NamedDecl *ND = candidate.getCorrectionDecl()) { + bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND); + bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND); + return (IsType || AllowedTemplate) && + (AllowInvalidDecl || !ND->isInvalidDecl()); + } + return !WantClassName && candidate.isKeyword(); } private: bool AllowInvalidDecl; bool WantClassName; + bool AllowClassTemplates; }; } @@ -394,13 +399,14 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, - ParsedType &SuggestedType) { + ParsedType &SuggestedType, + bool AllowClassTemplates) { // We don't have anything to suggest (yet). SuggestedType = ParsedType(); // There may have been a typo in the name of the type. Look up typo // results, in case we have something that we can suggest. - TypeNameValidatorCCC Validator(false); + TypeNameValidatorCCC Validator(false, false, AllowClassTemplates); if (TypoCorrection Corrected = CorrectTypo(DeclarationNameInfo(II, IILoc), LookupOrdinaryName, S, SS, Validator)) { |