Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When merging lambdas, keep track of the capture lists from each version.
Different versions of a lambda will in general refer to different enclosing variable declarations, because we do not merge most block-scope declarations, such as local variables. Keep track of all the declarations that correspond to a lambda's capture fields so that we can rewrite the name of any of those variables to the lambda capture, regardless of which copy of the body of `operator()` we look at.
- Loading branch information
Showing
6 changed files
with
128 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s | ||
|
||
#pragma clang module build A | ||
module A {} | ||
#pragma clang module contents | ||
#pragma clang module begin A | ||
template<typename T> T f(T v) { | ||
v(); | ||
return v; | ||
} | ||
inline auto g() { | ||
int n = 0; | ||
return f([=] { return n; }); | ||
} | ||
|
||
template<typename T> constexpr T f2(T v) { | ||
v(); | ||
return v; | ||
} | ||
constexpr auto g2() { | ||
int n = 0; | ||
return f2([=] { return n; }); | ||
} | ||
#pragma clang module end | ||
#pragma clang module endbuild | ||
|
||
#pragma clang module build B | ||
module B {} | ||
#pragma clang module contents | ||
#pragma clang module begin B | ||
template<typename T> T f(T v) { | ||
v(); | ||
return v; | ||
} | ||
inline auto g() { | ||
int n = 0; | ||
return f([=] { return n; }); | ||
} | ||
|
||
template<typename T> constexpr T f2(T v) { | ||
v(); | ||
return v; | ||
} | ||
constexpr auto g2() { | ||
int n = 0; | ||
return f2([=] { return n; }); | ||
} | ||
#pragma clang module end | ||
#pragma clang module endbuild | ||
|
||
#pragma clang module import A | ||
#pragma clang module import B | ||
|
||
// CHECK: define {{.*}}use_g | ||
int use_g() { | ||
return g()(); | ||
} | ||
|
||
static_assert(g2()() == 0); |