Eliminate redundant nested-name-specifiers on

TemplateSpecializationTypes, which also fixes PR9388.

llvm-svn: 126946
This commit is contained in:
Douglas Gregor 2011-03-03 17:04:51 +00:00
parent 66a35d765f
commit e29139c77d
3 changed files with 24 additions and 2 deletions

View File

@ -2230,6 +2230,9 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
QualType Canon) const {
assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
// Look through qualified template names.
if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
Template = TemplateName(QTN->getTemplateDecl());
if (!Canon.isNull())
Canon = getCanonicalType(Canon);
@ -2257,6 +2260,9 @@ ASTContext::getCanonicalTemplateSpecializationType(TemplateName Template,
unsigned NumArgs) const {
assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
// Look through qualified template names.
if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
Template = TemplateName(QTN->getTemplateDecl());
// Build the canonical template specialization type.
TemplateName CanonTemplate = getCanonicalTemplateName(Template);
@ -4387,6 +4393,8 @@ TemplateName
ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
TemplateDecl *Template) const {
assert(NNS && "Missing nested-name-specifier in qualified template name");
// FIXME: Canonicalization?
llvm::FoldingSetNodeID ID;
QualifiedTemplateName::Profile(ID, NNS, TemplateKeyword, Template);

View File

@ -149,9 +149,9 @@ struct X9 : X8 {
// Base specifiers
// CHECK: Identifier: "outer_alias" [16:19 - 16:30] NamespaceRef=outer_alias:10:11
// CHECK: Punctuation: "::" [16:30 - 16:32] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Punctuation: "::" [16:30 - 16:32] C++ base class specifier=outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "inner" [16:32 - 16:37] NamespaceRef=inner:2:13
// CHECK: Punctuation: "::" [16:37 - 16:39] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Punctuation: "::" [16:37 - 16:39] C++ base class specifier=outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "vector" [16:39 - 16:45] TemplateRef=vector:4:12
// CHECK: Punctuation: "<" [16:45 - 16:46] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "X" [16:46 - 16:47] TypeRef=struct X:12:8

View File

@ -146,3 +146,17 @@ struct DependentTemplateTemplateArgumentTester {
};
DependentTemplateTemplateArgumentTester<HasApply, int> DTTACheck; // expected-note{{in instantiation of template class}}
namespace PR9388 {
namespace std {
template<typename T> class vector {
};
}
template<typename T> static void foo(std::vector<T*> &V) {
__PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
}
void bar(std::vector<int*> &Blocks) {
foo(Blocks); // expected-note{{in instantiation of}}
}
}