Skip to content

Commit 926e10f

Browse files
authored
Merge pull request #42100 from hyp/i/cxxkwarguse
[cxx-interop] emit correct parameter name in the inline C++ function …
2 parents 128d6e1 + 8d4366b commit 926e10f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ class DeclAndTypePrinter::Implementation
881881
size_t index = 1;
882882
interleaveComma(*params, os, [&](const ParamDecl *param) {
883883
if (param->hasName()) {
884-
os << param->getName();
884+
ClangSyntaxPrinter(os).printIdentifier(param->getName().str());
885885
} else {
886886
os << "_" << index;
887887
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-public-decls -emit-clang-header-path %t/functions.h
3+
// RUN: %FileCheck %s < %t/functions.h
4+
5+
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
6+
7+
// CHECK: inline void testKeywordArgument(swift::Int register_) noexcept
8+
// CHECK-NEXT: return _impl::$s9Functions19testKeywordArgument8registerySi_tF(register_);
9+
10+
func testKeywordArgument(register: Int) {
11+
}

0 commit comments

Comments
 (0)