[PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 13 13:43:13 PST 2016
rsmith added inline comments.
================
Comment at: include/clang/Basic/Builtins.h:216-219
@@ -215,3 +215,6 @@
/// \brief This names the __make_integer_seq BuiltinTemplateDecl.
BTK__make_integer_seq
+
+ /// \brief This names the __nth_element BuiltinTemplateDecl.
+ , BTK__nth_element
};
----------------
Please put the comma after `BTK__make_integer_seq`, not on this line.
================
Comment at: lib/AST/DeclTemplate.cpp:1243
@@ +1242,3 @@
+static TemplateParameterList *
+createNthElement(const ASTContext &C, DeclContext *DC) {
+ // typename IndexType
----------------
Rename this `createNthElementParameterList`.
================
Comment at: lib/AST/DeclTemplate.cpp:1244-1248
@@ +1243,7 @@
+createNthElement(const ASTContext &C, DeclContext *DC) {
+ // typename IndexType
+ auto *IndexType = TemplateTypeParmDecl::Create(
+ C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
+ /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false);
+ IndexType->setImplicit(true);
+
----------------
Use `NonTypeTemplateParmDecl::Create`. You can get `size_t` from `ASTContext::getSizeType`.
================
Comment at: lib/Sema/SemaTemplate.cpp:2102-2103
@@ +2101,4 @@
+ // We simply return the type at index `Index`.
+ // TODO:
+ // What are the implications of calling .getExtValue() on an APSInt?
+ assert(Index.getExtValue() == Index &&
----------------
`getExtValue` is OK here, as we don't support `size_t` being larger than 64 bits.
http://reviews.llvm.org/D15421
More information about the cfe-commits
mailing list