aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-09-19 12:51:02 +0200
committerGitHub <noreply@github.com>2025-09-19 12:51:02 +0200
commit03e16c8e42a03574062df1c5f2c9c5f2122042d5 (patch)
tree4958e76a3ccc4c30ef76080ef961af44259c1ff4 /clang/lib/AST/ByteCode/Compiler.cpp
parent4d197c89b53febbd4722f9923e511b7215825860 (diff)
downloadllvm-03e16c8e42a03574062df1c5f2c9c5f2122042d5.zip
llvm-03e16c8e42a03574062df1c5f2c9c5f2122042d5.tar.gz
llvm-03e16c8e42a03574062df1c5f2c9c5f2122042d5.tar.bz2
[clang][bytecode] Move generic lambda handling to Compiler (#159733)
So the static invoker's Function still points to the static invoker instead of the call operator of the lambda record. This is important for a later commit.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 1340a84..fafec47 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6077,7 +6077,24 @@ bool Compiler<Emitter>::emitLambdaStaticInvokerBody(const CXXMethodDecl *MD) {
assert(cast<CompoundStmt>(MD->getBody())->body_empty());
const CXXRecordDecl *ClosureClass = MD->getParent();
- const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
+ const FunctionDecl *LambdaCallOp;
+ assert(ClosureClass->captures().empty());
+ if (ClosureClass->isGenericLambda()) {
+ LambdaCallOp = ClosureClass->getLambdaCallOperator();
+ assert(MD->isFunctionTemplateSpecialization() &&
+ "A generic lambda's static-invoker function must be a "
+ "template specialization");
+ const TemplateArgumentList *TAL = MD->getTemplateSpecializationArgs();
+ FunctionTemplateDecl *CallOpTemplate =
+ LambdaCallOp->getDescribedFunctionTemplate();
+ void *InsertPos = nullptr;
+ const FunctionDecl *CorrespondingCallOpSpecialization =
+ CallOpTemplate->findSpecialization(TAL->asArray(), InsertPos);
+ assert(CorrespondingCallOpSpecialization);
+ LambdaCallOp = CorrespondingCallOpSpecialization;
+ } else {
+ LambdaCallOp = ClosureClass->getLambdaCallOperator();
+ }
assert(ClosureClass->captures().empty());
const Function *Func = this->getFunction(LambdaCallOp);
if (!Func)