[PATCH] D67039: [ELF] Add a spell corrector for "undefined symbol" diagnostics

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 02:28:01 PDT 2019


grimar added inline comments.


================
Comment at: ELF/Relocations.cpp:721
+  StringRef name = sym.getName();
+  for (size_t i = 0, e = name.size(); i != e + 1; ++i) {
+    // Insert a character before name[i].
----------------
ruiu wrote:
> IIUC, this function costs (N+1)*74 where N is the length of a symbol name. Symbol names can be very long. Doesn't this too slow?
It's enabled for the first two undefined symbols. Even with large N, like 100 it shouldn't probably be too slow for the error reporting case?


================
Comment at: ELF/Relocations.cpp:727
+      if (suggest(newName))
+        break;
+    }
----------------
Seems it would be simpler to make `suggest` return `const Symbol *` (on success) or `nullptr` (on fail)?
You should be able to early return nicely then:

```
if (const Symbol *S = suggest(newName))
  return S;
```

and avoid doing things like

```
    if (corrected)
      break;
```




================
Comment at: ELF/Relocations.cpp:823
+  size_t i = 0;
+  for (const UndefinedDiag &undef : undefs)
+    if (!undef.locs.empty()) {
----------------
It feels `for` would look a bit better?

```
for (size_t I = 0; I<undefs.size(); ++I)
  if (!undefs[I].locs.empty())
    reportUndefinedSymbol<ELFT>(undefs[I], i < 2);
```


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D67039





More information about the llvm-commits mailing list