[PATCH] D119974: [NFC][llvm-nm] refactor function dumpSymbolNamesFromFile
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 13:28:16 PST 2022
DiggerLin created this revision.
DiggerLin added reviewers: jhenderson, MaskRay, hubert.reinterpretcast.
Herald added a subscriber: rupprecht.
DiggerLin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
split the function into several small functions.
change the function like
static void dumpSymbolNamesFromFile(std::string &Filename) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFileOrSTDIN(Filename);
if (error(BufferOrErr.getError(), Filename))
return;
LLVMContext Context;
LLVMContext *ContextPtr = NoLLVMBitcode ? nullptr : &Context;
Expected<std::unique_ptr<Binary>> BinaryOrErr =
createBinary(BufferOrErr.get()->getMemBufferRef(), ContextPtr);
if (!BinaryOrErr) {
error(BinaryOrErr.takeError(), Filename);
return;
}
Binary &Bin = *BinaryOrErr.get();
if (Archive *A = dyn_cast<Archive>(&Bin))
dumpArchive(A, Filename, ContextPtr);
else if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin))
dumpMachOUniversalBinary(UB, Filename, ContextPtr);
else if (TapiUniversal *TU = dyn_cast<TapiUniversal>(&Bin))
dumpTapiUniversal(TU, Filename);
else if (SymbolicFile *O = dyn_cast<SymbolicFile>(&Bin))
dumpSymbolicFile(O, Filename);
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119974
Files:
llvm/tools/llvm-nm/llvm-nm.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119974.409385.patch
Type: text/x-patch
Size: 26734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/cfd6c24e/attachment.bin>
More information about the llvm-commits
mailing list