[llvm] [llvm-strings] Use small buffer instead of reading whole file (PR #163073)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 02:03:46 PDT 2026


================
@@ -0,0 +1,9 @@
+## Show that a file that cannot be opened is reported on stderr, and that
+## processing continues with the remaining inputs.
+
+RUN: rm -rf %t && mkdir -p %t
+RUN: echo abcd > %t/good
+RUN: llvm-strings %t/does-not-exist %t/good 2>&1 | FileCheck %s -DFILE=%t/does-not-exist
+
+CHECK: [[FILE]]: {{[Nn]}}o such file or directory
----------------
jh7370 wrote:

This won't work on all platforms, as the error message is platform dependent (some platforms prefix it with an error code, for example). llvm lit has substitutions for these sorts of error messages. See the `%errc_*` family, which you can then pass in as a FileCheck variable (there are plenty of examples like this).

Also, these errors could do with additional context saying what the code is trying to do that triggers the error. In this case, it would be "cannot open file: no such file or directory", not just "no such file or directory" (in this specific case where the file doesn't exist, the additional context doesn't add much, but it becomes less obvious for other failure modes).

https://github.com/llvm/llvm-project/pull/163073


More information about the llvm-commits mailing list