[Mlir-commits] [mlir] ce70d4b - [mlir][emitc] Refactor getEmittedExpression (NFC) (#168361)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 24 01:08:05 PST 2025


Author: Gil Rapaport
Date: 2025-11-24T11:08:01+02:00
New Revision: ce70d4b5b5130f2ac8586c3dd2198dc91771f534

URL: https://github.com/llvm/llvm-project/commit/ce70d4b5b5130f2ac8586c3dd2198dc91771f534
DIFF: https://github.com/llvm/llvm-project/commit/ce70d4b5b5130f2ac8586c3dd2198dc91771f534.diff

LOG: [mlir][emitc] Refactor getEmittedExpression (NFC) (#168361)

This method returns the current expression being emitted, but is only
used testing whether an expression is being emitted or not. This patch
therefore replaces it with a boolean isEmittingExpression() method.

Added: 
    

Modified: 
    mlir/lib/Target/Cpp/TranslateToCpp.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index 56f81b0bea9e2..bcce0a5145221 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -253,8 +253,8 @@ struct CppEmitter {
     return !fileId.empty() && file.getId() == fileId;
   }
 
-  /// Get expression currently being emitted.
-  ExpressionOp getEmittedExpression() { return emittedExpression; }
+  /// Is expression currently being emitted.
+  bool isEmittingExpression() { return emittedExpression; }
 
   /// Determine whether given value is part of the expression potentially being
   /// emitted.
@@ -1717,7 +1717,7 @@ LogicalResult CppEmitter::emitGlobalVariable(GlobalOp op) {
 
 LogicalResult CppEmitter::emitAssignPrefix(Operation &op) {
   // If op is being emitted as part of an expression, bail out.
-  if (getEmittedExpression())
+  if (isEmittingExpression())
     return success();
 
   switch (op.getNumResults()) {
@@ -1799,7 +1799,7 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
   if (hasDeferredEmission(&op))
     return success();
 
-  if (getEmittedExpression() ||
+  if (isEmittingExpression() ||
       (isa<emitc::ExpressionOp>(op) &&
        shouldBeInlined(cast<emitc::ExpressionOp>(op))))
     return success();


        


More information about the Mlir-commits mailing list