2121#include " llvm/LineEditor/LineEditor.h"
2222#include " llvm/Support/CommandLine.h"
2323#include " llvm/Support/InitLLVM.h"
24+ #include " llvm/Support/Process.h"
2425#include " llvm/Support/SourceMgr.h"
2526
2627// ===----------------------------------------------------------------------===//
@@ -43,7 +44,7 @@ mlir::mlirQueryMain(int argc, char **argv, MLIRContext &context,
4344 llvm::cl::value_desc (" command" ), llvm::cl::cat (mlirQueryCategory));
4445
4546 static llvm::cl::opt<std::string> inputFilename (
46- llvm::cl::Positional, llvm::cl::desc (" <input file>" ),
47+ llvm::cl::Positional, llvm::cl::desc (" <input file>" ), llvm::cl::init ( " - " ),
4748 llvm::cl::cat (mlirQueryCategory));
4849
4950 static llvm::cl::opt<bool > noImplicitModule{
@@ -68,6 +69,14 @@ mlir::mlirQueryMain(int argc, char **argv, MLIRContext &context,
6869 return mlir::success ();
6970 }
7071
72+ // When reading from stdin and the input is a tty, it is often a user mistake
73+ // and the process "appears to be stuck". Print a message to let the user
74+ // know!
75+ if (inputFilename == " -" &&
76+ llvm::sys::Process::FileDescriptorIsDisplayed (fileno (stdin)))
77+ llvm::errs () << " (processing input from stdin now, hit ctrl-c/ctrl-d to "
78+ " interrupt)\n " ;
79+
7180 // Set up the input file.
7281 std::string errorMessage;
7382 auto file = openInputFile (inputFilename, &errorMessage);
0 commit comments