[PATCH] D88288: [Archive] Don't throw away errors for malformed archive members

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 02:56:42 PDT 2020


grimar added inline comments.


================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:378
+              }))
+        return std::move(Err);
       return Ret;
----------------
At line 362 we call `identify_magic(Buf.getBuffer())`. I wonder if it will be cleaner to
add a new static method to `SymbolicFile`, e.g:

```
bool SymbolicFile::isSymbolicFile(file_magic Type);
```

and then to use it from here and also from `SymbolicFile::createSymbolicFile`,
instead of the code it has:

```
  case file_magic::unknown:
  case file_magic::archive:
  case file_magic::coff_cl_gl_object:
  case file_magic::macho_universal_binary:
  case file_magic::windows_resource:
  case file_magic::pdb:
  case file_magic::minidump:
  case file_magic::tapi_file:
    return errorCodeToError(object_error::invalid_file_type);
```

With that you'll don't need to handle error code in this way, what is probably better because
I think the general direction is to get rid of them in favor of `Expected<>` etc. What do you think?


================
Comment at: llvm/test/Object/archive-unknown-filetype.test:1
+## Show that the archive library ignores does not emit an error or add any
+## symbols to the archive symbol table, when it encounters an unknown file type,
----------------
Did you mean this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88288



More information about the llvm-commits mailing list