[PATCH] D140217: [lit] Script to automate use of %(line-n). Use in CodeComplete tests.

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 04:53:03 PST 2022


sammccall marked 6 inline comments as done.
sammccall added inline comments.


================
Comment at: llvm/utils/relative_lines.py:17
+
+USAGE = """Example usage:
+    find clang/test/CodeCompletion | grep -v /Inputs/ | \
----------------
hokein wrote:
> This variable is not used in anywhere, and not print out in `--help` mode. I think it is more useful to move it to the above file comment, at least it is shown in `--help` mode.
oops, I meant to add it as the help epilog. done now


================
Comment at: llvm/utils/relative_lines.py:20
+    xargs relative_lines.py --dry-run --verbose --near=100 \
+    --pattern='-code-completion-at[ =]%s:(\\d+)' \
+    --pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}'
----------------
hokein wrote:
> `\\d` should be `\d`?
Indeed - I'm surprised neither python nor shell requires the backslash to be escaped...


================
Comment at: llvm/utils/relative_lines.py:94
+    for pattern in args.pattern:
+        contents = re.sub(pattern, replace_match, contents)
+    if failures > 0 and not args.partial:
----------------
hokein wrote:
> looks like we modify the file more eagerly -- if there are no matching pattern, we will replace the content as well (most cases are ok, I saw the CRLF => LF change, I think we'd better only overwrite the content if there are matching patterns). 
Oops, this is processing as text rather than binary. Added ugly bytes conversions everywhere.

(Rewriting the file after no changes seems silly, but it should be a no-op and it shows up bugs like this)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140217/new/

https://reviews.llvm.org/D140217



More information about the llvm-commits mailing list