File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
check/testdata/interop/cpp Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 14
14
15
15
library "[[@TEST_NAME]]" ;
16
16
17
+ // @dump-sem-ir-begin
17
18
import Cpp inline '''
18
19
19
20
// A C++ function.
20
21
inline void func() {}
21
22
22
23
''' ;
24
+ // @dump-sem-ir-end
23
25
24
26
fn Run () {
25
27
// @dump-sem-ir-begin
@@ -31,12 +33,14 @@ fn Run() {
31
33
32
34
library "[[@TEST_NAME]]" ;
33
35
36
+ // @dump-sem-ir-begin
34
37
import Cpp inline '''c++
35
38
36
39
// A C++ function.
37
40
inline void another_func() {}
38
41
39
42
''' ;
43
+ // @dump-sem-ir-end
40
44
41
45
fn Run () {
42
46
// @dump-sem-ir-begin
@@ -60,6 +64,12 @@ fn Run() {
60
64
// CHECK:STDOUT: %func.decl: %func.type = fn_decl @func [concrete = constants.%func] {} {}
61
65
// CHECK:STDOUT: }
62
66
// CHECK:STDOUT:
67
+ // CHECK:STDOUT: file {
68
+ // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
69
+ // CHECK:STDOUT: import Cpp inline
70
+ // CHECK:STDOUT: }
71
+ // CHECK:STDOUT: }
72
+ // CHECK:STDOUT:
63
73
// CHECK:STDOUT: fn @Run() {
64
74
// CHECK:STDOUT: !entry:
65
75
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
@@ -84,6 +94,12 @@ fn Run() {
84
94
// CHECK:STDOUT: %another_func.decl: %another_func.type = fn_decl @another_func [concrete = constants.%another_func] {} {}
85
95
// CHECK:STDOUT: }
86
96
// CHECK:STDOUT:
97
+ // CHECK:STDOUT: file {
98
+ // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
99
+ // CHECK:STDOUT: import Cpp inline
100
+ // CHECK:STDOUT: }
101
+ // CHECK:STDOUT: }
102
+ // CHECK:STDOUT:
87
103
// CHECK:STDOUT: fn @Run() {
88
104
// CHECK:STDOUT: !entry:
89
105
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
Original file line number Diff line number Diff line change @@ -1210,10 +1210,16 @@ auto Formatter::FormatImportCppDeclRhs() -> void {
1210
1210
OpenBrace ();
1211
1211
for (ImportCpp import_cpp : sem_ir_->import_cpps ().values ()) {
1212
1212
Indent ();
1213
- out_ << " import Cpp \" "
1214
- << FormatEscaped (
1215
- sem_ir_->string_literal_values ().Get (import_cpp.library_id ))
1216
- << " \"\n " ;
1213
+ out_ << " import Cpp " ;
1214
+ if (import_cpp.library_id .has_value ()) {
1215
+ out_ << " \" "
1216
+ << FormatEscaped (
1217
+ sem_ir_->string_literal_values ().Get (import_cpp.library_id ))
1218
+ << " \" " ;
1219
+ } else {
1220
+ out_ << " inline" ;
1221
+ }
1222
+ out_ << " \n " ;
1217
1223
}
1218
1224
CloseBrace ();
1219
1225
}
You can’t perform that action at this time.
0 commit comments