diff options
author | Utkarsh Saxena <usx@google.com> | 2022-08-30 16:57:07 +0200 |
---|---|---|
committer | Tobias Hieta <tobias@hieta.se> | 2022-09-08 08:49:36 +0200 |
commit | 1c73596d345481de957e5ccc0bedf1fb9d9f643a (patch) | |
tree | de87d23680e69956fea0d1a4cb5011c482bb6b12 /clang/lib | |
parent | 5e1ba27b9d494d26ea05d27a0f097ee99ea38e22 (diff) | |
download | llvm-1c73596d345481de957e5ccc0bedf1fb9d9f643a.zip llvm-1c73596d345481de957e5ccc0bedf1fb9d9f643a.tar.gz llvm-1c73596d345481de957e5ccc0bedf1fb9d9f643a.tar.bz2 |
[clang] Skip re-building lambda expressions in parameters to consteval fns.
As discussed in this [comment](https://github.com/llvm/llvm-project/issues/56183#issuecomment-1224331699),
we end up building the lambda twice: once while parsing the function calls and then again while handling the immediate invocation.
This happens specially during removing nested immediate invocation.
Eg: When we have another consteval function as the parameter along with this lambda expression. Eg: `foo(bar([]{}))`, `foo(bar(), []{})`
While removing such nested immediate invocations, we should not rebuild this lambda. (IIUC, rebuilding a lambda would always generate a new type which will never match the original type from parsing)
Fixes: https://github.com/llvm/llvm-project/issues/56183
Fixes: https://github.com/llvm/llvm-project/issues/51695
Fixes: https://github.com/llvm/llvm-project/issues/50455
Fixes: https://github.com/llvm/llvm-project/issues/54872
Fixes: https://github.com/llvm/llvm-project/issues/54587
Differential Revision: https://reviews.llvm.org/D132945
(cherry picked from commit e7eec38246560781e0a4020b19c7eb038a8c5655)
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0e24237..83081bb 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -17600,6 +17600,11 @@ static void RemoveNestedImmediateInvocation( DRSet.erase(E); return E; } + ExprResult TransformLambdaExpr(LambdaExpr *E) { + // Do not rebuild lambdas to avoid creating a new type. + // Lambdas have already been processed inside their eval context. + return E; + } bool AlwaysRebuild() { return false; } bool ReplacingOriginal() { return true; } bool AllowSkippingCXXConstructExpr() { |