compiler/types: Fix array name dimension flipping for unsized arrays
authorCaio Oliveira <caio.oliveira@intel.com>
Fri, 26 May 2023 18:23:19 +0000 (11:23 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 15 Sep 2023 01:21:40 +0000 (01:21 +0000)
commitc9b7639a7dc88f677aebc190f2474af26fa36f8a
treee244eeb24b5c12699cf3d61011e7b4876ad01a5f
parentea998ddd348b614b9c1f39a90cc6476534b3adcc
compiler/types: Fix array name dimension flipping for unsized arrays

Rewrite the code to use linear_asprintf and always flip the
dimensions in place if the element type is an array.  The new
code will now (correctly) flip even in the case of unsized arrays.

The flipping is done by swapping the ranges [a, b) and [b, c), as
shown below, with element type int[...] and an array of length 4.

```
           +--------------- a: first bracket in the name
           |    +---------- b: end of the element name
           |    |  +------- c: end of the array name
           |    |  |
        int[...][4]$

will be transformed into

        int[4][...]$
```

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23278>
src/compiler/glsl_types.cpp