r201056 - PR18685: Ignore class template specializations as potential
Kaelyn Uhrain
rikka at google.com
Sun Feb 9 13:47:04 PST 2014
Author: rikka
Date: Sun Feb 9 15:47:04 2014
New Revision: 201056
URL: http://llvm.org/viewvc/llvm-project?rev=201056&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=201056&r1=201055&r2=201056&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sun Feb 9 15:47:04 2014
@@ -4210,6 +4210,12 @@ TypoCorrection Sema::CorrectTypo(const D
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 D
CD = CD->getCanonicalDecl();
if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
!CD->isUnion() && CD->getIdentifier() &&
+ (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
(CD->isBeingDefined() || CD->isCompleteDefinition()))
Namespaces.AddNameSpecifier(CD);
}
Modified: cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp?rev=201056&r1=201055&r2=201056&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp Sun Feb 9 15:47:04 2014
@@ -207,3 +207,19 @@ struct {
int y = x; // expected-error-re {{use of undeclared identifier 'x'{{$}}}}
}
+
+namespace PR18685 {
+template <class C, int I, int J>
+class SetVector {
+ public:
+ SetVector() {}
+};
+
+template <class C, int I>
+class SmallSetVector : public SetVector<C, I, 8> {};
+
+class foo {};
+SmallSetVector<foo*, 2> fooSet;
+}
+
+PR18685::BitVector Map; // expected-error-re {{no type named 'BitVector' in namespace 'PR18685'{{$}}}}
More information about the cfe-commits
mailing list