[clang] [clang][AST] Fix spaces in TypePrinter for some calling convs (PR #143160)
Nick Sarnie via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 6 10:45:37 PDT 2025
================
@@ -0,0 +1,24 @@
+// Verify there is a space after the parens when priting callingconv attributes.
+// RUN: %clang_cc1 -DDEVICE -triple spirv64 -ast-dump -ast-dump-filter foo %s \
+// RUN: | FileCheck -check-prefix=CHECK-DEVICE --strict-whitespace %s
+
+// RUN: %clang_cc1 -DVECTOR -triple aarch64 -ast-dump -ast-dump-filter foo %s \
+// RUN: | FileCheck -check-prefix=CHECK-VECTOR --strict-whitespace %s
+
+// RUN: %clang_cc1 -DSVE -triple aarch64 -ast-dump -ast-dump-filter foo %s \
+// RUN: | FileCheck -check-prefix=CHECK-SVE --strict-whitespace %s
+
+#ifdef DEVICE
+// CHECK-DEVICE-NOT: ()__attribute__((device_kernel))
+void foo() __attribute__((device_kernel));
+#endif
+
+#ifdef VECTOR
+// CHECK-VECTOR-NOT: ()__attribute__((aarch64_vector_pcs))
+void foo() __attribute__((aarch64_vector_pcs));
+#endif
+
+#ifdef SVE
+// CHECK-SVE-NOT: ()__attribute__((aarch64_sve_pcs))
+void foo() __attribute__((aarch64_sve_pcs));
+#endif
----------------
sarnex wrote:
Thanks for the review. I did the negative check because before this change the AST print is a little different for some reason where it contains the good string as part of the overall string, ex:
```
foo3 'void () __attribute__((aarch64_sve_pcs))':'void ()__attribute__((aarch64_sve_pcs))'
```
and after the fix the output is only
```
foo3 'void () __attribute__((aarch64_sve_pcs))'
```
so checking for `foo3 'void () __attribute__((aarch64_sve_pcs))'` doesn't work because it's a substring in the bad case.
but I managed to fix it by using regex and checking for EOL, it's not super pretty though, just pushed it, thanks.
https://github.com/llvm/llvm-project/pull/143160
More information about the cfe-commits
mailing list