[PATCH] D19771: Rework FixedSizeTemplateParameterListStorage
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Mon May 2 08:30:25 PDT 2016
hubert.reinterpretcast updated this revision to Diff 55825.
hubert.reinterpretcast added a comment.
Adjust for changes to http://reviews.llvm.org/D19770
http://reviews.llvm.org/D19771
Files:
include/clang/AST/DeclTemplate.h
Index: include/clang/AST/DeclTemplate.h
===================================================================
--- include/clang/AST/DeclTemplate.h
+++ include/clang/AST/DeclTemplate.h
@@ -141,31 +141,20 @@
/// \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];
+template <size_t N>
+class FixedSizeTemplateParameterListStorage
+ : public TemplateParameterList::FixedSizeStorageOwner {
+ typename TemplateParameterList::FixedSizeStorage<
+ NamedDecl *>::with_counts<
+ N>::type storage;
public:
FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef<NamedDecl *> Params,
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; }
+ : FixedSizeStorageOwner(new (static_cast<void *>(&storage))
+ TemplateParameterList(TemplateLoc, LAngleLoc, Params, RAngleLoc)) {}
};
/// \brief A template argument list.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19771.55825.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160502/1f3495d4/attachment-0001.bin>
More information about the cfe-commits
mailing list