[all-commits] [llvm/llvm-project] 95566a: [Clang][AST] Fix MS Mangle concept uneval context ...
Max Winkler via All-commits
all-commits at lists.llvm.org
Tue Dec 3 20:18:37 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 95566af789d208b8fc422644ab282a43911041f2
https://github.com/llvm/llvm-project/commit/95566af789d208b8fc422644ab282a43911041f2
Author: Max Winkler <max.enrico.winkler at gmail.com>
Date: 2024-12-03 (Tue, 03 Dec 2024)
Changed paths:
M clang/lib/AST/MicrosoftMangle.cpp
A clang/test/CodeGenCXX/ms-uneval-context-crash.cpp
Log Message:
-----------
[Clang][AST] Fix MS Mangle concept uneval context template instantiation crash (#117845)
Fixes https://github.com/llvm/llvm-project/issues/115990.
MSVC mangling got inadvertently broken here,
https://github.com/llvm/llvm-project/pull/83997, when it was fixed what
decl context a lambda is apart of for uneval contexts.
https://godbolt.org/z/K6jb5v145 for reference.
Given the following code snippet
```
template <typename T>
concept C = requires(const T& t)
{
{ T::test([](){}) };
};
template<typename T, typename = void>
struct Widget;
template <C T>
struct Widget<T> {};
struct Baz
{
template<typename F>
static constexpr decltype(auto) test(F&& f) {}
};
void test()
{
Widget<Baz> w;
}
```
`Baz::test` has a deduced return type which means we must instantiate
that template even in an unevaluated context.
The lambda inside the concept is within the decl context of `struct
Widget<T> {};`. So we end up needing to mangle a name of
`Baz::test<Widget<template-type-0-0>::lambda()>>()` since the lambda
isn't apart of an instantiated substituted class `Widget` yet at the
point the lambda is instantiated.
Upon template instantation of `test` we end up asking for the mangled
name so we can add this instantiation to `CodeGenModule::DefferredDecls`
since `test` is now referenced but not yet used.
I think the longer term more correct solution is to key `DefferedDecls`
off of something else than the mangled name to avoid having to mangle
names for instantations that are referenced but will never be used since
they are only instantiated from an unevaluated context.
As a fix for the regression I just created a custom mangling scheme for
this case since MSVC has no comparable naming scheme as such a template
will never be emitted into the resulting obj as it will never be used.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list