Commit a0139db
committed
[C++20] [Modules] Fix the duplicated static initializer problem
Reproducer:
```
//--- a.cppm
export module a;
int func();
static int a = func();
//--- a.cpp
import a;
```
The `func()` should only execute once. However, before this patch
we will somehow import `static int a` from a.cppm incorrectly and
initialize that again.
This is super bad and can introduce serious runtime behaviors.
And also surprisingly, it looks like the root cause of the problem is
simply some oversight choosing APIs.1 parent e61a7dc commit a0139db
File tree
2 files changed
+20
-2
lines changed- clang
- lib/CodeGen
- test/Modules
2 files changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7146 | 7146 | | |
7147 | 7147 | | |
7148 | 7148 | | |
7149 | | - | |
7150 | | - | |
| 7149 | + | |
| 7150 | + | |
7151 | 7151 | | |
7152 | 7152 | | |
7153 | 7153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments