[PATCH] D13786: [Sema] Implement __make_integer_seq

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 11:21:35 PST 2015


rsmith added inline comments.

================
Comment at: lib/AST/ASTDumper.cpp:1340-1344
@@ +1339,7 @@
+  dumpName(D);
+  switch (D->getBuiltinTemplateKind()) {
+  case BTK__make_integer_seq:
+    OS << " __make_integer_seq";
+    break;
+  }
+  dumpTemplateParameters(D->getTemplateParameters());
----------------
This seems redundant given that you dumped the name on the prior line.

================
Comment at: lib/AST/DeclTemplate.cpp:1204
@@ +1203,3 @@
+
+  // Ints...
+  TypeSourceInfo *TI =
----------------
I think you mean `T ...Ints` (and likewise in comments below).

================
Comment at: lib/AST/DeclTemplate.cpp:1229
@@ +1228,3 @@
+
+  // Ints...
+  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(
----------------
This should be `T N` or similar, right? (In particular, it's not a pack.)

================
Comment at: lib/Sema/SemaTemplate.cpp:2176-2178
@@ -2173,1 +2175,5 @@
            "type of non-dependent specialization is not a RecordType");
+  } else if (auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
+    switch (BTD->getBuiltinTemplateKind()) {
+    case BTK__make_integer_seq:
+      // Specializations of __make_integer_seq<S, T, N> are treated like
----------------
Factor this out into a separate function to compute the canonical type for a builtin template; `CheckTemplateIdType` is long enough already :)

================
Comment at: lib/Sema/SemaTemplate.cpp:2210
@@ +2209,3 @@
+        Expr *E =
+            BuildExpressionFromIntegralTemplateArgument(TA, SourceLocation())
+                .getAs<Expr>();
----------------
Maybe use the location from the third template argument here?

================
Comment at: lib/Serialization/ASTReaderDecl.cpp:1861
@@ +1860,3 @@
+void ASTDeclReader::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) {
+  llvm_unreachable("BuiltinTemplates are not serialized");
+}
----------------
So what happens when we serialize an AST that references a builtin template? It's probably best to treat them as predefined declarations (look for existing references to `PREDEF_DECL_*` to see how this should fit in).


http://reviews.llvm.org/D13786





More information about the cfe-commits mailing list