[Builders.h] Silence a warning by adding a cast.
authorChris Lattner <clattner@nondot.org>
Sat, 16 Oct 2021 20:01:13 +0000 (13:01 -0700)
committerChris Lattner <clattner@nondot.org>
Sat, 16 Oct 2021 20:30:28 +0000 (13:30 -0700)
The no-result version of createOrFold calls 'tryFold' but
ignores the result since it doesn't matter what it produced.
Explicitly cast to void to silence this warning:

../llvm/mlir/include/mlir/IR/Builders.h:454:5: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
    tryFold(op.getOperation(), unused);
    ^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~

Differential Revision: https://reviews.llvm.org/D111951

mlir/include/mlir/IR/Builders.h

index e87796e..6a50bc7 100644 (file)
@@ -451,7 +451,7 @@ public:
   createOrFold(Location location, Args &&...args) {
     auto op = create<OpTy>(location, std::forward<Args>(args)...);
     SmallVector<Value, 0> unused;
-    tryFold(op.getOperation(), unused);
+    (void)tryFold(op.getOperation(), unused);
 
     // Folding cannot remove a zero-result operation, so for convenience we
     // continue to return it.