summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/DeclTemplate.h
diff options
context:
space:
mode:
authorHubert Tong <hubert.reinterpretcast@gmail.com>2016-07-20 01:05:31 +0000
committerHubert Tong <hubert.reinterpretcast@gmail.com>2016-07-20 01:05:31 +0000
commit06a1ffe84a23ff5d11dcf3f42ea024a6aee594bd (patch)
treee00aa6705e691ce8a8495ed0e1717cd0cb9276ce /include/clang/AST/DeclTemplate.h
parent23def507c579930c931c7aa85909d6c30cfcc62d (diff)
Revert r276069: MSVC bots not happy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r--include/clang/AST/DeclTemplate.h77
1 files changed, 27 insertions, 50 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index e70b29e53a..10ec5aa9fc 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -46,8 +46,7 @@ typedef llvm::PointerUnion3<TemplateTypeParmDecl*, NonTypeTemplateParmDecl*,
/// \brief Stores a list of template parameters for a TemplateDecl and its
/// derived classes.
class TemplateParameterList final
- : private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
- Expr *> {
+ : private llvm::TrailingObjects<TemplateParameterList, NamedDecl *> {
/// The location of the 'template' keyword.
SourceLocation TemplateLoc;
@@ -57,36 +56,26 @@ class TemplateParameterList final
/// The number of template parameters in this template
/// parameter list.
- unsigned NumParams : 30;
+ unsigned NumParams : 31;
/// Whether this template parameter list contains an unexpanded parameter
/// pack.
unsigned ContainsUnexpandedParameterPack : 1;
- /// Whether this template parameter list has an associated requires-clause
- unsigned HasRequiresClause : 1;
-
protected:
size_t numTrailingObjects(OverloadToken<NamedDecl *>) const {
return NumParams;
}
- size_t numTrailingObjects(OverloadToken<Expr *>) const {
- return HasRequiresClause;
- }
-
TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc,
- ArrayRef<NamedDecl *> Params, SourceLocation RAngleLoc,
- Expr *RequiresClause);
+ ArrayRef<NamedDecl *> Params, SourceLocation RAngleLoc);
public:
- // FIXME: remove default argument for RequiresClause
static TemplateParameterList *Create(const ASTContext &C,
SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef<NamedDecl *> Params,
- SourceLocation RAngleLoc,
- Expr *RequiresClause = nullptr);
+ SourceLocation RAngleLoc);
/// \brief Iterates through the template parameters in this list.
typedef NamedDecl** iterator;
@@ -138,16 +127,6 @@ public:
return ContainsUnexpandedParameterPack;
}
- /// \brief The constraint-expression of the associated requires-clause.
- Expr *getRequiresClause() {
- return HasRequiresClause ? *getTrailingObjects<Expr *>() : nullptr;
- }
-
- /// \brief The constraint-expression of the associated requires-clause.
- const Expr *getRequiresClause() const {
- return HasRequiresClause ? *getTrailingObjects<Expr *>() : nullptr;
- }
-
SourceLocation getTemplateLoc() const { return TemplateLoc; }
SourceLocation getLAngleLoc() const { return LAngleLoc; }
SourceLocation getRAngleLoc() const { return RAngleLoc; }
@@ -157,33 +136,36 @@ public:
}
friend TrailingObjects;
-
- template <size_t N, bool HasRequiresClause>
- friend class FixedSizeTemplateParameterListStorage;
+ template <size_t N> friend class FixedSizeTemplateParameterListStorage;
};
-/// \brief Stores a list of template parameters and the associated
-/// requires-clause (if any) for a TemplateDecl and its derived classes.
-/// Suitable for creating on the stack.
-template <size_t N, bool HasRequiresClause>
-class FixedSizeTemplateParameterListStorage
- : public TemplateParameterList::FixedSizeStorageOwner {
- typename TemplateParameterList::FixedSizeStorage<
- NamedDecl *, Expr *>::with_counts<
- N, HasRequiresClause ? 1u : 0u
- >::type storage;
+/// \brief Stores a list of template parameters for a TemplateDecl and its
+/// derived classes. Suitable for creating on the stack.
+template <size_t N> class FixedSizeTemplateParameterListStorage {
+ // This is kinda ugly: TemplateParameterList usually gets allocated
+ // in a block of memory with NamedDecls appended to it. Here, to get
+ // it stack allocated, we include the params as a separate
+ // variable. After allocation, the TemplateParameterList object
+ // treats them as part of itself.
+ TemplateParameterList List;
+ NamedDecl *Params[N];
public:
FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef<NamedDecl *> Params,
- SourceLocation RAngleLoc,
- Expr *RequiresClause)
- : FixedSizeStorageOwner(
- (assert(N == Params.size()),
- assert(HasRequiresClause == static_cast<bool>(RequiresClause)),
- new (static_cast<void *>(&storage)) TemplateParameterList(
- TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
+ SourceLocation RAngleLoc)
+ : List(TemplateLoc, LAngleLoc, Params, RAngleLoc) {
+ // Because we're doing an evil layout hack above, have some
+ // asserts, just to double-check everything is laid out like
+ // expected.
+ assert(sizeof(*this) ==
+ TemplateParameterList::totalSizeToAlloc<NamedDecl *>(N) &&
+ "Object layout not as expected");
+ assert(this->Params == List.getTrailingObjects<NamedDecl *>() &&
+ "Object layout not as expected");
+ }
+ TemplateParameterList *get() { return &List; }
};
/// \brief A template argument list.
@@ -371,11 +353,6 @@ public:
return TemplateParams;
}
- /// Get the constraint-expression from the associated requires-clause (if any)
- const Expr *getRequiresClause() const {
- return TemplateParams ? TemplateParams->getRequiresClause() : nullptr;
- }
-
/// Get the underlying, templated declaration.
NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); }