[Lldb-commits] [lldb] [lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals (NFC) (PR #92476)

Kazu Hirata via lldb-commits lldb-commits at lists.llvm.org
Thu May 16 20:46:54 PDT 2024


kazutakahirata wrote:

> The change looks fine. Was this done with by hand or with the help of a script? If so please put that in the commit message so we can do the same downstream.

Thank you for reviewing the patch!

I did get help from a script, but it's a bit too involved for a commit message, so let me put the recipe here.

1. Remove `StringRef::equals` temporarily from `StringRef.h`.
2. Build llvm with lldb enabled.
3. Redirect the error messages to a file, say `tem`.
4. Post process the error messages with:
   ```
   grep "llvm-project/lldb.* error:" tem | sort | uniq | \
     line-sed "s,^([^\!]*)\.equals\(([^\)]*)\),\1 == \2,"
   ```

   where `line-sed` is a helper shell script:

```
#!/bin/sh
pat="$1"

cat /dev/stdin | while IFS= read line ; do
  file="$(echo $line | cut -d: -f1)"
  lineno="$(echo $line | cut -d: -f2)"
  echo "Processing $file:$lineno..."
  sed -Ee "${lineno}${pat}" -i "$file"
done
```

The `sed` recipe above avoids lines containing `!` before `equals` because the negated `equals` needs to be replaced with `!=` instead of `==`.  Remaining cases, including negated `equals`, are fixed manually.

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


More information about the lldb-commits mailing list