[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:36 PDT 2025
https://github.com/sarnex updated https://github.com/llvm/llvm-project/pull/143160
>From 56f19d4f839d1c65a3f1145fcdcac5207ff61c11 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sarnie at intel.com>
Date: Fri, 6 Jun 2025 08:21:56 -0700
Subject: [PATCH 1/3] [clang][AST] Fix spaces TypePrinter for some calling
convs
Signed-off-by: Sarnie, Nick <nick.sarnie at intel.com>
---
clang/lib/AST/TypePrinter.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 330cfcd962825..d18723d807c6a 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1095,13 +1095,13 @@ void TypePrinter::printFunctionAfter(const FunctionType::ExtInfo &Info,
OS << " __attribute__((pcs(\"aapcs-vfp\")))";
break;
case CC_AArch64VectorCall:
- OS << "__attribute__((aarch64_vector_pcs))";
+ OS << " __attribute__((aarch64_vector_pcs))";
break;
case CC_AArch64SVEPCS:
- OS << "__attribute__((aarch64_sve_pcs))";
+ OS << " __attribute__((aarch64_sve_pcs))";
break;
case CC_DeviceKernel:
- OS << "__attribute__((device_kernel))";
+ OS << " __attribute__((device_kernel))";
break;
case CC_IntelOclBicc:
OS << " __attribute__((intel_ocl_bicc))";
>From c99bb95b1725bc28d48c97edd4a4ad6f057210a9 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sarnie at intel.com>
Date: Fri, 6 Jun 2025 09:57:31 -0700
Subject: [PATCH 2/3] add test
Signed-off-by: Sarnie, Nick <nick.sarnie at intel.com>
---
clang/test/AST/ast-dump-type-callingconv.cpp | 24 ++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 clang/test/AST/ast-dump-type-callingconv.cpp
diff --git a/clang/test/AST/ast-dump-type-callingconv.cpp b/clang/test/AST/ast-dump-type-callingconv.cpp
new file mode 100644
index 0000000000000..d7d6b823c5244
--- /dev/null
+++ b/clang/test/AST/ast-dump-type-callingconv.cpp
@@ -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
>From 8f1346cf976cfc1cb3b610d3fd0af4375c9cdbe3 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sarnie at intel.com>
Date: Fri, 6 Jun 2025 10:26:19 -0700
Subject: [PATCH 3/3] improve test
Signed-off-by: Sarnie, Nick <nick.sarnie at intel.com>
---
clang/test/AST/ast-dump-type-callingconv.cpp | 29 ++++++--------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/clang/test/AST/ast-dump-type-callingconv.cpp b/clang/test/AST/ast-dump-type-callingconv.cpp
index d7d6b823c5244..4abeec37d1876 100644
--- a/clang/test/AST/ast-dump-type-callingconv.cpp
+++ b/clang/test/AST/ast-dump-type-callingconv.cpp
@@ -1,24 +1,11 @@
-// 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 -triple aarch64 -ast-dump -ast-dump-filter foo %s \
+// RUN: | FileCheck --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
+// CHECK: {{foo1 'void \(\) __attribute__\(\(device_kernel\)\)'$}}
+void foo1() __attribute__((device_kernel));
-// RUN: %clang_cc1 -DSVE -triple aarch64 -ast-dump -ast-dump-filter foo %s \
-// RUN: | FileCheck -check-prefix=CHECK-SVE --strict-whitespace %s
+// CHECK: {{foo2 'void \(\) __attribute__\(\(aarch64_vector_pcs\)\)'$}}
+void foo2() __attribute__((aarch64_vector_pcs));
-#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
+// CHECK: {{foo3 'void \(\) __attribute__\(\(aarch64_sve_pcs\)\)'$}}
+void foo3() __attribute__((aarch64_sve_pcs));
More information about the cfe-commits
mailing list