-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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][AST] Fix MS Mangle concept uneval context template instantiation crash #117845
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %clang_cc1 -std=c++20 -fms-compatibility -fms-compatibility-version=19.33 -emit-llvm %s -o - -triple=x86_64-windows-msvc | FileCheck %s | ||
|
||
template <typename T> | ||
concept C = requires | ||
{ | ||
{ T::test([](){}) }; | ||
}; | ||
|
||
template<typename T> | ||
struct Widget {}; | ||
|
||
template <C T> | ||
struct Widget<T> {}; | ||
|
||
struct Baz | ||
{ | ||
template<typename F> | ||
static constexpr decltype(auto) test(F&&) {} | ||
}; | ||
|
||
void test() | ||
{ | ||
Widget<Baz> w; | ||
} | ||
// CHECK: @"?test@@YAXXZ" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose the mangling you're adding doesn't actually show up anywhere since it's only used for a concept? But then why do we need to mangle it in the first place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we get to CodeGen, the method looks like a regular method, except for the fact that one of the template arguments is a class defined inside a concept instantiation. And CodeGen doesn't have any way to check for "is a template argument a class defined inside a concept". So, like all other methods, we stick it into DeferredDecls. And the key for the DeferredDecls map is the mangled name. We end up trying to mangle a TemplateTypeParmType because we stick the instantiated class into the scope of an uninstantiated class template. So no, we don't actually need to mangle it, but there's currently no way for CodeGen to check for this situation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing codegen (-emit-llvm) in clang/test/AST/ is unusual, those tests normally just look at the AST (though there are exceptions). Maybe there is a better place for this?