[mlir] Default `mlir-query` input to stdin (#156324)

This allows piping  without an explicit `-` :

```shell
./mlir-opt input.mlir -canonicalize | ./mlir-query -c "<your_query_1>" -c "<your_query_2>" ... -c "<your_query_N>"
```

GitOrigin-RevId: f8faf23d92a6bf931bad6104bace62be7182724c
diff --git a/lib/Tools/mlir-query/MlirQueryMain.cpp b/lib/Tools/mlir-query/MlirQueryMain.cpp
index 9950050..6945c09 100644
--- a/lib/Tools/mlir-query/MlirQueryMain.cpp
+++ b/lib/Tools/mlir-query/MlirQueryMain.cpp
@@ -21,6 +21,7 @@
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/SourceMgr.h"
 
 //===----------------------------------------------------------------------===//
@@ -43,7 +44,7 @@
       llvm::cl::value_desc("command"), llvm::cl::cat(mlirQueryCategory));
 
   static llvm::cl::opt<std::string> inputFilename(
-      llvm::cl::Positional, llvm::cl::desc("<input file>"),
+      llvm::cl::Positional, llvm::cl::desc("<input file>"), llvm::cl::init("-"),
       llvm::cl::cat(mlirQueryCategory));
 
   static llvm::cl::opt<bool> noImplicitModule{
@@ -68,6 +69,14 @@
     return mlir::success();
   }
 
+  // When reading from stdin and the input is a tty, it is often a user mistake
+  // and the process "appears to be stuck". Print a message to let the user
+  // know!
+  if (inputFilename == "-" &&
+      llvm::sys::Process::FileDescriptorIsDisplayed(fileno(stdin)))
+    llvm::errs() << "(processing input from stdin now, hit ctrl-c/ctrl-d to "
+                    "interrupt)\n";
+
   // Set up the input file.
   std::string errorMessage;
   auto file = openInputFile(inputFilename, &errorMessage);