Skip to content

Commit 4a23006

Browse files
committed
[llvm] IDS auto codemod for Object and ObjCopy libraries
1 parent 1002436 commit 4a23006

40 files changed

+347
-313
lines changed

llvm/include/llvm/ObjCopy/COFF/COFFObjcopy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace coff {
2626
/// Apply the transformations described by \p Config and \p COFFConfig
2727
/// to \p In and writes the result into \p Out.
2828
/// \returns any Error encountered whilst performing the operation.
29-
Error executeObjcopyOnBinary(const CommonConfig &Config, const COFFConfig &,
29+
LLVM_ABI Error executeObjcopyOnBinary(const CommonConfig &Config, const COFFConfig &,
3030
object::COFFObjectFile &In, raw_ostream &Out);
3131

3232
} // end namespace coff

llvm/include/llvm/ObjCopy/CommonConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_OBJCOPY_COMMONCONFIG_H
1010
#define LLVM_OBJCOPY_COMMONCONFIG_H
1111

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/ADT/ArrayRef.h"
1314
#include "llvm/ADT/CachedHashString.h"
1415
#include "llvm/ADT/DenseSet.h"
@@ -104,7 +105,7 @@ class NameOrPattern {
104105
public:
105106
// ErrorCallback is used to handle recoverable errors. An Error returned
106107
// by the callback aborts the parsing and is then returned by this function.
107-
static Expected<NameOrPattern>
108+
LLVM_ABI static Expected<NameOrPattern>
108109
create(StringRef Pattern, MatchStyle MS,
109110
llvm::function_ref<Error(Error)> ErrorCallback);
110111

llvm/include/llvm/ObjCopy/ConfigManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_OBJCOPY_CONFIGMANAGER_H
1010
#define LLVM_OBJCOPY_CONFIGMANAGER_H
1111

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/ObjCopy/COFF/COFFConfig.h"
1314
#include "llvm/ObjCopy/CommonConfig.h"
1415
#include "llvm/ObjCopy/ELF/ELFConfig.h"
@@ -20,7 +21,7 @@
2021
namespace llvm {
2122
namespace objcopy {
2223

23-
struct ConfigManager : public MultiFormatConfig {
24+
struct LLVM_ABI ConfigManager : public MultiFormatConfig {
2425
virtual ~ConfigManager() {}
2526

2627
const CommonConfig &getCommonConfig() const override { return Common; }

llvm/include/llvm/ObjCopy/ELF/ELFObjcopy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ namespace elf {
2727
/// \p In, which must represent an IHex file, and writes the result
2828
/// into \p Out.
2929
/// \returns any Error encountered whilst performing the operation.
30-
Error executeObjcopyOnIHex(const CommonConfig &Config,
30+
LLVM_ABI Error executeObjcopyOnIHex(const CommonConfig &Config,
3131
const ELFConfig &ELFConfig, MemoryBuffer &In,
3232
raw_ostream &Out);
3333

3434
/// Apply the transformations described by \p Config and \p ELFConfig to
3535
/// \p In, which is treated as a raw binary input, and writes the result
3636
/// into \p Out.
3737
/// \returns any Error encountered whilst performing the operation.
38-
Error executeObjcopyOnRawBinary(const CommonConfig &Config,
38+
LLVM_ABI Error executeObjcopyOnRawBinary(const CommonConfig &Config,
3939
const ELFConfig &ELFConfig, MemoryBuffer &In,
4040
raw_ostream &Out);
4141

4242
/// Apply the transformations described by \p Config and \p ELFConfig to
4343
/// \p In and writes the result into \p Out.
4444
/// \returns any Error encountered whilst performing the operation.
45-
Error executeObjcopyOnBinary(const CommonConfig &Config,
45+
LLVM_ABI Error executeObjcopyOnBinary(const CommonConfig &Config,
4646
const ELFConfig &ELFConfig,
4747
object::ELFObjectFileBase &In, raw_ostream &Out);
4848

llvm/include/llvm/ObjCopy/MachO/MachOObjcopy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ namespace macho {
2727
/// Apply the transformations described by \p Config and \p MachOConfig to
2828
/// \p In and writes the result into \p Out.
2929
/// \returns any Error encountered whilst performing the operation.
30-
Error executeObjcopyOnBinary(const CommonConfig &Config,
30+
LLVM_ABI Error executeObjcopyOnBinary(const CommonConfig &Config,
3131
const MachOConfig &MachOConfig,
3232
object::MachOObjectFile &In, raw_ostream &Out);
3333

3434
/// Apply the transformations described by \p Config and \p MachOConfig to
3535
/// \p In and writes the result into \p Out.
3636
/// \returns any Error encountered whilst performing the operation.
37-
Error executeObjcopyOnMachOUniversalBinary(
37+
LLVM_ABI Error executeObjcopyOnMachOUniversalBinary(
3838
const MultiFormatConfig &Config, const object::MachOUniversalBinary &In,
3939
raw_ostream &Out);
4040

llvm/include/llvm/ObjCopy/ObjCopy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_OBJCOPY_OBJCOPY_H
1010
#define LLVM_OBJCOPY_OBJCOPY_H
1111

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/Support/Error.h"
1314

1415
namespace llvm {
@@ -26,14 +27,14 @@ class MultiFormatConfig;
2627
/// each member in archive \p Ar.
2728
/// Writes a result in a file specified by \p Config.OutputFilename.
2829
/// \returns any Error encountered whilst performing the operation.
29-
Error executeObjcopyOnArchive(const MultiFormatConfig &Config,
30+
LLVM_ABI Error executeObjcopyOnArchive(const MultiFormatConfig &Config,
3031
const object::Archive &Ar);
3132

3233
/// Applies the transformations described by \p Config to \p In and writes
3334
/// the result into \p Out. This function does the dispatch based on the
3435
/// format of the input binary (COFF, ELF, MachO or wasm).
3536
/// \returns any Error encountered whilst performing the operation.
36-
Error executeObjcopyOnBinary(const MultiFormatConfig &Config,
37+
LLVM_ABI Error executeObjcopyOnBinary(const MultiFormatConfig &Config,
3738
object::Binary &In, raw_ostream &Out);
3839

3940
} // end namespace objcopy

llvm/include/llvm/ObjCopy/wasm/WasmObjcopy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace wasm {
2525
/// Apply the transformations described by \p Config and \p WasmConfig
2626
/// to \p In and writes the result into \p Out.
2727
/// \returns any Error encountered whilst performing the operation.
28-
Error executeObjcopyOnBinary(const CommonConfig &Config, const WasmConfig &,
28+
LLVM_ABI Error executeObjcopyOnBinary(const CommonConfig &Config, const WasmConfig &,
2929
object::WasmObjectFile &In, raw_ostream &Out);
3030

3131
} // end namespace wasm

llvm/include/llvm/Object/Archive.h

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_OBJECT_ARCHIVE_H
1414
#define LLVM_OBJECT_ARCHIVE_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/ADT/fallible_iterator.h"
1819
#include "llvm/ADT/iterator_range.h"
@@ -61,10 +62,10 @@ class AbstractArchiveMemberHeader {
6162
virtual Expected<const char *> getNextChildLoc() const = 0;
6263
virtual Expected<bool> isThin() const = 0;
6364

64-
Expected<sys::fs::perms> getAccessMode() const;
65-
Expected<sys::TimePoint<std::chrono::seconds>> getLastModified() const;
66-
Expected<unsigned> getUID() const;
67-
Expected<unsigned> getGID() const;
65+
LLVM_ABI Expected<sys::fs::perms> getAccessMode() const;
66+
LLVM_ABI Expected<sys::TimePoint<std::chrono::seconds>> getLastModified() const;
67+
LLVM_ABI Expected<unsigned> getUID() const;
68+
LLVM_ABI Expected<unsigned> getGID() const;
6869

6970
/// Returns the size in bytes of the format-defined member header of the
7071
/// concrete archive type.
@@ -99,7 +100,7 @@ struct UnixArMemHdrType {
99100
char Terminator[2];
100101
};
101102

102-
class ArchiveMemberHeader : public CommonArchiveMemberHeader<UnixArMemHdrType> {
103+
class LLVM_ABI ArchiveMemberHeader : public CommonArchiveMemberHeader<UnixArMemHdrType> {
103104
public:
104105
ArchiveMemberHeader(const Archive *Parent, const char *RawHeaderPtr,
105106
uint64_t Size, Error *Err);
@@ -133,7 +134,7 @@ struct BigArMemHdrType {
133134
};
134135

135136
// Define file member header of AIX big archive.
136-
class BigArchiveMemberHeader
137+
class LLVM_ABI BigArchiveMemberHeader
137138
: public CommonArchiveMemberHeader<BigArMemHdrType> {
138139

139140
public:
@@ -153,7 +154,7 @@ class BigArchiveMemberHeader
153154
Expected<bool> isThin() const override { return false; }
154155
};
155156

156-
class Archive : public Binary {
157+
class LLVM_ABI Archive : public Binary {
157158
virtual void anchor();
158159

159160
public:
@@ -171,8 +172,8 @@ class Archive : public Binary {
171172
Expected<bool> isThinMember() const;
172173

173174
public:
174-
Child(const Archive *Parent, const char *Start, Error *Err);
175-
Child(const Archive *Parent, StringRef Data, uint16_t StartOfFile);
175+
LLVM_ABI Child(const Archive *Parent, const char *Start, Error *Err);
176+
LLVM_ABI Child(const Archive *Parent, StringRef Data, uint16_t StartOfFile);
176177

177178
Child(const Child &C)
178179
: Parent(C.Parent), Data(C.Data), StartOfFile(C.StartOfFile) {
@@ -218,10 +219,10 @@ class Archive : public Binary {
218219
}
219220

220221
const Archive *getParent() const { return Parent; }
221-
Expected<Child> getNext() const;
222+
LLVM_ABI Expected<Child> getNext() const;
222223

223-
Expected<StringRef> getName() const;
224-
Expected<std::string> getFullName() const;
224+
LLVM_ABI Expected<StringRef> getName() const;
225+
LLVM_ABI Expected<std::string> getFullName() const;
225226
Expected<StringRef> getRawName() const { return Header->getRawName(); }
226227

227228
Expected<sys::TimePoint<std::chrono::seconds>> getLastModified() const {
@@ -240,17 +241,17 @@ class Archive : public Binary {
240241
}
241242

242243
/// \return the size of the archive member without the header or padding.
243-
Expected<uint64_t> getSize() const;
244+
LLVM_ABI Expected<uint64_t> getSize() const;
244245
/// \return the size in the archive header for this member.
245-
Expected<uint64_t> getRawSize() const;
246+
LLVM_ABI Expected<uint64_t> getRawSize() const;
246247

247-
Expected<StringRef> getBuffer() const;
248-
uint64_t getChildOffset() const;
248+
LLVM_ABI Expected<StringRef> getBuffer() const;
249+
LLVM_ABI uint64_t getChildOffset() const;
249250
uint64_t getDataOffset() const { return getChildOffset() + StartOfFile; }
250251

251-
Expected<MemoryBufferRef> getMemoryBufferRef() const;
252+
LLVM_ABI Expected<MemoryBufferRef> getMemoryBufferRef() const;
252253

253-
Expected<std::unique_ptr<Binary>>
254+
LLVM_ABI Expected<std::unique_ptr<Binary>>
254255
getAsBinary(LLVMContext *Context = nullptr) const;
255256
};
256257

@@ -299,10 +300,10 @@ class Archive : public Binary {
299300
return (Parent == other.Parent) && (SymbolIndex == other.SymbolIndex);
300301
}
301302

302-
StringRef getName() const;
303-
Expected<Child> getMember() const;
304-
Symbol getNext() const;
305-
bool isECSymbol() const;
303+
LLVM_ABI StringRef getName() const;
304+
LLVM_ABI Expected<Child> getMember() const;
305+
LLVM_ABI Symbol getNext() const;
306+
LLVM_ABI bool isECSymbol() const;
306307
};
307308

308309
class symbol_iterator {
@@ -416,7 +417,7 @@ class BigArchive : public Archive {
416417
bool Has64BitGlobalSymtab = false;
417418

418419
public:
419-
BigArchive(MemoryBufferRef Source, Error &Err);
420+
LLVM_ABI BigArchive(MemoryBufferRef Source, Error &Err);
420421
uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
421422
uint64_t getLastChildOffset() const { return LastChildOffset; }
422423
bool isEmpty() const override { return getFirstChildOffset() == 0; }

llvm/include/llvm/Object/ArchiveWriter.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_OBJECT_ARCHIVEWRITER_H
1414
#define LLVM_OBJECT_ARCHIVEWRITER_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/Object/Archive.h"
1718

1819
namespace llvm {
@@ -24,21 +25,21 @@ struct NewArchiveMember {
2425
unsigned UID = 0, GID = 0, Perms = 0644;
2526

2627
NewArchiveMember() = default;
27-
NewArchiveMember(MemoryBufferRef BufRef);
28+
LLVM_ABI NewArchiveMember(MemoryBufferRef BufRef);
2829

2930
// Detect the archive format from the object or bitcode file. This helps
3031
// assume the archive format when creating or editing archives in the case
3132
// one isn't explicitly set.
32-
object::Archive::Kind detectKindFromObject() const;
33+
LLVM_ABI object::Archive::Kind detectKindFromObject() const;
3334

34-
static Expected<NewArchiveMember>
35+
LLVM_ABI static Expected<NewArchiveMember>
3536
getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
3637

37-
static Expected<NewArchiveMember> getFile(StringRef FileName,
38+
LLVM_ABI static Expected<NewArchiveMember> getFile(StringRef FileName,
3839
bool Deterministic);
3940
};
4041

41-
Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
42+
LLVM_ABI Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
4243

4344
enum class SymtabWritingMode {
4445
NoSymtab, // Do not write symbol table.
@@ -48,17 +49,17 @@ enum class SymtabWritingMode {
4849
BigArchive64 // Only write the 64-bit symbol table.
4950
};
5051

51-
void warnToStderr(Error Err);
52+
LLVM_ABI void warnToStderr(Error Err);
5253

5354
// Write an archive directly to an output stream.
54-
Error writeArchiveToStream(raw_ostream &Out,
55+
LLVM_ABI Error writeArchiveToStream(raw_ostream &Out,
5556
ArrayRef<NewArchiveMember> NewMembers,
5657
SymtabWritingMode WriteSymtab,
5758
object::Archive::Kind Kind, bool Deterministic,
5859
bool Thin, std::optional<bool> IsEC = std::nullopt,
5960
function_ref<void(Error)> Warn = warnToStderr);
6061

61-
Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
62+
LLVM_ABI Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
6263
SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
6364
bool Deterministic, bool Thin,
6465
std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr,
@@ -67,7 +68,7 @@ Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
6768

6869
// writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
6970
// buffer instead of writing it out to a file.
70-
Expected<std::unique_ptr<MemoryBuffer>>
71+
LLVM_ABI Expected<std::unique_ptr<MemoryBuffer>>
7172
writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers,
7273
SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
7374
bool Deterministic, bool Thin,

llvm/include/llvm/Object/Binary.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_OBJECT_BINARY_H
1414
#define LLVM_OBJECT_BINARY_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm-c/Types.h"
1718
#include "llvm/Object/Error.h"
1819
#include "llvm/Support/CBindingWrapping.h"
@@ -29,7 +30,7 @@ class StringRef;
2930

3031
namespace object {
3132

32-
class Binary {
33+
class LLVM_ABI Binary {
3334
private:
3435
unsigned int TypeID;
3536

@@ -189,7 +190,7 @@ DEFINE_ISA_CONVERSION_FUNCTIONS(Binary, LLVMBinaryRef)
189190
/// Create a Binary from Source, autodetecting the file type.
190191
///
191192
/// @param Source The data to create the Binary from.
192-
Expected<std::unique_ptr<Binary>> createBinary(MemoryBufferRef Source,
193+
LLVM_ABI Expected<std::unique_ptr<Binary>> createBinary(MemoryBufferRef Source,
193194
LLVMContext *Context = nullptr,
194195
bool InitContent = true);
195196

@@ -241,7 +242,7 @@ template <typename T> const T* OwningBinary<T>::getBinary() const {
241242
return Bin.get();
242243
}
243244

244-
Expected<OwningBinary<Binary>> createBinary(StringRef Path,
245+
LLVM_ABI Expected<OwningBinary<Binary>> createBinary(StringRef Path,
245246
LLVMContext *Context = nullptr,
246247
bool InitContent = true);
247248

llvm/include/llvm/Object/BuildID.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef LLVM_DEBUGINFO_OBJECT_BUILDID_H
1616
#define LLVM_DEBUGINFO_OBJECT_BUILDID_H
1717

18+
#include "llvm/Support/Compiler.h"
1819
#include "llvm/ADT/ArrayRef.h"
1920
#include "llvm/ADT/SmallVector.h"
2021

@@ -30,13 +31,13 @@ typedef ArrayRef<uint8_t> BuildIDRef;
3031
class ObjectFile;
3132

3233
/// Parses a build ID from a hex string.
33-
BuildID parseBuildID(StringRef Str);
34+
LLVM_ABI BuildID parseBuildID(StringRef Str);
3435

3536
/// Returns the build ID, if any, contained in the given object file.
36-
BuildIDRef getBuildID(const ObjectFile *Obj);
37+
LLVM_ABI BuildIDRef getBuildID(const ObjectFile *Obj);
3738

3839
/// BuildIDFetcher searches local cache directories for debug info.
39-
class BuildIDFetcher {
40+
class LLVM_ABI BuildIDFetcher {
4041
public:
4142
BuildIDFetcher(std::vector<std::string> DebugFileDirectories)
4243
: DebugFileDirectories(std::move(DebugFileDirectories)) {}

0 commit comments

Comments
 (0)