[PATCH] D120357: [llvm-nm]add helper function to print out the object file name, archive name, architecture name

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 22:29:26 PST 2022


jhenderson added inline comments.


================
Comment at: llvm/test/Object/nm-universal-binary.test:38
 
-CHECK-AR: macho-universal-archive.x86_64.i386(hello.o) (for architecture x86_64):
+CHECK-AR: {{[[:space:]].*}}macho-universal-archive.x86_64.i386(hello.o) (for architecture x86_64):
 CHECK-AR: 0000000000000068 s EH_frame0
----------------
Adding `{{[[:space:]].*}}` does literally nothing useful, as the whitespace at the start of a line is ignored unless using both `--strict-whitespace` and `--match-full-lines` in the FileCheck command. I believe, if you want to check the first line is empty, that you can use:

```
CHECK-AR:      {{^$}}
CHECK-AR-NEXT: macho-universal-archive.x86_64.i386(hello.o) (for architecture x86_64):
```

For later blank lines, you can do `CHECK-EMPTY:` immediately following a regular `CHECK`. `CHECK-EMPTY` works like `CHECK-NEXT` but ensures the line is completely blank instead of checking against some pattern. Since it works like `CHECK-NEXT` it cannot be used as the first `CHECK` pattern however. Conversely, `{{^$}}` will not always work if used after the first `CHECK` pattern. This is because FileCheck consumes the string it has matched up to before running the next `CHECK`. For example, imagine the output was:
```
foo
bar
```
And we have the following CHECKs:
```
CHECK: foo
CHECK-NEXT: {{^$}}
CHECK-NEXT: bar
```
to test that there is a blank line between foo and bar. In this case, after matching `foo`, the output will look like a blank line, followed by a line containing bar. The attempt to check for an empty line matches the first line (at the end of foo), which is not the line after the previous match, so the CHECK-NEXT fails.

(Aside, not something for you to fix, but this test is full of holes, and could fail to catch symbols in the output that shouldn't be present, or other additional lines).


================
Comment at: llvm/test/Object/nm-universal-binary.test:48
 
-CHECK-64-AR: macho-universal64-archive.x86_64.i386(foo.o) (for architecture i386):
+CHECK-64-AR: {{[[:space:]].*}}macho-universal64-archive.x86_64.i386(foo.o) (for architecture i386):
 CHECK-64-AR: 00000008 D _bar
----------------
See above.


================
Comment at: llvm/tools/llvm-nm/llvm-nm.cpp:1889
+  CurrentFilename = Obj.getFileName();
+  if (IsSymbolsEmpty && SymbolList.empty() && !Quiet) {
     writeFileName(errs(), ArchiveName, ArchitectureName);
----------------
Why have you just introduced this change? How is it better than the previous code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120357



More information about the llvm-commits mailing list