[clang] [libclang/python] Add non ref and unqualified getters for types (PR #175534)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 13 18:56:47 PDT 2026


================
@@ -530,6 +530,43 @@ def test_pretty(self):
         pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False)
         self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X")
 
+    def test_non_reference(self):
+        source = """
+        int dummy;
+        int &reference;
+        """
+        tu = get_tu(source, lang="cpp")
+        dummy = get_cursor(tu, "dummy")
+        reference = get_cursor(tu, "reference")
+        self.assertEqual(reference.type.get_non_reference().spelling, "int")
+        self.assertEqual(dummy.type.spelling, dummy.type.get_non_reference().spelling)
+
+    def test_unqualified(self):
----------------
Endilll wrote:

If you look at [documentation](https://github.com/llvm/llvm-project/blob/8b9be7f685c371706171b603f2a96de53ef833b6/clang/include/clang/AST/TypeBase.h#L1233-L1255) for `clang::QualType::GetUnqualifiedType()`, there are number of quirk to that function, namely:
- looking through typedefs if they add qualifiers,
- `_Atomic` is ignored,
- arrays have special handling.

They should be reflected in both tests and docstring of the new function.

https://github.com/llvm/llvm-project/pull/175534


More information about the cfe-commits mailing list