================
@@ -916,6 +916,135 @@ def test_get_template_argument_unsigned_value(self):
         self.assertEqual(foos[1].get_template_argument_unsigned_value(0), 
2**32 - 7)
         self.assertEqual(foos[1].get_template_argument_unsigned_value(2), True)
 
+    def test_get_template_argument_integral_type(self):
+        tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
+        foos = get_cursors(tu, "foo")
+
+        self.assertEqual(
+            foos[1].get_template_argument_integral_type(0).kind, TypeKind.INT
+        )
+        self.assertEqual(
+            foos[1].get_template_argument_integral_type(1).kind,
+            TypeKind.INVALID,
+        )
+        self.assertEqual(
+            foos[1].get_template_argument_integral_type(2).kind, TypeKind.BOOL
+        )
+
+    def test_get_template_argument_integral_type_pack(self):
+        source = """
+            template<int... Ns> struct Foo {};
+            template class Foo<1, 2, 3>;
+        """
+        tu = get_tu(source, lang="cpp")
+        foo = get_cursor(tu, "Foo")
+        # Find the specialization.
+        spec = None
+        for c in tu.cursor.walk_preorder():
+            if c.kind == CursorKind.STRUCT_DECL and c.spelling == "Foo":
+                if c.get_num_template_arguments() >= 0:
+                    spec = c
+                    break
----------------
DeinAlptraum wrote:

Is there a reason you need to do a walk here?
If not, I would prefer you solve this via `get_cursors` as you did in the 
previous test, then just pick the element at the correct index and assert that 
it's a `STRUCT_DECL` 

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