Skip to content

Commit e48e1b6

Browse files
committed
[llvm] IDS auto codemod for TextAPI library
1 parent 4e44166 commit e48e1b6

16 files changed

+106
-90
lines changed

llvm/include/llvm/TextAPI/Architecture.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include <cstdint>
1718
#include <utility>
1819

@@ -32,24 +33,24 @@ enum Architecture : uint8_t {
3233
};
3334

3435
/// Convert a CPU Type and Subtype pair to an architecture slice.
35-
Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType);
36+
LLVM_ABI Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType);
3637

3738
/// Convert a name to an architecture slice.
38-
Architecture getArchitectureFromName(StringRef Name);
39+
LLVM_ABI Architecture getArchitectureFromName(StringRef Name);
3940

4041
/// Convert an architecture slice to a string.
41-
StringRef getArchitectureName(Architecture Arch);
42+
LLVM_ABI StringRef getArchitectureName(Architecture Arch);
4243

4344
/// Convert an architecture slice to a CPU Type and Subtype pair.
44-
std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch);
45+
LLVM_ABI std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch);
4546

4647
/// Convert a target to an architecture slice.
47-
Architecture mapToArchitecture(const llvm::Triple &Target);
48+
LLVM_ABI Architecture mapToArchitecture(const llvm::Triple &Target);
4849

4950
/// Check if architecture is 64 bit.
50-
bool is64Bit(Architecture);
51+
LLVM_ABI bool is64Bit(Architecture);
5152

52-
raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
53+
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
5354

5455
} // end namespace MachO.
5556
} // end namespace llvm.

llvm/include/llvm/TextAPI/ArchitectureSet.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/TextAPI/Architecture.h"
1718
#include <cstddef>
1819
#include <iterator>
@@ -38,7 +39,7 @@ class ArchitectureSet {
3839
constexpr ArchitectureSet() = default;
3940
constexpr ArchitectureSet(ArchSetType Raw) : ArchSet(Raw) {}
4041
ArchitectureSet(Architecture Arch) : ArchitectureSet() { set(Arch); }
41-
ArchitectureSet(const std::vector<Architecture> &Archs);
42+
LLVM_ABI ArchitectureSet(const std::vector<Architecture> &Archs);
4243

4344
static ArchitectureSet All() { return ArchitectureSet(EndIndexVal); }
4445

@@ -61,7 +62,7 @@ class ArchitectureSet {
6162
return (ArchSet & Archs.ArchSet) == Archs.ArchSet;
6263
}
6364

64-
size_t count() const;
65+
LLVM_ABI size_t count() const;
6566

6667
bool empty() const { return ArchSet == 0; }
6768

@@ -158,17 +159,17 @@ class ArchitectureSet {
158159
const_iterator begin() const { return {&ArchSet}; }
159160
const_iterator end() const { return {&ArchSet, EndIndexVal}; }
160161

161-
operator std::string() const;
162-
operator std::vector<Architecture>() const;
163-
void print(raw_ostream &OS) const;
162+
LLVM_ABI operator std::string() const;
163+
LLVM_ABI operator std::vector<Architecture>() const;
164+
LLVM_ABI void print(raw_ostream &OS) const;
164165
};
165166

166167
inline ArchitectureSet operator|(const Architecture &lhs,
167168
const Architecture &rhs) {
168169
return ArchitectureSet(lhs) | ArchitectureSet(rhs);
169170
}
170171

171-
raw_ostream &operator<<(raw_ostream &OS, ArchitectureSet Set);
172+
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, ArchitectureSet Set);
172173

173174
} // end namespace MachO.
174175
} // end namespace llvm.

llvm/include/llvm/TextAPI/DylibReader.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/StringMap.h"
1718
#include "llvm/Support/Error.h"
1819
#include "llvm/Support/MemoryBuffer.h"
@@ -37,19 +38,19 @@ struct ParseOption {
3738
/// \param Buffer Data that points to dylib.
3839
/// \param Options Determines which attributes to extract.
3940
/// \return List of record slices.
40-
Expected<Records> readFile(MemoryBufferRef Buffer, const ParseOption &Opt);
41+
LLVM_ABI Expected<Records> readFile(MemoryBufferRef Buffer, const ParseOption &Opt);
4142

4243
/// Get TAPI file representation of binary dylib.
4344
///
4445
/// \param Buffer Data that points to dylib.
45-
Expected<std::unique_ptr<InterfaceFile>> get(MemoryBufferRef Buffer);
46+
LLVM_ABI Expected<std::unique_ptr<InterfaceFile>> get(MemoryBufferRef Buffer);
4647

4748
using SymbolToSourceLocMap = llvm::StringMap<RecordLoc>;
4849
/// Get the source location for each symbol from dylib.
4950
///
5051
/// \param DSYM Path to DSYM file.
5152
/// \param T Requested target slice for dylib.
52-
SymbolToSourceLocMap accumulateSourceLocFromDSYM(const StringRef DSYM,
53+
LLVM_ABI SymbolToSourceLocMap accumulateSourceLocFromDSYM(const StringRef DSYM,
5354
const Target &T);
5455

5556
} // namespace llvm::MachO::DylibReader

llvm/include/llvm/TextAPI/InterfaceFile.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_TEXTAPI_INTERFACEFILE_H
1515
#define LLVM_TEXTAPI_INTERFACEFILE_H
1616

17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/ADT/Hashing.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/ADT/iterator.h"
@@ -60,7 +61,7 @@ class InterfaceFileRef {
6061

6162
StringRef getInstallName() const { return InstallName; };
6263

63-
void addTarget(const Target &Target);
64+
LLVM_ABI void addTarget(const Target &Target);
6465
template <typename RangeT> void addTargets(RangeT &&Targets) {
6566
for (const auto &Target : Targets)
6667
addTarget(Target(Target));
@@ -146,7 +147,7 @@ class InterfaceFile {
146147
/// Set and add target.
147148
///
148149
/// \param Target the target to add into.
149-
void addTarget(const Target &Target);
150+
LLVM_ABI void addTarget(const Target &Target);
150151

151152
/// Determine if target triple slice exists in file.
152153
///
@@ -174,7 +175,7 @@ class InterfaceFile {
174175
std::function<bool(const Target &)>>;
175176
using const_filtered_target_range =
176177
llvm::iterator_range<const_filtered_target_iterator>;
177-
const_filtered_target_range targets(ArchitectureSet Archs) const;
178+
LLVM_ABI const_filtered_target_range targets(ArchitectureSet Archs) const;
178179

179180
/// Set the install name of the library.
180181
void setInstallName(StringRef InstallName_) {
@@ -241,7 +242,7 @@ class InterfaceFile {
241242
/// Set the parent umbrella frameworks.
242243
/// \param Target_ The target applicable to Parent
243244
/// \param Parent The name of Parent
244-
void addParentUmbrella(const Target &Target_, StringRef Parent);
245+
LLVM_ABI void addParentUmbrella(const Target &Target_, StringRef Parent);
245246

246247
/// Get the list of Parent Umbrella frameworks.
247248
///
@@ -261,7 +262,7 @@ class InterfaceFile {
261262
/// \param InstallName The name of the client that is allowed to link this
262263
/// library.
263264
/// \param Target The target triple for which this applies.
264-
void addAllowableClient(StringRef InstallName, const Target &Target);
265+
LLVM_ABI void addAllowableClient(StringRef InstallName, const Target &Target);
265266

266267
/// Get the list of allowable clients.
267268
///
@@ -274,7 +275,7 @@ class InterfaceFile {
274275
///
275276
/// \param InstallName The name of the library to re-export.
276277
/// \param Target The target triple for which this applies.
277-
void addReexportedLibrary(StringRef InstallName, const Target &Target);
278+
LLVM_ABI void addReexportedLibrary(StringRef InstallName, const Target &Target);
278279

279280
/// Get the list of re-exported libraries.
280281
///
@@ -286,7 +287,7 @@ class InterfaceFile {
286287
/// Add a library for inlining to top level library.
287288
///
288289
///\param Document The library to inline with top level library.
289-
void addDocument(std::shared_ptr<InterfaceFile> &&Document);
290+
LLVM_ABI void addDocument(std::shared_ptr<InterfaceFile> &&Document);
290291

291292
/// Returns the pointer to parent document if exists or nullptr otherwise.
292293
InterfaceFile *getParent() const { return Parent; }
@@ -301,7 +302,7 @@ class InterfaceFile {
301302
/// Set the runpath search paths.
302303
/// \param RPath The name of runpath.
303304
/// \param InputTarget The target applicable to runpath search path.
304-
void addRPath(StringRef RPath, const Target &InputTarget);
305+
LLVM_ABI void addRPath(StringRef RPath, const Target &InputTarget);
305306

306307
/// Get the list of runpath search paths.
307308
///
@@ -373,14 +374,14 @@ class InterfaceFile {
373374
///
374375
/// \param Arch architecture to extract from.
375376
/// \return New InterfaceFile with extracted architecture slice.
376-
llvm::Expected<std::unique_ptr<InterfaceFile>>
377+
LLVM_ABI llvm::Expected<std::unique_ptr<InterfaceFile>>
377378
extract(Architecture Arch) const;
378379

379380
/// Remove architecture slice from Interface.
380381
///
381382
/// \param Arch architecture to remove.
382383
/// \return New Interface File with removed architecture slice.
383-
llvm::Expected<std::unique_ptr<InterfaceFile>>
384+
LLVM_ABI llvm::Expected<std::unique_ptr<InterfaceFile>>
384385
remove(Architecture Arch) const;
385386

386387
/// Merge Interfaces for the same library. The following library attributes
@@ -390,29 +391,29 @@ class InterfaceFile {
390391
///
391392
/// \param O The Interface to merge.
392393
/// \return New Interface File that was merged.
393-
llvm::Expected<std::unique_ptr<InterfaceFile>>
394+
LLVM_ABI llvm::Expected<std::unique_ptr<InterfaceFile>>
394395
merge(const InterfaceFile *O) const;
395396

396397
/// Inline reexported library into Interface.
397398
///
398399
/// \param Library Interface of reexported library.
399400
/// \param Overwrite Whether to overwrite preexisting inlined library.
400-
void inlineLibrary(std::shared_ptr<InterfaceFile> Library,
401+
LLVM_ABI void inlineLibrary(std::shared_ptr<InterfaceFile> Library,
401402
bool Overwrite = false);
402403

403404
/// Set InterfaceFile properties from pre-gathered binary attributes,
404405
/// if they are not set already.
405406
///
406407
/// \param BA Attributes typically represented in load commands.
407408
/// \param Targ MachO Target slice to add attributes to.
408-
void setFromBinaryAttrs(const RecordsSlice::BinaryAttrs &BA,
409+
LLVM_ABI void setFromBinaryAttrs(const RecordsSlice::BinaryAttrs &BA,
409410
const Target &Targ);
410411

411412
/// The equality is determined by attributes that impact linking
412413
/// compatibilities. Path, & FileKind are irrelevant since these by
413414
/// itself should not impact linking.
414415
/// This is an expensive operation.
415-
bool operator==(const InterfaceFile &O) const;
416+
LLVM_ABI bool operator==(const InterfaceFile &O) const;
416417

417418
bool operator!=(const InterfaceFile &O) const { return !(*this == O); }
418419

llvm/include/llvm/TextAPI/PackedVersion.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/Support/VersionTuple.h"
1718
#include <cstdint>
1819
#include <string>
@@ -53,8 +54,8 @@ class PackedVersion {
5354
/// Retrieve the subminor version number, if provided.
5455
unsigned getSubminor() const { return Version & 0xff; }
5556

56-
bool parse32(StringRef Str);
57-
std::pair<bool, bool> parse64(StringRef Str);
57+
LLVM_ABI bool parse32(StringRef Str);
58+
LLVM_ABI std::pair<bool, bool> parse64(StringRef Str);
5859

5960
bool operator<(const PackedVersion &O) const { return Version < O.Version; }
6061

@@ -64,9 +65,9 @@ class PackedVersion {
6465

6566
uint32_t rawValue() const { return Version; }
6667

67-
operator std::string() const;
68+
LLVM_ABI operator std::string() const;
6869

69-
void print(raw_ostream &OS) const;
70+
LLVM_ABI void print(raw_ostream &OS) const;
7071
};
7172

7273
inline raw_ostream &operator<<(raw_ostream &OS, const PackedVersion &Version) {

llvm/include/llvm/TextAPI/Platform.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef LLVM_TEXTAPI_PLATFORM_H
1313
#define LLVM_TEXTAPI_PLATFORM_H
1414

15+
#include "llvm/Support/Compiler.h"
1516
#include "llvm/ADT/SmallSet.h"
1617
#include "llvm/BinaryFormat/MachO.h"
1718
#include "llvm/Support/VersionTuple.h"
@@ -22,14 +23,14 @@ namespace MachO {
2223
using PlatformSet = SmallSet<PlatformType, 3>;
2324
using PlatformVersionSet = SmallSet<std::pair<PlatformType, VersionTuple>, 3>;
2425

25-
PlatformType mapToPlatformType(PlatformType Platform, bool WantSim);
26-
PlatformType mapToPlatformType(const Triple &Target);
27-
PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
28-
StringRef getPlatformName(PlatformType Platform);
29-
PlatformType getPlatformFromName(StringRef Name);
30-
std::string getOSAndEnvironmentName(PlatformType Platform,
26+
LLVM_ABI PlatformType mapToPlatformType(PlatformType Platform, bool WantSim);
27+
LLVM_ABI PlatformType mapToPlatformType(const Triple &Target);
28+
LLVM_ABI PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
29+
LLVM_ABI StringRef getPlatformName(PlatformType Platform);
30+
LLVM_ABI PlatformType getPlatformFromName(StringRef Name);
31+
LLVM_ABI std::string getOSAndEnvironmentName(PlatformType Platform,
3132
std::string Version = "");
32-
VersionTuple mapToSupportedOSVersion(const Triple &Triple);
33+
LLVM_ABI VersionTuple mapToSupportedOSVersion(const Triple &Triple);
3334

3435
} // end namespace MachO.
3536
} // end namespace llvm.

llvm/include/llvm/TextAPI/Record.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_TEXTAPI_RECORD_H
1515
#define LLVM_TEXTAPI_RECORD_H
1616

17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/ADT/MapVector.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/Casting.h"
@@ -104,7 +105,7 @@ class Record {
104105
SymbolFlags getFlags() const { return Flags; }
105106

106107
private:
107-
SymbolFlags mergeFlags(SymbolFlags Flags, RecordLinkage Linkage);
108+
LLVM_ABI SymbolFlags mergeFlags(SymbolFlags Flags, RecordLinkage Linkage);
108109

109110
protected:
110111
StringRef Name;
@@ -164,9 +165,9 @@ class ObjCContainerRecord : public Record {
164165
ObjCContainerRecord(StringRef Name, RecordLinkage Linkage)
165166
: Record({Name, Linkage, SymbolFlags::Data}) {}
166167

167-
ObjCIVarRecord *addObjCIVar(StringRef IVar, RecordLinkage Linkage);
168-
ObjCIVarRecord *findObjCIVar(StringRef IVar) const;
169-
std::vector<ObjCIVarRecord *> getObjCIVars() const;
168+
LLVM_ABI ObjCIVarRecord *addObjCIVar(StringRef IVar, RecordLinkage Linkage);
169+
LLVM_ABI ObjCIVarRecord *findObjCIVar(StringRef IVar) const;
170+
LLVM_ABI std::vector<ObjCIVarRecord *> getObjCIVars() const;
170171
RecordLinkage getLinkage() const { return Linkage; }
171172

172173
private:
@@ -207,11 +208,11 @@ class ObjCInterfaceRecord : public ObjCContainerRecord {
207208
return getLinkageForSymbol(CurrType) >= RecordLinkage::Rexported;
208209
}
209210

210-
RecordLinkage getLinkageForSymbol(ObjCIFSymbolKind CurrType) const;
211-
void updateLinkageForSymbols(ObjCIFSymbolKind SymType, RecordLinkage Link);
211+
LLVM_ABI RecordLinkage getLinkageForSymbol(ObjCIFSymbolKind CurrType) const;
212+
LLVM_ABI void updateLinkageForSymbols(ObjCIFSymbolKind SymType, RecordLinkage Link);
212213

213-
bool addObjCCategory(ObjCCategoryRecord *Record);
214-
std::vector<ObjCCategoryRecord *> getObjCCategories() const;
214+
LLVM_ABI bool addObjCCategory(ObjCCategoryRecord *Record);
215+
LLVM_ABI std::vector<ObjCCategoryRecord *> getObjCCategories() const;
215216

216217
private:
217218
/// Linkage level for each symbol represented in ObjCInterfaceRecord.

llvm/include/llvm/TextAPI/RecordVisitor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
#ifndef LLVM_TEXTAPI_RECORDVISITOR_H
1414
#define LLVM_TEXTAPI_RECORDVISITOR_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/TextAPI/Record.h"
1718
#include "llvm/TextAPI/SymbolSet.h"
1819

1920
namespace llvm {
2021
namespace MachO {
2122

2223
/// Base class for any usage of traversing over collected Records.
23-
class RecordVisitor {
24+
class LLVM_ABI RecordVisitor {
2425
public:
2526
virtual ~RecordVisitor();
2627

@@ -32,7 +33,7 @@ class RecordVisitor {
3233
/// Specialized RecordVisitor for collecting exported symbols
3334
/// and undefined symbols if RecordSlice being visited represents a
3435
/// flat-namespaced library.
35-
class SymbolConverter : public RecordVisitor {
36+
class LLVM_ABI SymbolConverter : public RecordVisitor {
3637
public:
3738
SymbolConverter(SymbolSet *Symbols, const Target &T,
3839
const bool RecordUndefs = false)

0 commit comments

Comments
 (0)