-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-cl] [AST] Fix MS 1920+ placeholder return type mangling for lambdas #105999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-cl] [AST] Fix MS 1920+ placeholder return type mangling for lambdas #105999
Conversation
@llvm/pr-subscribers-clang Author: Max Winkler (MaxEW707) ChangesFixes #104722. Missed handling Added some missing unit tests to test for the various placeholder trailing return types in lambdas. Full diff: https://github.com/llvm/llvm-project/pull/105999.diff 2 Files Affected:
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index b539681984ef7c..018ab617a0ecee 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2967,13 +2967,12 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
mangleType(ResultType, Range, QMM_Result);
} else if (IsInLambda) {
if (const auto *AT = ResultType->getContainedAutoType()) {
- assert(AT->getKeyword() == AutoTypeKeyword::Auto &&
- "should only need to mangle auto!");
- (void)AT;
+ assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+ "shouldn't need to mangle __auto_type!");
Out << '?';
mangleQualifiers(ResultType.getLocalQualifiers(), /*IsMember=*/false);
Out << '?';
- mangleSourceName("<auto>");
+ mangleSourceName(AT->isDecltypeAuto() ? "<decltype-auto>" : "<auto>");
Out << '@';
} else {
Out << '@';
diff --git a/clang/test/CodeGenCXX/mangle-ms-auto-return.cpp b/clang/test/CodeGenCXX/mangle-ms-auto-return.cpp
index 5b18dcc0820ee6..0cf59ac962a764 100644
--- a/clang/test/CodeGenCXX/mangle-ms-auto-return.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms-auto-return.cpp
@@ -215,6 +215,8 @@ void test_template_decltypeauto() {
// Still want to use clang's custom mangling for lambdas to keep backwards compatibility until
// MSVC lambda name mangling has been deciphered.
void test_lambda() {
+ int i = 0;
+
auto lambdaIntRetAuto = []() { return 0; };
lambdaIntRetAuto();
// CHECK: call {{.*}} @"??R<lambda_1>@?0??test_lambda@@YAXXZ@QEBA?A?<auto>@@XZ"
@@ -226,6 +228,18 @@ void test_lambda() {
auto lambdaGenericIntIntRetAuto = [](auto a) { return a; };
lambdaGenericIntIntRetAuto(0);
// CHECK: call {{.*}} @"??$?RH@<lambda_0>@?0??test_lambda@@YAXXZ@QEBA?A?<auto>@@H@Z"
+
+ auto lambdaRetTrailingAuto = []() -> auto { return 0; };
+ lambdaRetTrailingAuto();
+ // CHECK: call {{.*}} @"??R<lambda_3>@?0??test_lambda@@YAXXZ@QEBA?A?<auto>@@XZ"
+
+ auto lambdaRetTrailingDecltypeAuto = []() -> decltype(auto) { return 0; };
+ lambdaRetTrailingDecltypeAuto();
+ // CHECK: call {{.*}} @"??R<lambda_4>@?0??test_lambda@@YAXXZ@QEBA?A?<decltype-auto>@@XZ"
+
+ auto lambdaRetTrailingRefCollapse = [](int x) -> auto&& { return x; };
+ lambdaRetTrailingRefCollapse(i);
+ // CHECK: call {{.*}} @"??R<lambda_5>@?0??test_lambda@@YAXXZ@QEBA?A?<auto>@@H@Z"
}
auto TestTrailingInt() -> int {
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/3102 Here is the relevant piece of the build log for the reference
|
I took a look and it appears this is a common spurious failure on this build bot. |
…e321d5030 Local branch amd-gfx 6cde321 Merged main:b10303730d7cd009ad505da307b417aaecc91f51 into amd-gfx:c1c160c3b024 Remote branch main 2579b41 [clang-cl] [AST] Fix MS 1920+ placeholder return type mangling for lambdas (llvm#105999)
Fixes #104722.
Missed handling
decltype(auto)
trailing return types for lambdas.This was a mistake and regression on my part with my PR, #104722.
Added some missing unit tests to test for the various placeholder trailing return types in lambdas.