[lld] [lld][ELF] Add --debug-names to create merged .debug_names. (PR #86508)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 11:13:46 PDT 2024


================
@@ -2782,83 +2866,23 @@ void DebugNamesBaseSection::parseDebugNames(
       ne.hashValue = caseFoldingDjbHash(name);
 
       // Read a series of index entries that end with abbreviation code 0.
-      const char *errMsg = nullptr;
+      std::string errMsg;
       uint64_t offset = locs.EntriesBase + entryOffsets[i];
       while (offset < namesSec.Data.size() && namesSec.Data[offset] != 0) {
         // Read & store all entries (for the same string).
-        auto ie = makeThreadLocal<IndexEntry>();
-        ie->poolOffset = offset;
-        Error err = Error::success();
-        ie->abbrevCode =
-            static_cast<uint32_t>(namesExtractor.getULEB128(&offset, &err));
-        if (err) {
-          consumeError(std::move(err));
-          errMsg = ": invalid abbrev code in entry";
-          break;
+        Expected<IndexEntry *> ieOrErr =
+            readEntry(offset, ni, locs.EntriesBase, namesExtractor, namesSec);
+        if (!ieOrErr) {
+          errorOrWarn(toString(namesSec.sec) +
+                      Twine(toString(ieOrErr.takeError())));
----------------
MaskRay wrote:

Using `Expected<DebugNamesBaseSection::IndexEntry *>` and `inconvertibleErrorCode()` look unnecessary to me.
We have other places that we return different types of errors and we simply return a std::string.

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


More information about the llvm-commits mailing list