Skip to content

Commit 1263ffa

Browse files
committed
Tested both branches of if block
1 parent b8c7b18 commit 1263ffa

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

mlir/lib/Target/Cpp/TranslateToCpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ static LogicalResult printOperation(CppEmitter &emitter, ClassOp classOp) {
10021002
raw_indented_ostream &os = emitter.ostream();
10031003
os << "class " << classOp.getSymName();
10041004
if (classOp.getFinalSpecifier())
1005-
os << " final ";
1006-
os << "{\n public:\n";
1005+
os << " final";
1006+
os << " {\n public:\n";
10071007
os.indent();
10081008

10091009
for (Operation &op : classOp) {

mlir/test/mlir-translate/emitc_classops.mlir

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mlir-translate --mlir-to-cpp %s | FileCheck %s
1+
// RUN: mlir-translate --mlir-to-cpp -split-input-file %s | FileCheck %s
22

3-
emitc.class final @modelClass {
3+
emitc.class @modelClass {
44
emitc.field @fieldName0 : !emitc.array<1xf32>
55
emitc.field @fieldName1 : !emitc.array<1xf32>
66
emitc.func @execute() {
@@ -12,7 +12,32 @@ emitc.class final @modelClass {
1212
}
1313
}
1414

15-
// CHECK: class modelClass final {
15+
// CHECK-LABEL: class modelClass {
16+
// CHECK-NEXT: public:
17+
// CHECK-NEXT: float[1] fieldName0;
18+
// CHECK-NEXT: float[1] fieldName1;
19+
// CHECK-NEXT: void execute() {
20+
// CHECK-NEXT: size_t v1 = 0;
21+
// CHECK-NEXT: float[1] v2 = fieldName0;
22+
// CHECK-NEXT: float[1] v3 = fieldName1;
23+
// CHECK-NEXT: return;
24+
// CHECK-NEXT: }
25+
// CHECK-EMPTY:
26+
// CHECK-NEXT: };
27+
28+
emitc.class final @finalClass {
29+
emitc.field @fieldName0 : !emitc.array<1xf32>
30+
emitc.field @fieldName1 : !emitc.array<1xf32>
31+
emitc.func @execute() {
32+
%0 = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
33+
%1 = get_field @fieldName0 : !emitc.array<1xf32>
34+
%2 = get_field @fieldName1 : !emitc.array<1xf32>
35+
%3 = subscript %1[%0] : (!emitc.array<1xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
36+
return
37+
}
38+
}
39+
40+
// CHECK-LABEL: class finalClass final {
1641
// CHECK-NEXT: public:
1742
// CHECK-NEXT: float[1] fieldName0;
1843
// CHECK-NEXT: float[1] fieldName1;

0 commit comments

Comments
 (0)