diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-08-29 22:14:43 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-08-29 22:14:43 +0000 |
commit | 1abacfcb2358a1928f0ced693e149a6cf2fc482e (patch) | |
tree | 088e56bf34781f1201c8a15421f2b79bd6ee5c1c /clang/lib/AST/TemplateName.cpp | |
parent | c6daf73c7241fa3c3803167bf79e68f86b4c2f3f (diff) | |
download | bcm5719-llvm-1abacfcb2358a1928f0ced693e149a6cf2fc482e.tar.gz bcm5719-llvm-1abacfcb2358a1928f0ced693e149a6cf2fc482e.zip |
PR10147: When substituting a template template argument, substitute in the most
recent (non-friend) declaration to pick up the right set of default template
arguments.
llvm-svn: 312049
Diffstat (limited to 'clang/lib/AST/TemplateName.cpp')
-rw-r--r-- | clang/lib/AST/TemplateName.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp index 47a7d47e7a4..9dbe827df58 100644 --- a/clang/lib/AST/TemplateName.cpp +++ b/clang/lib/AST/TemplateName.cpp @@ -131,6 +131,23 @@ DependentTemplateName *TemplateName::getAsDependentTemplateName() const { return Storage.dyn_cast<DependentTemplateName *>(); } +TemplateName TemplateName::getNameToSubstitute() const { + TemplateDecl *Decl = getAsTemplateDecl(); + + // Substituting a dependent template name: preserve it as written. + if (!Decl) + return *this; + + // If we have a template declaration, use the most recent non-friend + // declaration of that template. + Decl = cast<TemplateDecl>(Decl->getMostRecentDecl()); + while (Decl->getFriendObjectKind()) { + Decl = cast<TemplateDecl>(Decl->getPreviousDecl()); + assert(Decl && "all declarations of template are friends"); + } + return TemplateName(Decl); +} + bool TemplateName::isDependent() const { if (TemplateDecl *Template = getAsTemplateDecl()) { if (isa<TemplateTemplateParmDecl>(Template)) |