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

View File

@ -149,9 +149,9 @@ struct X9 : X8 {
// Base specifiers // Base specifiers
// CHECK: Identifier: "outer_alias" [16:19 - 16:30] NamespaceRef=outer_alias:10:11 // 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: 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: 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: 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 // 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}} 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}}
}
}