================
@@ -3267,7 +3267,29 @@ CINDEX_LINKAGE CXType
clang_Cursor_getTemplateArgumentType(CXCursor C,
unsigned I);
/**
- * Retrieve the value of an Integral TemplateArgument (of a function
+ * Retrieve the type of an Integral TemplateArgument at a given index.
+ *
+ * For example, for:
+ * template <typename T, int N>
+ * void foo() {}
+ *
+ * template <>
+ * void foo<float, 42>();
+ *
+ * If called with I = 1, the type "int" will be returned (the type of the
+ * integral argument 42). An invalid type is returned if the argument at
+ * index I is not integral, or if the index is out of range.
+ *
+ * \param C a cursor representing a template specialization.
+ * \param I the zero-based index of the template argument.
+ *
+ * \returns the type of the integral template argument, or an invalid type.
+ */
+CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentIntegralType(CXCursor C,
----------------
fscheidl wrote:
My earlier reasoning was that a type template argument is a type, while a
non-type template argument has a type. Since these are different semantic
operations, my intuition was to not put them in the same accessor.
In the original proposal `clang_Cursor_getTemplateArgumentIntegralType` returns
the type after conversion (so it's actually `short` in your example, not `int`)
which is indeed the type of the NTTP, not the type of the expression that is
passed as argument. So `clang_Cursor_getNonTypeTemplateArgumentType` (or
whatever we call it) would really be returning the parameter type for non-type
arguments, which is definitely worth being precise about in the docs (and
naming!).
FWIW The function argument accessors like `clang_getNumArgTypes` and
`clang_getArgType` might invite a similar discussion, since they actually refer
to function parameters and not the passed arguments.
Happy to wait for @erichkeane's input on the naming/semantics.
https://github.com/llvm/llvm-project/pull/183504
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits