diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-31 02:15:21 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-31 02:15:21 +0000 |
commit | 434bc3478f4a1c49e18cc881b8135b9d073a23c9 (patch) | |
tree | 82479b005d3e825c49c1e11b0deff2d0bb41fe8f /include/clang/AST/DeclTemplate.h | |
parent | f08aef7aa48a59d900845b61962c19ba1bec4f4c (diff) |
PR12298 et al: don't recursively instantiate a template specialization from
within the instantiation of that same specialization. This could previously
happen for eagerly-instantiated function templates, variable templates,
exception specifications, default arguments, and a handful of other cases.
We still have an issue here for default template arguments that recursively
make use of themselves and likewise for substitution into the type of a
non-type template parameter, but in those cases we're producing a different
entity each time, so they should instead be caught by the instantiation depth
limit. However, currently we will typically run out of stack before we reach
it. :(
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 8671d95c10..2af95c02c4 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -43,6 +43,8 @@ class VarTemplatePartialSpecializationDecl; typedef llvm::PointerUnion3<TemplateTypeParmDecl*, NonTypeTemplateParmDecl*, TemplateTemplateParmDecl*> TemplateParameter; +NamedDecl *getAsNamedDecl(TemplateParameter P); + /// \brief Stores a list of template parameters for a TemplateDecl and its /// derived classes. class TemplateParameterList final @@ -2937,6 +2939,14 @@ public: friend class ASTDeclWriter; }; +inline NamedDecl *getAsNamedDecl(TemplateParameter P) { + if (auto *PD = P.dyn_cast<TemplateTypeParmDecl*>()) + return PD; + if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl*>()) + return PD; + return P.get<TemplateTemplateParmDecl*>(); +} + } /* end of namespace clang */ #endif |