LLVM 20.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"
17
18namespace llvm {
19
21 std::unique_ptr<MemoryBuffer> Buf;
24 unsigned UID = 0, GID = 0, Perms = 0644;
25
26 NewArchiveMember() = default;
28
29 // Detect the archive format from the object or bitcode file. This helps
30 // assume the archive format when creating or editing archives in the case
31 // one isn't explicitly set.
33
35 getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
36
38 bool Deterministic);
39};
40
42
44 NoSymtab, // Do not write symbol table.
45 NormalSymtab, // Write symbol table. For the Big Archive format, write both
46 // 32-bit and 64-bit symbol tables.
47 BigArchive32, // Only write the 32-bit symbol table.
48 BigArchive64 // Only write the 64-bit symbol table.
49};
50
51void warnToStderr(Error Err);
52
53// Write an archive directly to an output stream.
54Error writeArchiveToStream(raw_ostream &Out,
55 ArrayRef<NewArchiveMember> NewMembers,
56 SymtabWritingMode WriteSymtab,
57 object::Archive::Kind Kind, bool Deterministic,
58 bool Thin, std::optional<bool> IsEC = std::nullopt,
59 function_ref<void(Error)> Warn = warnToStderr);
60
61Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
63 bool Deterministic, bool Thin,
64 std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr,
65 std::optional<bool> IsEC = std::nullopt,
66 function_ref<void(Error)> Warn = warnToStderr);
67
68// writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
69// buffer instead of writing it out to a file.
70Expected<std::unique_ptr<MemoryBuffer>>
71writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers,
73 bool Deterministic, bool Thin,
74 function_ref<void(Error)> Warn = warnToStderr);
75}
76
77#endif
BlockVerifier::State From
Tagged union holding either a T or a Error.
Definition: Error.h:481
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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
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)
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)
void warnToStderr(Error Err)
Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
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:43
sys::TimePoint< std::chrono::seconds > ModTime
Definition: ArchiveWriter.h:23
object::Archive::Kind detectKindFromObject() const
static Expected< NewArchiveMember > getFile(StringRef FileName, bool Deterministic)
static Expected< NewArchiveMember > getOldMember(const object::Archive::Child &OldMember, bool Deterministic)
std::unique_ptr< MemoryBuffer > Buf
Definition: ArchiveWriter.h:21