Skip to content

Commit a4a93fb

Browse files
committed
emitc: Do not add newlines after ModuleOp, TranslationUnitOp
1 parent 2113e3c commit a4a93fb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mlir/lib/Target/Cpp/TranslateToCpp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,9 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
16381638
if (hasDeferredEmission(&op))
16391639
return success();
16401640

1641+
if (isa<ModuleOp, TranslationUnitOp>(op))
1642+
return success(); // skip adding newlines
1643+
16411644
if (getEmittedExpression() ||
16421645
(isa<emitc::ExpressionOp>(op) &&
16431646
shouldBeInlined(cast<emitc::ExpressionOp>(op))))

mlir/test/Target/Cpp/tu.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s --check-prefix NO-FILTER
2-
// RUN: mlir-translate -mlir-to-cpp -translation-unit-id=non-existing %s | FileCheck %s --check-prefix NON-EXISTING
1+
// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s --check-prefix NO-FILTER --allow-empty
2+
// RUN: mlir-translate -mlir-to-cpp -translation-unit-id=non-existing %s | FileCheck %s --check-prefix NON-EXISTING --allow-empty
33
// RUN: mlir-translate -mlir-to-cpp -translation-unit-id=tu_one %s | FileCheck %s --check-prefix TU-ONE
44
// RUN: mlir-translate -mlir-to-cpp -translation-unit-id=tu_two %s | FileCheck %s --check-prefix TU-TWO
55

0 commit comments

Comments
 (0)