Skip to content

Commit 492d25b

Browse files
authored
[llvm] annotate interfaces in llvm/ObjectYAML for DLL export (#143763)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the `llvm/ObjectYAML` library. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). These were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
1 parent 695c4f2 commit 492d25b

File tree

8 files changed

+148
-119
lines changed

8 files changed

+148
-119
lines changed

llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/DebugInfo/CodeView/CodeView.h"
2020
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
2121
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include "llvm/Support/Error.h"
2324
#include "llvm/Support/YAMLTraits.h"
2425
#include <cstdint>
@@ -108,23 +109,24 @@ struct InlineeInfo {
108109
};
109110

110111
struct YAMLDebugSubsection {
111-
static Expected<YAMLDebugSubsection>
112+
LLVM_ABI static Expected<YAMLDebugSubsection>
112113
fromCodeViewSubection(const codeview::StringsAndChecksumsRef &SC,
113114
const codeview::DebugSubsectionRecord &SS);
114115

115116
std::shared_ptr<detail::YAMLSubsectionBase> Subsection;
116117
};
117118

118-
Expected<std::vector<std::shared_ptr<codeview::DebugSubsection>>>
119+
LLVM_ABI Expected<std::vector<std::shared_ptr<codeview::DebugSubsection>>>
119120
toCodeViewSubsectionList(BumpPtrAllocator &Allocator,
120121
ArrayRef<YAMLDebugSubsection> Subsections,
121122
const codeview::StringsAndChecksums &SC);
122123

123-
std::vector<YAMLDebugSubsection>
124+
LLVM_ABI std::vector<YAMLDebugSubsection>
124125
fromDebugS(ArrayRef<uint8_t> Data, const codeview::StringsAndChecksumsRef &SC);
125126

126-
void initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections,
127-
codeview::StringsAndChecksums &SC);
127+
LLVM_ABI void
128+
initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections,
129+
codeview::StringsAndChecksums &SC);
128130

129131
} // end namespace CodeViewYAML
130132

llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "llvm/DebugInfo/CodeView/CodeView.h"
1818
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/Support/Error.h"
2021
#include "llvm/Support/YAMLTraits.h"
2122
#include <memory>
@@ -32,11 +33,12 @@ struct SymbolRecordBase;
3233
struct SymbolRecord {
3334
std::shared_ptr<detail::SymbolRecordBase> Symbol;
3435

35-
codeview::CVSymbol
36+
LLVM_ABI codeview::CVSymbol
3637
toCodeViewSymbol(BumpPtrAllocator &Allocator,
3738
codeview::CodeViewContainer Container) const;
3839

39-
static Expected<SymbolRecord> fromCodeViewSymbol(codeview::CVSymbol Symbol);
40+
LLVM_ABI static Expected<SymbolRecord>
41+
fromCodeViewSymbol(codeview::CVSymbol Symbol);
4042
};
4143

4244
} // end namespace CodeViewYAML

llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/ArrayRef.h"
1818
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
1919
#include "llvm/Support/Allocator.h"
20+
#include "llvm/Support/Compiler.h"
2021
#include "llvm/Support/Error.h"
2122
#include "llvm/Support/YAMLTraits.h"
2223
#include <cstdint>
@@ -45,15 +46,16 @@ struct MemberRecord {
4546
struct LeafRecord {
4647
std::shared_ptr<detail::LeafRecordBase> Leaf;
4748

48-
codeview::CVType
49+
LLVM_ABI codeview::CVType
4950
toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const;
50-
static Expected<LeafRecord> fromCodeViewRecord(codeview::CVType Type);
51+
LLVM_ABI static Expected<LeafRecord>
52+
fromCodeViewRecord(codeview::CVType Type);
5153
};
5254

53-
std::vector<LeafRecord> fromDebugT(ArrayRef<uint8_t> DebugTorP,
54-
StringRef SectionName);
55-
ArrayRef<uint8_t> toDebugT(ArrayRef<LeafRecord>, BumpPtrAllocator &Alloc,
56-
StringRef SectionName);
55+
LLVM_ABI std::vector<LeafRecord> fromDebugT(ArrayRef<uint8_t> DebugTorP,
56+
StringRef SectionName);
57+
LLVM_ABI ArrayRef<uint8_t>
58+
toDebugT(ArrayRef<LeafRecord>, BumpPtrAllocator &Alloc, StringRef SectionName);
5759

5860
} // end namespace CodeViewYAML
5961

llvm/include/llvm/ObjectYAML/DWARFEmitter.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "llvm/ADT/StringMap.h"
1616
#include "llvm/ADT/StringRef.h"
17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/Support/Error.h"
1819
#include "llvm/Support/MemoryBuffer.h"
1920
#include "llvm/TargetParser/Host.h"
@@ -27,26 +28,26 @@ namespace DWARFYAML {
2728

2829
struct Data;
2930

30-
Error emitDebugAbbrev(raw_ostream &OS, const Data &DI);
31-
Error emitDebugStr(raw_ostream &OS, const Data &DI);
32-
33-
Error emitDebugAranges(raw_ostream &OS, const Data &DI);
34-
Error emitDebugRanges(raw_ostream &OS, const Data &DI);
35-
Error emitDebugPubnames(raw_ostream &OS, const Data &DI);
36-
Error emitDebugPubtypes(raw_ostream &OS, const Data &DI);
37-
Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI);
38-
Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI);
39-
Error emitDebugInfo(raw_ostream &OS, const Data &DI);
40-
Error emitDebugLine(raw_ostream &OS, const Data &DI);
41-
Error emitDebugAddr(raw_ostream &OS, const Data &DI);
42-
Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI);
43-
Error emitDebugRnglists(raw_ostream &OS, const Data &DI);
44-
Error emitDebugLoclists(raw_ostream &OS, const Data &DI);
45-
Error emitDebugNames(raw_ostream &OS, const Data &DI);
46-
47-
std::function<Error(raw_ostream &, const Data &)>
31+
LLVM_ABI Error emitDebugAbbrev(raw_ostream &OS, const Data &DI);
32+
LLVM_ABI Error emitDebugStr(raw_ostream &OS, const Data &DI);
33+
34+
LLVM_ABI Error emitDebugAranges(raw_ostream &OS, const Data &DI);
35+
LLVM_ABI Error emitDebugRanges(raw_ostream &OS, const Data &DI);
36+
LLVM_ABI Error emitDebugPubnames(raw_ostream &OS, const Data &DI);
37+
LLVM_ABI Error emitDebugPubtypes(raw_ostream &OS, const Data &DI);
38+
LLVM_ABI Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI);
39+
LLVM_ABI Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI);
40+
LLVM_ABI Error emitDebugInfo(raw_ostream &OS, const Data &DI);
41+
LLVM_ABI Error emitDebugLine(raw_ostream &OS, const Data &DI);
42+
LLVM_ABI Error emitDebugAddr(raw_ostream &OS, const Data &DI);
43+
LLVM_ABI Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI);
44+
LLVM_ABI Error emitDebugRnglists(raw_ostream &OS, const Data &DI);
45+
LLVM_ABI Error emitDebugLoclists(raw_ostream &OS, const Data &DI);
46+
LLVM_ABI Error emitDebugNames(raw_ostream &OS, const Data &DI);
47+
48+
LLVM_ABI std::function<Error(raw_ostream &, const Data &)>
4849
getDWARFEmitterByName(StringRef SecName);
49-
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
50+
LLVM_ABI Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
5051
emitDebugSections(StringRef YAMLString,
5152
bool IsLittleEndian = sys::IsLittleEndianHost,
5253
bool Is64BitAddrSize = true);

llvm/include/llvm/ObjectYAML/DWARFYAML.h

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/ADT/StringRef.h"
2020
#include "llvm/BinaryFormat/Dwarf.h"
2121
#include "llvm/ObjectYAML/YAML.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include "llvm/Support/YAMLTraits.h"
2324
#include <cstdint>
2425
#include <optional>
@@ -255,16 +256,16 @@ struct Data {
255256
std::optional<std::vector<ListTable<LoclistEntry>>> DebugLoclists;
256257
std::optional<DebugNamesSection> DebugNames;
257258

258-
bool isEmpty() const;
259+
LLVM_ABI bool isEmpty() const;
259260

260-
SetVector<StringRef> getNonEmptySectionNames() const;
261+
LLVM_ABI SetVector<StringRef> getNonEmptySectionNames() const;
261262

262263
struct AbbrevTableInfo {
263264
uint64_t Index;
264265
uint64_t Offset;
265266
};
266-
Expected<AbbrevTableInfo> getAbbrevTableInfoByID(uint64_t ID) const;
267-
StringRef getAbbrevTableContentByIndex(uint64_t Index) const;
267+
LLVM_ABI Expected<AbbrevTableInfo> getAbbrevTableInfoByID(uint64_t ID) const;
268+
LLVM_ABI StringRef getAbbrevTableContentByIndex(uint64_t Index) const;
268269

269270
private:
270271
mutable std::unordered_map<uint64_t, AbbrevTableInfo> AbbrevTableInfoMap;
@@ -310,88 +311,90 @@ namespace llvm {
310311
namespace yaml {
311312

312313
template <> struct MappingTraits<DWARFYAML::Data> {
313-
static void mapping(IO &IO, DWARFYAML::Data &DWARF);
314+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::Data &DWARF);
314315
};
315316

316317
template <> struct MappingTraits<DWARFYAML::AbbrevTable> {
317-
static void mapping(IO &IO, DWARFYAML::AbbrevTable &AbbrevTable);
318+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::AbbrevTable &AbbrevTable);
318319
};
319320

320321
template <> struct MappingTraits<DWARFYAML::Abbrev> {
321-
static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
322+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
322323
};
323324

324325
template <> struct MappingTraits<DWARFYAML::AttributeAbbrev> {
325-
static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
326+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
326327
};
327328

328329
template <> struct MappingTraits<DWARFYAML::ARangeDescriptor> {
329-
static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
330+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
330331
};
331332

332333
template <> struct MappingTraits<DWARFYAML::ARange> {
333-
static void mapping(IO &IO, DWARFYAML::ARange &ARange);
334+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::ARange &ARange);
334335
};
335336

336337
template <> struct MappingTraits<DWARFYAML::RangeEntry> {
337-
static void mapping(IO &IO, DWARFYAML::RangeEntry &Entry);
338+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::RangeEntry &Entry);
338339
};
339340

340341
template <> struct MappingTraits<DWARFYAML::Ranges> {
341-
static void mapping(IO &IO, DWARFYAML::Ranges &Ranges);
342+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::Ranges &Ranges);
342343
};
343344

344345
template <> struct MappingTraits<DWARFYAML::PubEntry> {
345-
static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
346+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
346347
};
347348

348349
template <> struct MappingTraits<DWARFYAML::PubSection> {
349-
static void mapping(IO &IO, DWARFYAML::PubSection &Section);
350+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::PubSection &Section);
350351
};
351352

352353
template <> struct MappingTraits<DWARFYAML::Unit> {
353-
static void mapping(IO &IO, DWARFYAML::Unit &Unit);
354+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::Unit &Unit);
354355
};
355356

356357
template <> struct MappingTraits<DWARFYAML::DebugNamesSection> {
357-
static void mapping(IO &IO, DWARFYAML::DebugNamesSection &);
358+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNamesSection &);
358359
};
359360
template <> struct MappingTraits<DWARFYAML::DebugNameEntry> {
360-
static void mapping(IO &IO, DWARFYAML::DebugNameEntry &);
361+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNameEntry &);
361362
};
362363
template <> struct MappingTraits<DWARFYAML::DebugNameAbbreviation> {
363-
static void mapping(IO &IO, DWARFYAML::DebugNameAbbreviation &);
364+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNameAbbreviation &);
364365
};
365366
template <> struct MappingTraits<DWARFYAML::IdxForm> {
366-
static void mapping(IO &IO, DWARFYAML::IdxForm &);
367+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::IdxForm &);
367368
};
368369

369370
template <> struct MappingTraits<DWARFYAML::Entry> {
370-
static void mapping(IO &IO, DWARFYAML::Entry &Entry);
371+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::Entry &Entry);
371372
};
372373

373374
template <> struct MappingTraits<DWARFYAML::FormValue> {
374-
static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
375+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
375376
};
376377

377378
template <> struct MappingTraits<DWARFYAML::File> {
378-
static void mapping(IO &IO, DWARFYAML::File &File);
379+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::File &File);
379380
};
380381

381382
template <> struct MappingTraits<DWARFYAML::LineTableOpcode> {
382-
static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode);
383+
LLVM_ABI static void mapping(IO &IO,
384+
DWARFYAML::LineTableOpcode &LineTableOpcode);
383385
};
384386

385387
template <> struct MappingTraits<DWARFYAML::LineTable> {
386-
static void mapping(IO &IO, DWARFYAML::LineTable &LineTable);
388+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::LineTable &LineTable);
387389
};
388390

389391
template <> struct MappingTraits<DWARFYAML::SegAddrPair> {
390-
static void mapping(IO &IO, DWARFYAML::SegAddrPair &SegAddrPair);
392+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::SegAddrPair &SegAddrPair);
391393
};
392394

393395
template <> struct MappingTraits<DWARFYAML::DWARFOperation> {
394-
static void mapping(IO &IO, DWARFYAML::DWARFOperation &DWARFOperation);
396+
LLVM_ABI static void mapping(IO &IO,
397+
DWARFYAML::DWARFOperation &DWARFOperation);
395398
};
396399

397400
template <typename EntryType>
@@ -407,19 +410,20 @@ struct MappingTraits<DWARFYAML::ListEntries<EntryType>> {
407410
};
408411

409412
template <> struct MappingTraits<DWARFYAML::RnglistEntry> {
410-
static void mapping(IO &IO, DWARFYAML::RnglistEntry &RnglistEntry);
413+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::RnglistEntry &RnglistEntry);
411414
};
412415

413416
template <> struct MappingTraits<DWARFYAML::LoclistEntry> {
414-
static void mapping(IO &IO, DWARFYAML::LoclistEntry &LoclistEntry);
417+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::LoclistEntry &LoclistEntry);
415418
};
416419

417420
template <> struct MappingTraits<DWARFYAML::AddrTableEntry> {
418-
static void mapping(IO &IO, DWARFYAML::AddrTableEntry &AddrTable);
421+
LLVM_ABI static void mapping(IO &IO, DWARFYAML::AddrTableEntry &AddrTable);
419422
};
420423

421424
template <> struct MappingTraits<DWARFYAML::StringOffsetsTable> {
422-
static void mapping(IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable);
425+
LLVM_ABI static void mapping(IO &IO,
426+
DWARFYAML::StringOffsetsTable &StrOffsetsTable);
423427
};
424428

425429
template <> struct ScalarEnumerationTraits<dwarf::DwarfFormat> {

0 commit comments

Comments
 (0)