From de8278ff88df21ddcc5d98fc6f5df0d1048544fc Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Sun, 9 Feb 2014 21:47:04 +0000 Subject: [PATCH] PR18685: Ignore class template specializations as potential nested-name-specifiers for typos unless the typo already has a nested-name-specifier that is a template specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201056 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaLookup.cpp | 7 +++++++ test/SemaCXX/typo-correction-pt2.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 8a5c0a5ba7..1a47340d69 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -4210,6 +4210,12 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, KNI != KNIEnd; ++KNI) Namespaces.AddNameSpecifier(KNI->first); + bool SSIsTemplate = false; + if (NestedNameSpecifier *NNS = + (SS && SS->isValid()) ? SS->getScopeRep() : 0) { + if (const Type *T = NNS->getAsType()) + SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization; + } for (ASTContext::type_iterator TI = Context.types_begin(), TIEnd = Context.types_end(); TI != TIEnd; ++TI) { @@ -4217,6 +4223,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, CD = CD->getCanonicalDecl(); if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() && !CD->isUnion() && CD->getIdentifier() && + (SSIsTemplate || !isa(CD)) && (CD->isBeingDefined() || CD->isCompleteDefinition())) Namespaces.AddNameSpecifier(CD); } diff --git a/test/SemaCXX/typo-correction-pt2.cpp b/test/SemaCXX/typo-correction-pt2.cpp index 65d961085a..1738bb41b9 100644 --- a/test/SemaCXX/typo-correction-pt2.cpp +++ b/test/SemaCXX/typo-correction-pt2.cpp @@ -207,3 +207,19 @@ struct { int y = x; // expected-error-re {{use of undeclared identifier 'x'{{$}}}} } + +namespace PR18685 { +template +class SetVector { + public: + SetVector() {} +}; + +template +class SmallSetVector : public SetVector {}; + +class foo {}; +SmallSetVector fooSet; +} + +PR18685::BitVector Map; // expected-error-re {{no type named 'BitVector' in namespace 'PR18685'{{$}}}} -- 2.49.0