LLVM 22.0.0git
ArchiveWriter.h
Go to the documentation of this file.
1//===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Declares the writeArchive function for writing an archive file.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_ARCHIVEWRITER_H
14#define LLVM_OBJECT_ARCHIVEWRITER_H
15
16#include "llvm/Object/Archive.h"
18
19namespace llvm {
20
22 std::unique_ptr<MemoryBuffer> Buf;
25 unsigned UID = 0, GID = 0, Perms = 0644;
26
27 NewArchiveMember() = default;
29
30 // Detect the archive format from the object or bitcode file. This helps
31 // assume the archive format when creating or editing archives in the case
32 // one isn't explicitly set.
34
36 getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
37
39 bool Deterministic);
40};
41
43 StringRef To);
44
46 NoSymtab, // Do not write symbol table.
47 NormalSymtab, // Write symbol table. For the Big Archive format, write both
48 // 32-bit and 64-bit symbol tables.
49 BigArchive32, // Only write the 32-bit symbol table.
50 BigArchive64 // Only write the 64-bit symbol table.
51};
52
53LLVM_ABI void warnToStderr(Error Err);
54
55// Write an archive directly to an output stream.
57 raw_ostream &Out, ArrayRef<NewArchiveMember> NewMembers,
59 bool Deterministic, bool Thin, std::optional<bool> IsEC = std::nullopt,
60 function_ref<void(Error)> Warn = warnToStderr);
61
62LLVM_ABI Error
63writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
65 bool Deterministic, bool Thin,
66 std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr,
67 std::optional<bool> IsEC = std::nullopt,
68 function_ref<void(Error)> Warn = warnToStderr);
69
70// writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
71// buffer instead of writing it out to a file.
72LLVM_ABI Expected<std::unique_ptr<MemoryBuffer>>
73writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers,
75 bool Deterministic, bool Thin,
76 function_ref<void(Error)> Warn = warnToStderr);
77}
78
79#endif
BlockVerifier::State From
#define LLVM_ABI
Definition: Compiler.h:213
Tagged union holding either a T or a Error.
Definition: Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
Definition: Chrono.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI Expected< std::unique_ptr< MemoryBuffer > > writeArchiveToBuffer(ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, function_ref< void(Error)> Warn=warnToStderr)
LLVM_ABI Error writeArchive(StringRef ArcName, ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr, std::optional< bool > IsEC=std::nullopt, function_ref< void(Error)> Warn=warnToStderr)
LLVM_ABI void warnToStderr(Error Err)
LLVM_ABI Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
LLVM_ABI Error writeArchiveToStream(raw_ostream &Out, ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::optional< bool > IsEC=std::nullopt, function_ref< void(Error)> Warn=warnToStderr)
SymtabWritingMode
Definition: ArchiveWriter.h:45
sys::TimePoint< std::chrono::seconds > ModTime
Definition: ArchiveWriter.h:24
LLVM_ABI object::Archive::Kind detectKindFromObject() const
static LLVM_ABI Expected< NewArchiveMember > getFile(StringRef FileName, bool Deterministic)
static LLVM_ABI Expected< NewArchiveMember > getOldMember(const object::Archive::Child &OldMember, bool Deterministic)
std::unique_ptr< MemoryBuffer > Buf
Definition: ArchiveWriter.h:22