[clang] 56b9844 - [clang][AST] Fix spaces in TypePrinter for some calling convs (#143160)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 7 09:47:32 PDT 2025
Author: Nick Sarnie
Date: 2025-06-07T16:47:28Z
New Revision: 56b98449c8f047c983508b13294a9610f8df0e2b
URL: https://github.com/llvm/llvm-project/commit/56b98449c8f047c983508b13294a9610f8df0e2b
DIFF: https://github.com/llvm/llvm-project/commit/56b98449c8f047c983508b13294a9610f8df0e2b.diff
LOG: [clang][AST] Fix spaces in TypePrinter for some calling convs (#143160)
There needs to be a space as the first character, otherwise the printed
function prototype will have the CC attribute attached to the final `)`.
I noticed this looking at the AST for a function with
`__attribute__((device_kernel))`
---------
Signed-off-by: Sarnie, Nick <nick.sarnie at intel.com>
Added:
clang/test/AST/ast-dump-type-callingconv.cpp
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/AST/TypePrinter.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 74a205a85da5c..1dd8b794c943a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -842,6 +842,7 @@ Bug Fixes to AST Handling
- Fixed type checking when a statement expression ends in an l-value of atomic type. (#GH106576)
- Fixed uninitialized use check in a lambda within CXXOperatorCallExpr. (#GH129198)
- Fixed a malformed printout of ``CXXParenListInitExpr`` in certain contexts.
+- Fixed a malformed printout of certain calling convention function attributes. (#GH143160)
Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
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))";
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..1611223acbc80
--- /dev/null
+++ b/clang/test/AST/ast-dump-type-callingconv.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple aarch64 -ast-dump -ast-dump-filter foo %s \
+// RUN: | FileCheck --strict-whitespace %s
+
+// CHECK: foo1 'void () __attribute__((device_kernel))'{{$}}
+void foo1() __attribute__((device_kernel));
+
+// CHECK: foo2 'void () __attribute__((aarch64_vector_pcs))'{{$}}
+void foo2() __attribute__((aarch64_vector_pcs));
+
+// CHECK: foo3 'void () __attribute__((aarch64_sve_pcs))'{{$}}
+void foo3() __attribute__((aarch64_sve_pcs));
More information about the cfe-commits
mailing list