Skip to content

Commit 170237b

Browse files
authored
Fix handling of enums in overload resolution. (#6072)
When mapping Carbon types to C++ types, check first for the Carbon type being imported from C++ before checking whether it's an adapter for a builtin. Enums imported from C++ will be both, and it's important we map them back to the enum type rather than to their underlying (integer) type. Fixes #6061
1 parent b44ba47 commit 170237b

File tree

2 files changed

+197
-56
lines changed

2 files changed

+197
-56
lines changed

toolchain/check/cpp_type_mapping.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,14 @@ static auto TryMapClassType(Context& context, SemIR::TypeId type_id)
127127
// Maps a non-wrapper (no const or pointer) Carbon type to a C++ type.
128128
static auto MapNonWrapperType(Context& context, SemIR::InstId inst_id,
129129
SemIR::TypeId type_id) -> clang::QualType {
130-
clang::QualType mapped_type = TryMapBuiltinType(context, inst_id, type_id);
130+
// It's important to check for a class type first, because an enum imported
131+
// from C++ is both a Carbon class type and has an object representation that
132+
// is a builtin type, and we want to map back to the enum.
133+
// TODO: The order won't matter once TryMapBuiltinType stops looking through
134+
// adapters.
135+
clang::QualType mapped_type = TryMapClassType(context, type_id);
131136
if (mapped_type.isNull()) {
132-
mapped_type = TryMapClassType(context, type_id);
137+
mapped_type = TryMapBuiltinType(context, inst_id, type_id);
133138
}
134139
return mapped_type;
135140
}

toolchain/lower/testdata/interop/cpp/enum.carbon

Lines changed: 190 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// TIP: To dump output, run:
1111
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/enum.carbon
1212

13-
// TODO: Tests marked as `fail_todo_5891_` to fixed as a follow-up of https://github.com/carbon-language/carbon-lang/pull/5891.
14-
1513
// --- enum_member.h
1614

1715
struct C {
@@ -24,57 +22,23 @@ struct C {
2422
static void F(E);
2523
};
2624

27-
// --- fail_todo_5891_pass_as_arg.carbon
25+
// --- pass_as_arg.carbon
2826

2927
library "[[@TEST_NAME]]";
3028

3129
import Cpp library "enum_member.h";
3230

3331
fn Pass() {
3432
Cpp.C.F(Cpp.C.a);
35-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
36-
// CHECK:STDERR: Cpp.C.F(Cpp.C.b);
37-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
38-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
39-
// CHECK:STDERR: Cpp.C.F(Cpp.C.b);
40-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
41-
// CHECK:STDERR:
33+
Cpp.C.F(Cpp.C.a);
4234
Cpp.C.F(Cpp.C.b);
43-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
44-
// CHECK:STDERR: Cpp.C.F(Cpp.C.c);
45-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
46-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
47-
// CHECK:STDERR: Cpp.C.F(Cpp.C.c);
48-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
49-
// CHECK:STDERR:
5035
Cpp.C.F(Cpp.C.c);
51-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
52-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.a);
53-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
54-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
55-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.a);
56-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
57-
// CHECK:STDERR:
5836
Cpp.C.F(Cpp.C.E.a);
59-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
60-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.b);
61-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
62-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
63-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.b);
64-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
65-
// CHECK:STDERR:
6637
Cpp.C.F(Cpp.C.E.b);
67-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
68-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.c);
69-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
70-
// CHECK:STDERR: fail_todo_5891_pass_as_arg.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
71-
// CHECK:STDERR: Cpp.C.F(Cpp.C.E.c);
72-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
73-
// CHECK:STDERR:
7438
Cpp.C.F(Cpp.C.E.c);
7539
}
7640

77-
// --- fail_todo_5891_convert.carbon
41+
// --- convert.carbon
7842

7943
library "[[@TEST_NAME]]";
8044

@@ -91,13 +55,6 @@ fn ConvertEnumToI16(e: Cpp.C.E) {
9155
}
9256

9357
fn ConvertI16ToEnum(n: i16) {
94-
// CHECK:STDERR: fail_todo_5891_convert.carbon:[[@LINE+7]]:3: error: no matching function for call to `F` [CppOverloadingNoViableFunctionFound]
95-
// CHECK:STDERR: Cpp.C.F(n as Cpp.C.E);
96-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
97-
// CHECK:STDERR: fail_todo_5891_convert.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
98-
// CHECK:STDERR: Cpp.C.F(n as Cpp.C.E);
99-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
100-
// CHECK:STDERR:
10158
Cpp.C.F(n as Cpp.C.E);
10259
}
10360

@@ -111,7 +68,7 @@ enum Bits {
11168

11269
void Take(Bits b);
11370

114-
// --- fail_todo_use_5891_bitmask.carbon
71+
// --- use_bitmask.carbon
11572

11673
library "[[@TEST_NAME]]";
11774

@@ -122,12 +79,191 @@ import Cpp library "bitmask.h";
12279
fn BitOr(a: Cpp.Bits, b: Cpp.Bits) -> Cpp.Bits = "int.or";
12380

12481
fn Call() {
125-
// CHECK:STDERR: fail_todo_use_5891_bitmask.carbon:[[@LINE+7]]:3: error: no matching function for call to `Take` [CppOverloadingNoViableFunctionFound]
126-
// CHECK:STDERR: Cpp.Take(BitOr(Cpp.A, Cpp.C));
127-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128-
// CHECK:STDERR: fail_todo_use_5891_bitmask.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
129-
// CHECK:STDERR: Cpp.Take(BitOr(Cpp.A, Cpp.C));
130-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131-
// CHECK:STDERR:
13282
Cpp.Take(BitOr(Cpp.A, Cpp.C));
13383
}
84+
85+
// CHECK:STDOUT: ; ModuleID = 'pass_as_arg.carbon'
86+
// CHECK:STDOUT: source_filename = "pass_as_arg.carbon"
87+
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
88+
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
89+
// CHECK:STDOUT:
90+
// CHECK:STDOUT: define void @_CPass.Main() !dbg !7 {
91+
// CHECK:STDOUT: entry:
92+
// CHECK:STDOUT: %.loc7_16.1.temp = alloca i16, align 2, !dbg !10
93+
// CHECK:STDOUT: %.loc8_16.1.temp = alloca i16, align 2, !dbg !11
94+
// CHECK:STDOUT: %.loc9_16.1.temp = alloca i16, align 2, !dbg !12
95+
// CHECK:STDOUT: %.loc10_16.1.temp = alloca i16, align 2, !dbg !13
96+
// CHECK:STDOUT: %.loc11_18.1.temp = alloca i16, align 2, !dbg !14
97+
// CHECK:STDOUT: %.loc12_18.1.temp = alloca i16, align 2, !dbg !15
98+
// CHECK:STDOUT: %.loc13_18.1.temp = alloca i16, align 2, !dbg !16
99+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_16.1.temp), !dbg !10
100+
// CHECK:STDOUT: store i16 0, ptr %.loc7_16.1.temp, align 2, !dbg !10
101+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc7_16.1.temp), !dbg !17
102+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc8_16.1.temp), !dbg !11
103+
// CHECK:STDOUT: store i16 0, ptr %.loc8_16.1.temp, align 2, !dbg !11
104+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc8_16.1.temp), !dbg !18
105+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_16.1.temp), !dbg !12
106+
// CHECK:STDOUT: store i16 7, ptr %.loc9_16.1.temp, align 2, !dbg !12
107+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc9_16.1.temp), !dbg !19
108+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc10_16.1.temp), !dbg !13
109+
// CHECK:STDOUT: store i16 8, ptr %.loc10_16.1.temp, align 2, !dbg !13
110+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc10_16.1.temp), !dbg !20
111+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc11_18.1.temp), !dbg !14
112+
// CHECK:STDOUT: store i16 0, ptr %.loc11_18.1.temp, align 2, !dbg !14
113+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc11_18.1.temp), !dbg !21
114+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc12_18.1.temp), !dbg !15
115+
// CHECK:STDOUT: store i16 7, ptr %.loc12_18.1.temp, align 2, !dbg !15
116+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc12_18.1.temp), !dbg !22
117+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc13_18.1.temp), !dbg !16
118+
// CHECK:STDOUT: store i16 8, ptr %.loc13_18.1.temp, align 2, !dbg !16
119+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc13_18.1.temp), !dbg !23
120+
// CHECK:STDOUT: ret void, !dbg !24
121+
// CHECK:STDOUT: }
122+
// CHECK:STDOUT:
123+
// CHECK:STDOUT: declare void @_ZN1C1FENS_1EE(i16)
124+
// CHECK:STDOUT:
125+
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
126+
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #0
127+
// CHECK:STDOUT:
128+
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
129+
// CHECK:STDOUT: define dso_local void @_ZN1C1FENS_1EE.carbon_thunk(ptr %0) #1 {
130+
// CHECK:STDOUT: entry:
131+
// CHECK:STDOUT: %.addr = alloca ptr, align 8
132+
// CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
133+
// CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
134+
// CHECK:STDOUT: %2 = load i16, ptr %1, align 2
135+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE(i16 signext %2)
136+
// CHECK:STDOUT: ret void
137+
// CHECK:STDOUT: }
138+
// CHECK:STDOUT:
139+
// CHECK:STDOUT: ; uselistorder directives
140+
// CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 6, 5, 4, 3, 2, 1, 0 }
141+
// CHECK:STDOUT:
142+
// CHECK:STDOUT: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
143+
// CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
144+
// CHECK:STDOUT:
145+
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
146+
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
147+
// CHECK:STDOUT:
148+
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
149+
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
150+
// CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
151+
// CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
152+
// CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
153+
// CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
154+
// CHECK:STDOUT: !6 = !DIFile(filename: "pass_as_arg.carbon", directory: "")
155+
// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Pass", linkageName: "_CPass.Main", scope: null, file: !6, line: 6, type: !8, spFlags: DISPFlagDefinition, unit: !5)
156+
// CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
157+
// CHECK:STDOUT: !9 = !{}
158+
// CHECK:STDOUT: !10 = !DILocation(line: 7, column: 11, scope: !7)
159+
// CHECK:STDOUT: !11 = !DILocation(line: 8, column: 11, scope: !7)
160+
// CHECK:STDOUT: !12 = !DILocation(line: 9, column: 11, scope: !7)
161+
// CHECK:STDOUT: !13 = !DILocation(line: 10, column: 11, scope: !7)
162+
// CHECK:STDOUT: !14 = !DILocation(line: 11, column: 11, scope: !7)
163+
// CHECK:STDOUT: !15 = !DILocation(line: 12, column: 11, scope: !7)
164+
// CHECK:STDOUT: !16 = !DILocation(line: 13, column: 11, scope: !7)
165+
// CHECK:STDOUT: !17 = !DILocation(line: 7, column: 3, scope: !7)
166+
// CHECK:STDOUT: !18 = !DILocation(line: 8, column: 3, scope: !7)
167+
// CHECK:STDOUT: !19 = !DILocation(line: 9, column: 3, scope: !7)
168+
// CHECK:STDOUT: !20 = !DILocation(line: 10, column: 3, scope: !7)
169+
// CHECK:STDOUT: !21 = !DILocation(line: 11, column: 3, scope: !7)
170+
// CHECK:STDOUT: !22 = !DILocation(line: 12, column: 3, scope: !7)
171+
// CHECK:STDOUT: !23 = !DILocation(line: 13, column: 3, scope: !7)
172+
// CHECK:STDOUT: !24 = !DILocation(line: 6, column: 1, scope: !7)
173+
// CHECK:STDOUT: ; ModuleID = 'convert.carbon'
174+
// CHECK:STDOUT: source_filename = "convert.carbon"
175+
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
176+
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
177+
// CHECK:STDOUT:
178+
// CHECK:STDOUT: declare void @_CTakeI16.Main(i16)
179+
// CHECK:STDOUT:
180+
// CHECK:STDOUT: define void @_CPassEnum.Main() !dbg !7 {
181+
// CHECK:STDOUT: entry:
182+
// CHECK:STDOUT: call void @_CTakeI16.Main(i16 7), !dbg !10
183+
// CHECK:STDOUT: ret void, !dbg !11
184+
// CHECK:STDOUT: }
185+
// CHECK:STDOUT:
186+
// CHECK:STDOUT: define void @_CConvertEnumToI16.Main(i16 %e) !dbg !12 {
187+
// CHECK:STDOUT: entry:
188+
// CHECK:STDOUT: call void @_CTakeI16.Main(i16 %e), !dbg !13
189+
// CHECK:STDOUT: ret void, !dbg !14
190+
// CHECK:STDOUT: }
191+
// CHECK:STDOUT:
192+
// CHECK:STDOUT: define void @_CConvertI16ToEnum.Main(i16 %n) !dbg !15 {
193+
// CHECK:STDOUT: entry:
194+
// CHECK:STDOUT: %.loc17_13.3.temp = alloca i16, align 2, !dbg !16
195+
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc17_13.3.temp), !dbg !16
196+
// CHECK:STDOUT: store i16 %n, ptr %.loc17_13.3.temp, align 2, !dbg !16
197+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE.carbon_thunk(ptr %.loc17_13.3.temp), !dbg !17
198+
// CHECK:STDOUT: ret void, !dbg !18
199+
// CHECK:STDOUT: }
200+
// CHECK:STDOUT:
201+
// CHECK:STDOUT: declare void @_ZN1C1FENS_1EE(i16)
202+
// CHECK:STDOUT:
203+
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
204+
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #0
205+
// CHECK:STDOUT:
206+
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
207+
// CHECK:STDOUT: define dso_local void @_ZN1C1FENS_1EE.carbon_thunk(ptr %0) #1 {
208+
// CHECK:STDOUT: entry:
209+
// CHECK:STDOUT: %.addr = alloca ptr, align 8
210+
// CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
211+
// CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
212+
// CHECK:STDOUT: %2 = load i16, ptr %1, align 2
213+
// CHECK:STDOUT: call void @_ZN1C1FENS_1EE(i16 signext %2)
214+
// CHECK:STDOUT: ret void
215+
// CHECK:STDOUT: }
216+
// CHECK:STDOUT:
217+
// CHECK:STDOUT: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
218+
// CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
219+
// CHECK:STDOUT:
220+
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
221+
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
222+
// CHECK:STDOUT:
223+
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
224+
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
225+
// CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
226+
// CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
227+
// CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
228+
// CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
229+
// CHECK:STDOUT: !6 = !DIFile(filename: "convert.carbon", directory: "")
230+
// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "PassEnum", linkageName: "_CPassEnum.Main", scope: null, file: !6, line: 8, type: !8, spFlags: DISPFlagDefinition, unit: !5)
231+
// CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
232+
// CHECK:STDOUT: !9 = !{}
233+
// CHECK:STDOUT: !10 = !DILocation(line: 9, column: 3, scope: !7)
234+
// CHECK:STDOUT: !11 = !DILocation(line: 8, column: 1, scope: !7)
235+
// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "ConvertEnumToI16", linkageName: "_CConvertEnumToI16.Main", scope: null, file: !6, line: 12, type: !8, spFlags: DISPFlagDefinition, unit: !5)
236+
// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 3, scope: !12)
237+
// CHECK:STDOUT: !14 = !DILocation(line: 12, column: 1, scope: !12)
238+
// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "ConvertI16ToEnum", linkageName: "_CConvertI16ToEnum.Main", scope: null, file: !6, line: 16, type: !8, spFlags: DISPFlagDefinition, unit: !5)
239+
// CHECK:STDOUT: !16 = !DILocation(line: 17, column: 11, scope: !15)
240+
// CHECK:STDOUT: !17 = !DILocation(line: 17, column: 3, scope: !15)
241+
// CHECK:STDOUT: !18 = !DILocation(line: 16, column: 1, scope: !15)
242+
// CHECK:STDOUT: ; ModuleID = 'use_bitmask.carbon'
243+
// CHECK:STDOUT: source_filename = "use_bitmask.carbon"
244+
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
245+
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
246+
// CHECK:STDOUT:
247+
// CHECK:STDOUT: define void @_CCall.Main() !dbg !7 {
248+
// CHECK:STDOUT: entry:
249+
// CHECK:STDOUT: call void @_Z4Take4Bits(i32 5), !dbg !10
250+
// CHECK:STDOUT: ret void, !dbg !11
251+
// CHECK:STDOUT: }
252+
// CHECK:STDOUT:
253+
// CHECK:STDOUT: declare void @_Z4Take4Bits(i32)
254+
// CHECK:STDOUT:
255+
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
256+
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
257+
// CHECK:STDOUT:
258+
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
259+
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
260+
// CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
261+
// CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
262+
// CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
263+
// CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
264+
// CHECK:STDOUT: !6 = !DIFile(filename: "use_bitmask.carbon", directory: "")
265+
// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Call", linkageName: "_CCall.Main", scope: null, file: !6, line: 10, type: !8, spFlags: DISPFlagDefinition, unit: !5)
266+
// CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
267+
// CHECK:STDOUT: !9 = !{}
268+
// CHECK:STDOUT: !10 = !DILocation(line: 11, column: 3, scope: !7)
269+
// CHECK:STDOUT: !11 = !DILocation(line: 10, column: 1, scope: !7)

0 commit comments

Comments
 (0)