Commit ab187bb
authored
[clang][AST] Fix positioning of preserve cconv attributes in TypePrinter (llvm#147285)
TypePrinter currently generates function pointer types that do not
compile when using the `preserve_.*` calling conventions as per
https://clang.llvm.org/docs/AttributeReference.html#preserve-all ff.
Running clang with `-Xclang -ast-print` on the following:
```cc
using IN1 = void (__attribute__((preserve_most)) *)();
using IN2 = __attribute__((preserve_most)) void (*) ();
```
outputs:
```cc
using IN1 = void (*)() __attribute__((preserve_most));
using IN2 = void ((*))() __attribute__((preserve_most));
```
However, this does not compile:
```cc
<source>:3:23: error: expected ';' after alias declaration
3 | using IN1 = void (*)() __attribute__((preserve_most));
```
This PR updates TypePrinter such that output is correct and compiles:
```cc
using IN1 = __attribute__((preserve_most)) void (*)();
using IN2 = __attribute__((preserve_most)) void ((*))();
```
I've verified via `-ast-dump` that the AST looks equivalent.1 parent 27c9b55 commit ab187bb
File tree
5 files changed
+46
-19
lines changed- clang
- lib/AST
- test
- AST
- SemaCXX
- Sema
5 files changed
+46
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1861 | 1861 | | |
1862 | 1862 | | |
1863 | 1863 | | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
1864 | 1875 | | |
1865 | 1876 | | |
1866 | 1877 | | |
| |||
1972 | 1983 | | |
1973 | 1984 | | |
1974 | 1985 | | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
1975 | 1993 | | |
1976 | 1994 | | |
1977 | 1995 | | |
| |||
2036 | 2054 | | |
2037 | 2055 | | |
2038 | 2056 | | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
2039 | 2060 | | |
2040 | 2061 | | |
2041 | 2062 | | |
| |||
2071 | 2092 | | |
2072 | 2093 | | |
2073 | 2094 | | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
2080 | | - | |
| 2095 | + | |
| 2096 | + | |
2081 | 2097 | | |
2082 | 2098 | | |
2083 | 2099 | | |
2084 | 2100 | | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | 2101 | | |
2089 | 2102 | | |
2090 | 2103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments