<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61810>61810</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Possible regression in libclang clang_getTypeSpelling
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          gjasny
      </td>
    </tr>
</table>

<pre>
    Hello,

I inherited a code generator that is based on [luaclang](https://github.com/mkottman/luaclang-parser) and the libclang C interface.
That generator can be used to create pimpl-like proxy interfaces or Google Mock classes for existing interfaces.

While upgrading libclang from v15 to v16 I noticed a change in `clang_getTypeSpelling`. Before v16 it printed fully qualified namespaces for function argument types, now only the types as written in the declaration itself.

I created a small test case within the libclang python binding test:

```diff
diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py
index efe9b0f50be8..4f1ade7ab2f1 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -466,3 +466,30 @@ class TestType(unittest.TestCase):
         # Variable without a template argument.
         cursor = get_cursor(tu, 'bar')
 self.assertEqual(cursor.get_num_template_arguments(), -1)
+
+    def test_type_spelling_namespace(self):
+        """Ensure Type.spelling prints whole namespace."""
+
+        source ="""
+namespace X {
+    namespace Y {
+        struct Params {
+            int i;
+        };
+        struct Foo {
+            virtual void f(const Params& p) = 0;
+        };
+    }
+}
+    """
+ tu = get_tu(source, lang='cpp')
+        f = get_cursor(tu, 'f')
+ self.assertIsNotNone(f)
+
+        args = f.type.argument_types()
+        self.assertIsNotNone(args)
+ self.assertEqual(len(args), 1)
+
+        t0 = args[0]
+ self.assertIsNotNone(t0)
+        self.assertEqual(t0.spelling, 'const X::Y::Params &')
```

The test works as expected on the `release/15.x` branch but fails on the `release/16.x` branch:
```
$ ninja check-clang-python
...
======================================================================
FAIL: test_type_spelling_namespace (tests.cindex.test_type.TestType)
Ensure Type.is_function_variadic works.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gregorj/src/llvm-project/clang/bindings/python/tests/cindex/test_type.py", line 495, in test_type_spelling_namespace
 self.assertEqual(t0.spelling, 'const X::Y::Params &')
AssertionError: 'const Params &' != 'const X::Y::Params &'
- const Params &
+ const X::Y::Params &
?       ++++++
```

Would the change in behaviour above qualify as a regression? If not, is there a way to restore the old behaviour somehow?

Thanks,
Gregor
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV92OqzgSfhrnphQEJpDkIhfd6cNsS7ujkfZoZ-YqMlCATxubtU3SeftVASHp3zNSz9Ui1E1s11fl8lc_Fs7JWiPuWHLPkoeF6H1j7K7-IZw-L3JTnnf_QKUM43sWPrDwbvz7CFI3aKXHEgQUpkSoUaMV3ljwjfAgHeTCYQlGA0vuVS8KJXTNkgfGN433nWPxHeMZ41ktfdPnQWFaxrP2yXjfCs14dpFZdsI6tIxvQegSfIOgZD5MwR6k9mgrUWAwmvadtF-NKYSGHKEnU7yBwqLwCJ1sO7VU8gmhs-b5fEVxYCz8YkytEP5liicolHAOHVTGAj5L56Wub5YHt275vZEKoe9qK0paNptZWdPCMUrIhGOUwiNo42Uxeq8RukaQGlgaDssPNfrv5w7_3aFSUtcsDQO4x8pYHKSlh86SCSVUvVJn-G8vlKwklqBFi64b9kEGV70uvDQahK37FrUHf-7QMb4HbU5gtDoP_hxGQTg4Wek9arKGxksslLBigJDeoaqClzQY_UnbcK1QCjw6D4VwCCfpmwlldkN39o3RkEs9uIcWEwtuEFkajm8pq2ocoi9YLmvpQTCejTTi2QTiGM9GWMYzAqSBQuoSn6eBA20u6M6Qf0V6tGWYAaxwm4dVEua4CYJVFYkS1yLnVQRRGKar1bh4uVx-zeLJJfx-fP-ODbBVyFYhLFdpyvg-Bsbvp88QprmB8PAd3cBBxje9Jk44H9DYXjhkfDsfG1wexmP4j7BS5Go8fN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