aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/Archive.cpp
AgeCommit message (Collapse)AuthorFilesLines
11 days[Object] Add a missing space to a diagnostic (#159826)Nico Weber1-1/+1
Follow-up to https://reviews.llvm.org/D46527
2025-09-17[llvm] Validate Parent object before dereference (#157460)Daniel Kuts1-3/+1
Fixes #157449
2024-11-29[Support][Error] Add ErrorAsOutParameter constructor that takes an Error by ref.Lang Hames1-1/+1
ErrorAsOutParameter's Error* constructor supports cases where an Error might not be passed in (because in the calling context it's known that this call won't fail). Most clients always have an Error present however, and for them an Error& overload is more convenient.
2024-11-19[Object] Remove unused includes (NFC) (#116750)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-10-01[NFC] Make 'Triple&' param a 'const&' instead (#110628)Sirraide1-1/+1
There isn’t really a reason for it not to be a `const&` (afaict), and it is a bit annoying because some APIs (e.g. `TargetMachine::getTargetTriple()`) return a `const Triple&`.
2024-05-08[llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (#91441)Kazu Hirata1-2/+2
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 70 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-03-13[llvm-ar] Use COFF archive format for COFF targets. (#82898)Jacek Caban1-4/+11
Detect COFF files by default and allow specifying it with --format argument. This is important for ARM64EC, which uses a separated symbol map for EC symbols. Since K_COFF is mostly compatible with K_GNU, this shouldn't really make a difference for other targets. This originally landed as #82642, but was reverted due to test failures in tests using no symbol table. Since COFF symbol can't express it, fallback to GNU format in that case.
2024-02-27[llvm-ar][Archive] Use getDefaultTargetTriple instead of host triple for the ↵Jacek Caban1-2/+2
fallback archive format. (#82888)
2024-02-24Revert "[llvm-ar] Use COFF archive format for COFF targets." (#82889)Jacek Caban1-11/+4
Reverts llvm/llvm-project#82642 for lld/test/ELF/invalid/Output/data-encoding.test.tmp.a failures on Windows.
2024-02-24[llvm-ar] Use COFF archive format for COFF targets. (#82642)Jacek Caban1-4/+11
Detect COFF files by default and allow specifying it with --format argument. This is important for ARM64EC, which uses a separated symbol map for EC symbols. Since K_COFF is mostly compatible with K_GNU, this shouldn't really make a difference for other targets.
2024-01-19[llvm] Use SmallString::operator std::string (NFC)Kazu Hirata1-1/+1
2023-12-11[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)Kazu Hirata1-8/+8
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata1-1/+1
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-08-22[AIX] supporting -X options for llvm-ranlib in AIX OSzhijian1-0/+4
Summary: llvm-ar is symlinked as llvm-ranlib and will act as ranlib when invoked in that mode. llvm-ar since [[ https://github.ibm.com/compiler/llvm-project/commit/4f2cfbe5314b064625b2c87bde6ce5c8d04004c5 | compiler/llvm-project@4f2cfbe ]] supports the -X options, but doesn't seem to accept them when running as llvm-ranlib. In AIX OS , according to https://www.ibm.com/docs/en/aix/7.2?topic=r-ranlib-command -X mode Specifies the type of object file ranlib should examine. The mode must be one of the following: 32 Processes only 32-bit object files 64 Processes only 64-bit object files 32_64, any Processes both 32-bit and 64-bit object files The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes ranlib to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable. Reviewers: James Henderson, MaskRay, Stephen Peckham Differential Revision: https://reviews.llvm.org/D142660
2023-05-18[AIX] support 64bit global symbol table for big archivezhijian1-42/+120
Summary: In big archive , there is 32bit global symbol table and 64 bit global symbol table. llvm-ar only support 32bit global symbol table this moment, we need to support the 64 bit global symbol table. https://www.ibm.com/docs/en/aix/7.2?topic=formats-ar-file-format-big Global Symbol Tables Immediately following the member table, the archive file contains two global symbol tables. The first global symbol table locates 32-bit file members that define global symbols; the second global symbol table does the same for 64-bit file members. If the archive has no 32-bit or 64-bit file members, the respective global symbol table is omitted. The strip command can be used to delete one or both global symbol tables from the archive. The fl_gstoff field in the fixed-length header contains the offset to the 32-bit global symbol table, and the fl_gst64off contains the offset to the 64-bit global symbol table. Reviewers: James Henderson,Stephen Peckham Differential Revision: https://reviews.llvm.org/D142479
2023-04-22[Object] Always initialized StartOfFile in Archive::Child::Child constructor.Jacek Caban1-0/+1
Fixes uninitialized memory access revealed by https://reviews.llvm.org/D146534. In empty archives, we use Child(nullptr,nullptr,nullptr) in Archive constructor in setFirstRegular. This copies unitialized StartOfFile to FirstRegularStartOfFile, which child_begin may use later. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D148955
2023-04-21[llvm-nm] Print EC symbol map.Jacek Caban1-8/+109
This is useful for examining ARM64EC static libraries and allows better llvm-lib testing. Changes to Archive class will also be useful for LLD to support ARM64EC, where it will need to use one map or the other, depending on linking target (or both, in case of ARM64X, but separately as they are in different namespaces). Reviewed By: jhenderson, efriedma Differential Revision: https://reviews.llvm.org/D146534
2023-03-06Reland [AIX][BigArchive] Treat the archive is empty if the first child ↵Kai Luo1-1/+15
member offset is zero If the archive contains free list and contains no member file, the buffer length doesn't equal to length of the header. Reviewed By: Esme, DiggerLin, #powerpc Differential Revision: https://reviews.llvm.org/D138986
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott1-1/+1
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-01-30Revert "[AIX][BigArchive] Treat the archive is empty if the first child ↵Mitch Phillips1-9/+1
member offset is zero" This reverts commit 7f0003c19c3a47f484ea9cc929728808b27ace32. Reason: This broke the ASan buildbot, see the comments in https://reviews.llvm.org/D138986 for more information.
2023-01-30[AIX][BigArchive] Treat the archive is empty if the first child member ↵Kai Luo1-1/+9
offset is zero If the archive contains free list and contains no member file, the buffer length doesn't equal to length of the header. Reviewed By: Esme, DiggerLin, #powerpc Differential Revision: https://reviews.llvm.org/D138986
2022-12-04[Object] llvm::Optional => std::optionalFangrui Song1-2/+1
2022-12-02[llvm] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-21Return None instead of Optional<T>() (NFC)Kazu Hirata1-1/+1
This patch replaces: return Optional<T>(); with: return None; to make the migration from llvm::Optional to std::optional easier. Specifically, I can deprecate None (in my source tree, that is) to identify all the instances of None that should be replaced with std::nullopt. Note that "return None" far outnumbers "return Optional<T>();". There are more than 2000 instances of "return None" in our source tree. All of the instances in this patch come from functions that return Optional<T> except Archive::findSym and ASTNodeImporter::import, where we return Expected<Optional<T>>. Note that we can construct Expected<Optional<T>> from any parameter convertible to Optional<T>, which None certainly is. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138464
2022-10-28[Object] Prevent null pointer dereference in BigArchiveMemberHeaderVictor Campos1-2/+5
The pointer argument Err from BigArchiveMemberHeader's constructor can be null. This pointer was dereferenced without any null checks. This patch adds a check to avoid a null dereference. Reviewed By: brenoguim Differential Revision: https://reviews.llvm.org/D135449
2022-07-18[AIX] support read global symbol of big archivezhijian1-3/+58
Reviewers: James Henderson, Fangrui Song Differential Revision: https://reviews.llvm.org/D124865
2022-06-06[Object][Archive] Support a new archive member /<ECSYMBOLS>/Pengxuan Zheng1-0/+4
Some libraries (e.g., arm64rt.lib) from the Windows WDK (version 10.0.22000.0) contain an undocumented special member '/<ECSYMBOLS>/'. This causes llvm-lib to fail with the following error: "truncated or malformed archive (long name offset characters after the '/' are not all decimal numbers: '<ECSYMBOLS>/' for archive member header at offset 162)" The '/<ECSYMBOLS>/' member does not seem to be documented anywhere, but might be related to the ARM64EC ABI Microsoft announced last year. https://blogs.windows.com/windowsdeveloper/2021/06/28/announcing-arm64ec-building-native-and-interoperable-apps-for-windows-11-on-arm/ Reviewed By: thieta, thakis Differential Revision: https://reviews.llvm.org/D127135
2022-05-19[Object] Fix updating darwin archivesKeith Smiley1-0/+9
When creating an archive, llvm-ar looks at the host to determine the archive format to use, on Apple platforms this means it uses the K_DARWIN format. K_DARWIN is _virtually_ equivalent to K_BSD, expect for some very slight differences around padding, timestamps in deterministic mode, and 64 bit formats. When updating an archive using llvm-ar, or llvm-objcopy, Archive would try to determine the kind, but it was not possible to get K_DARWIN in the initialization of the archive, because they're virtually inciting usable from K_BSD, especially since the slight differences only apply in very specific cases. This leads to linker failures when the alignment workaround is not applied to an archive copied with llvm-objcopy. This change teaches Archive to infer the K_DARWIN type in the cases where it's possible and the first object in the archive is a macho object. This avoids using the host triple to determine this to not affect cross compiling. Ideally we would eliminate the separate K_DARWIN type entirely since it's not a truly separate archive type, but then we'd have to force the macho workarounds on the BSD format generally. This might be acceptable but then it would be unclear how to handle this case without forcing the K_DARWIN64 format on all BSD users: ``` if (LastOffset >= Sym64Threshold) { if (Kind == object::Archive::K_DARWIN) Kind = object::Archive::K_DARWIN64; else Kind = object::Archive::K_GNU64; } ``` The logic used to determine if the object is macho is derived from the logic llvm-ar uses. Previous context: - 111cd669e90e5b2132187d36f8b141b11a671a8b - 23a76be5adcaa768ba538f8a4514a7afccf61988 Differential Revision: https://reviews.llvm.org/D124895
2022-03-02[Object] Skip section offset checking for /<XFGHASHMAP>/Pavel Samolysov1-0/+4
Starting from Windows SDK for Windows 11 (10.0.22000.x), all the system libraries (.lib files) contain a section with the '/<XFGHASHMAP>/' name. This looks like the libraries are built with control flow guard enabled: https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard?view=msvc-170 To let the LLVM tools (llvm-ar, llvm-lib) work with these libraries, this patch just skips the section offset check for sections with the '/<XFGHASHMAP>/' name. Closes: llvm/llvm-project#53814 Signed-off-by: Pavel Samolysov <pavel.samolysov@intel.com> Reviewed By: jhenderson, thieta Differential Revision: https://reviews.llvm.org/D120645
2022-02-10Cleanup LLVMObject headersserge-sans-paille1-1/+0
Most notably, llvm/Object/Binary.h no longer includes llvm/Support/MemoryBuffer.h llvm/Object/MachOUniversal*.h no longer include llvm/Object/Archive.h llvm/Object/TapiUniversal.h no longer includes llvm/Object/TapiFile.h llvm-project preprocessed size: before: 1068185081 after: 1068324320 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119457
2022-01-23[Object] Remove a redundant return statement (NFC)Kazu Hirata1-1/+0
Identified with readability-redundant-control-flow.
2022-01-18[AIX] Support of Big archive (read)zhijian1-146/+322
Summary: The patch is based on the EGuesnet's implement of the "Support of Big archive (read) the first commit of the patch is come from https://reviews.llvm.org/D100651. the rest of commits of the patch 1 Addressed the comments on the https://reviews.llvm.org/D100651 2 according to https://www.ibm.com/docs/en/aix/7.2?topic=formats-ar-file-format-big using the "fl_fstmoff" for the first object file number, using "char ar_nxtmem[20]" to get next object file , using the "char fl_lstmoff[20]" for the last of the object file will fix the following problems: 2.1 can not correct reading a archive files which has padding data between too object file 2.2 can not correct reading a archive files from which some object file has be deleted 3 introduce a new derived class BigArchive for big ar file. Reviewers: James Henderson Differential Revision: https://reviews.llvm.org/D111889
2022-01-18Revert "[AIX] Support of Big archive (read)"Florian Hahn1-319/+146
This appears to be causing the following build failures on green dragon during stage2 builds on macOS: /System/Volumes/Data/jenkins/workspace/apple-clang-stage2-configure-RA_osceola/clang.roots/BuildRecords/clang-9999.99_install/Objects/obj-llvm/./bin/clang++ -fno-stack-protector -fno-common -Wno-profile-instr-unprofiled -Wno-unknown-warning-option -Werror=unguarded-availability-new -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/System/Volumes/Data/jenkins/workspace/apple-clang-stage2-configure-RA_osceola/clang.roots/BuildRecords/clang-9999.99_install/Objects/obj-llvm/tools/clang/stage2-bins/module.cache -fcxx-modules -Xclang -fmodules-local-submodule-visibility -gmodules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -O2 -gline-tables-only -DNDEBUG -arch x86_64 -arch arm64 -arch arm64e -isysroot /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -mmacosx-version-min=10.10 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip tools/llvm-cov/CMakeFiles/llvm-cov.dir/llvm-cov.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/gcov.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CodeCoverage.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterJson.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterLcov.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageFilters.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageReport.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageSummaryInfo.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageView.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageViewHTML.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageViewText.cpp.o tools/llvm-cov/CMakeFiles/llvm-cov.dir/TestingSupport.cpp.o -o bin/llvm-cov -Wl,-rpath,@loader_path/../lib lib/libLLVMCore.a lib/libLLVMSupport.a lib/libLLVMObject.a lib/libLLVMCoverage.a lib/libLLVMProfileData.a lib/libLLVMDebugInfoDWARF.a lib/libLLVMObject.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMMCParser.a lib/libLLVMTextAPI.a lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a lib/libLLVMSupport.a -lm /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/lib/libz.tbd /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/lib/libcurses.tbd lib/libLLVMDemangle.a && cd /System/Volumes/Data/jenkins/workspace/apple-clang-stage2-configure-RA_osceola/clang.roots/BuildRecords/clang-9999.99_install/Objects/obj-llvm/tools/clang/stage2-bins/tools/llvm-cov && xcrun dsymutil -o=llvm-cov.dSYM /System/Volumes/Data/jenkins/workspace/apple-clang-stage2-configure-RA_osceola/clang.roots/BuildRecords/clang-9999.99_install/Objects/obj-llvm/tools/clang/stage2-bins/bin/llvm-cov Undefined symbols for architecture x86_64: "llvm::object::CommonArchiveMemberHeader<llvm::object::BigArMemHdrType>::getRawAccessMode() const", referenced from: vtable for llvm::object::BigArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::BigArMemHdrType>::getRawUID() const", referenced from: vtable for llvm::object::BigArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::BigArMemHdrType>::getRawGID() const", referenced from: vtable for llvm::object::BigArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::UnixArMemHdrType>::getRawAccessMode() const", referenced from: vtable for llvm::object::ArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::UnixArMemHdrType>::getRawLastModified() const", referenced from: vtable for llvm::object::ArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::BigArMemHdrType>::getRawLastModified() const", referenced from: vtable for llvm::object::BigArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::BigArMemHdrType>::getOffset() const", referenced from: vtable for llvm::object::BigArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::UnixArMemHdrType>::getRawUID() const", referenced from: vtable for llvm::object::ArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::UnixArMemHdrType>::getRawGID() const", referenced from: vtable for llvm::object::ArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) "llvm::object::CommonArchiveMemberHeader<llvm::object::UnixArMemHdrType>::getOffset() const", referenced from: vtable for llvm::object::ArchiveMemberHeader in libLLVMObject.a(Archive.cpp.o) ld: symbol(s) not found for architecture x86_64 https://smooshbase.apple.com/ci/job/apple-clang-stage2-configure-RA_osceola/30276/console
2022-01-17[AIX] Support of Big archive (read)zhijian1-146/+319
Summary: The patch is based on the EGuesnet's implement of the "Support of Big archive (read) the first commit of the patch is come from https://reviews.llvm.org/D100651. the rest of commits of the patch 1 Addressed the comments on the https://reviews.llvm.org/D100651 2 according to https://www.ibm.com/docs/en/aix/7.2?topic=formats-ar-file-format-big using the "fl_fstmoff" for the first object file number, using "char ar_nxtmem[20]" to get next object file , using the "char fl_lstmoff[20]" for the last of the object file will fix the following problems: 2.1 can not correct reading a archive files which has padding data between too object file 2.2 can not correct reading a archive files from which some object file has be deleted 3 introduce a new derived class BigArchive for big ar file. Reviewers: James Henderson Differential Revision: https://reviews.llvm.org/D111889
2022-01-17Revert "[AIX] Support of Big archive (read)"zhijian1-320/+147
This reverts commit 3130134d6e4823b5ee7619288a4b7e1e60831a82.
2022-01-17[AIX] Support of Big archive (read)zhijian1-147/+320
Summary: The patch is based on the EGuesnet's implement of the "Support of Big archive (read) the first commit of the patch is come from https://reviews.llvm.org/D100651. the rest of commits of the patch 1 Addressed the comments on the https://reviews.llvm.org/D100651 2 according to https://www.ibm.com/docs/en/aix/7.2?topic=formats-ar-file-format-big using the "fl_fstmoff" for the first object file number, using "char ar_nxtmem[20]" to get next object file , using the "char fl_lstmoff[20]" for the last of the object file will fix the following problems: 2.1 can not correct reading a archive files which has padding data between too object file 2.2 can not correct reading a archive files from which some object file has be deleted 3 introduce a new derived class BigArchive for big ar file. Reviewers: James Henderson Differential Revision: https://reviews.llvm.org/D111889
2021-08-05[llvm-ar] Fix for handling thin archive with SYM64 and a test case for itRamesh Peri1-1/+1
WHen thin archives are created which have symbol table of type SYM64 then all the tools will not work since they cannot read the files properly. One can reproduce the problem as follows: 1. Take a hello world program and create an archive out of it. The SYM64_THRESHOLD=0 will force the generation of SYM64 symbol table. clang -c hello.cpp SYM64_THRESHOLD=0 llvm-ar crsT mylib.a hello.o 2. Now try to use any of the tools on this mylib.a and it will fail. llvm-nm -M mylib.a THis fix will eliminate these failures. A regression test is created in llvm/test/Object/archive-symtab.test Reviewed By: MaskRay, Ramesh Differential Revision: https://reviews.llvm.org/D107322
2021-05-27[NFC][libObject] clang-format Archive{.h,.cpp}Jordan Rupprecht1-68/+79
In preparation for D100651
2020-12-01static const char *const foo => const char foo[]Fangrui Song1-2/+2
By default, a non-template variable of non-volatile const-qualified type having namespace-scope has internal linkage, so no need for `static`.
2020-03-11[Object] Fix handling of large archive membersJames Henderson1-7/+3
The archive library truncated the size of archive members whose size was greater than max uint32_t. This patch fixes the issue and adds some unit tests to verify. Reviewed by: ruiu, MaskRay, grimar, rupprecht Differential Revision: https://reviews.llvm.org/D75742
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling1-4/+4
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling1-4/+4
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-2/+2
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-09-20[Object] Uncapitalize an error messageFangrui Song1-1/+1
Test case will be added by my next commit. llvm-svn: 372369
2019-07-23[llvm-ar] Fix support for archives with members larger than 4GBOwen Reynolds1-2/+2
llvm-ar outputs a strange error message when handling archives with members larger than 4GB due to not checking file size when passing the value as an unsigned 32 bit integer. This overflow issue caused malformed archives to be created.: https://bugs.llvm.org/show_bug.cgi?id=38058 This change allows for members above 4GB and will error in a case that is over the formats size limit, a 10 digit decimal integer. Differential Revision: https://reviews.llvm.org/D65093 llvm-svn: 366813
2019-02-06[libObject][NFC] Include filename in error messageJordan Rupprecht1-1/+1
llvm-svn: 353341
2019-02-05[ADT] Add a fallible_iterator wrapper.Lang Hames1-5/+4
A fallible iterator is one whose increment or decrement operations may fail. This would usually be supported by replacing the ++ and -- operators with methods that return error: class MyFallibleIterator { public: // ... Error inc(); Errro dec(); // ... }; The downside of this style is that it no longer conforms to the C++ iterator concept, and can not make use of standard algorithms and features such as range-based for loops. The fallible_iterator wrapper takes an iterator written in the style above and adapts it to (mostly) conform with the C++ iterator concept. It does this by providing standard ++ and -- operator implementations, returning any errors generated via a side channel (an Error reference passed into the wrapper at construction time), and immediately jumping the iterator to a known 'end' value upon error. It also marks the Error as checked any time an iterator is compared with a known end value and found to be inequal, allowing early exit from loops without redundant error checking*. Usage looks like: MyFallibleIterator I = ..., E = ...; Error Err = Error::success(); for (auto &Elem : make_fallible_range(I, E, Err)) { // Loop body is only entered when safe. // Early exits from loop body permitted without checking Err. if (SomeCondition) return; } if (Err) // Handle error. * Since failure causes a fallible iterator to jump to end, testing that a fallible iterator is not an end value implicitly verifies that the error is a success value, and so is equivalent to an error check. Reviewers: dblaikie, rupprecht Subscribers: mgorny, dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57618 llvm-svn: 353237
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-05-08Object: Find terminator correctly when reading long filenames in GNU ↵Hans Wennborg1-4/+8
archives (PR37244) The code was previously relying on there being a null terminator somewhere in (or after) the string table, something made less likely by r330786. Differential Revision: https://reviews.llvm.org/D46527 llvm-svn: 331746
2017-10-27Make 32-bit member offset in Archive::Symbol::getMember 64-bitJake Ehrlich1-1/+1
When accessing a member for a symbol with an offset greater than 2^32 - 1 the current Archive::Symbol::getMember implementation will overflow and cause unexpected behavior. This change simply fixes that. In particular if you call "llvm-nm --print-armap" on an archive that has this behavior you'll get an error. Differential Revision: https://reviews.llvm.org/D39379 llvm-svn: 316801