================
@@ -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,
----------------
AaronBallman wrote:

> Thinking about it again, I'd prefer 
> `clang_Cursor_getNonTypeTemplateArgumentType` after all. Extending 
> `clang_Cursor_getTemplateArgumentType` would conflate two different things: 
> returning the type that **is** the argument vs. the type **of** the 
> argument's value. It would also silently break existing uses where 
> `clang_Cursor_getTemplateArgumentType(C, I).kind != CXType_Invalid` is used 
> to detect whether an argument is a type argument. (Not that far fetched imo)

The parameter and the argument can have different types, but I don't see how 
the argument and the argument value can have different types. e.g., `template 
<short N> void func(short s = N); func<12>();`. I would expect 
`clang_Cursor_getTemplateArgumentType()` to return `int` in that case, not 
`short`.

Huh, and it seems 1) we also have `clang_Type_getTemplateArgumentAsType()` for 
reasons I don't yet understand, and 2) we don't have interfaces for template 
*parameters* which makes me concerned we've conflated ideas in the APIs. CC 
@erichkeane for template maintainer eyeballs.

https://github.com/llvm/llvm-project/pull/183504
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to