diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-11-04 03:40:30 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-11-04 03:40:30 +0000 |
commit | 6bb02a27b9161e772ec3fd64c8ee9955787d583e (patch) | |
tree | 9c233c030b85adee499edc3badf256ad989d31a1 /include/clang/AST/DeclTemplate.h | |
parent | 0c29653a59e47624ec37f4e607976449fb975f44 (diff) |
[Sema] Implement __make_integer_seq
This new builtin template allows for incredibly fast instantiations of
templates like std::integer_sequence.
Performance numbers follow:
My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz.
__make_integer_seq<std::integer_sequence, int, 90000> takes 0.25
seconds.
std::make_integer_sequence<int, 90000> takes unbound time, it is still
running. Clang is consuming gigabytes of memory.
Differential Revision: http://reviews.llvm.org/D13786
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index bd38ac8823..a23fe4b5e5 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -25,6 +25,7 @@ namespace clang { +enum BuiltinTemplateKind : int; class TemplateParameterList; class TemplateDecl; class RedeclarableTemplateDecl; @@ -1490,6 +1491,35 @@ public: friend TrailingObjects; }; +/// \brief Represents the builtin template declaration which is used to +/// implement __make_integer_seq. It serves no real purpose beyond existing as +/// a place to hold template parameters. +class BuiltinTemplateDecl : public TemplateDecl { + void anchor() override; + + BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC, + DeclarationName Name, BuiltinTemplateKind BTK); + + BuiltinTemplateKind BTK; + +public: + // Implement isa/cast/dyncast support + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == BuiltinTemplate; } + + static BuiltinTemplateDecl *Create(const ASTContext &C, DeclContext *DC, + DeclarationName Name, + BuiltinTemplateKind BTK) { + return new (C, DC) BuiltinTemplateDecl(C, DC, Name, BTK); + } + + SourceRange getSourceRange() const override LLVM_READONLY { + return SourceRange(); + } + + BuiltinTemplateKind getBuiltinTemplateKind() const { return BTK; } +}; + /// \brief Represents a class template specialization, which refers to /// a class template with a given set of template arguments. /// |