LLVM 20.0.0git
RecordVisitor.cpp
Go to the documentation of this file.
1//===- RecordVisitor.cpp --------------------------------------------------===//
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/// Implements the TAPI Record Visitor.
10///
11//===----------------------------------------------------------------------===//
12
14
15using namespace llvm;
16using namespace llvm::MachO;
17
21
22static bool shouldSkipRecord(const Record &R, const bool RecordUndefs) {
23 if (R.isExported())
24 return false;
25
26 // Skip non exported symbols unless for flat namespace libraries.
27 return !(RecordUndefs && R.isUndefined());
28}
29
31 auto [SymName, SymKind, InterfaceType] = parseSymbol(GR.getName());
32 if (shouldSkipRecord(GR, RecordUndefs))
33 return;
34 Symbols->addGlobal(SymKind, SymName, GR.getFlags(), Targ);
35
36 if (InterfaceType == ObjCIFSymbolKind::None) {
37 Symbols->addGlobal(SymKind, SymName, GR.getFlags(), Targ);
38 return;
39 }
40
41 // It is impossible to hold a complete ObjCInterface with a single
42 // GlobalRecord, so continue to treat this symbol a generic global.
44 Targ);
45}
46
47void SymbolConverter::addIVars(const ArrayRef<ObjCIVarRecord *> IVars,
48 StringRef ContainerName) {
49 for (auto *IV : IVars) {
50 if (shouldSkipRecord(*IV, RecordUndefs))
51 continue;
52 std::string Name =
53 ObjCIVarRecord::createScopedName(ContainerName, IV->getName());
55 IV->getFlags(), Targ);
56 }
57}
58
60 if (!shouldSkipRecord(ObjCR, RecordUndefs)) {
61 if (ObjCR.isCompleteInterface()) {
63 ObjCR.getFlags(), Targ);
64 if (ObjCR.hasExceptionAttribute())
66 ObjCR.getFlags(), Targ);
67 } else {
68 // Because there is not a complete interface, visit individual symbols
69 // instead.
72 (ObjC2EHTypePrefix + ObjCR.getName()).str(),
73 ObjCR.getFlags(), Targ);
76 (ObjC2ClassNamePrefix + ObjCR.getName()).str(),
77 ObjCR.getFlags(), Targ);
80 (ObjC2MetaClassNamePrefix + ObjCR.getName()).str(),
81 ObjCR.getFlags(), Targ);
82 }
83 }
84
85 addIVars(ObjCR.getObjCIVars(), ObjCR.getName());
86 for (const auto *Cat : ObjCR.getObjCCategories())
87 addIVars(Cat->getObjCIVars(), ObjCR.getName());
88}
89
91 addIVars(Cat.getObjCIVars(), Cat.getSuperClassName());
92}
std::string Name
static bool shouldSkipRecord(const Record &R, const bool RecordUndefs)
static const uint32_t IV[8]
Definition: blake3_impl.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
StringRef getSuperClassName() const
Definition: Record.h:184
std::vector< ObjCIVarRecord * > getObjCIVars() const
static std::string createScopedName(StringRef SuperClass, StringRef IVar)
Definition: Record.h:150
std::vector< ObjCCategoryRecord * > getObjCCategories() const
bool isCompleteInterface() const
Definition: Record.h:202
bool isExportedSymbol(ObjCIFSymbolKind CurrType) const
Definition: Record.h:206
bool hasExceptionAttribute() const
Definition: Record.h:199
virtual void visitObjCCategory(const ObjCCategoryRecord &)
virtual void visitObjCInterface(const ObjCInterfaceRecord &)
StringRef getName() const
Definition: Record.h:103
SymbolFlags getFlags() const
Definition: Record.h:104
void visitObjCInterface(const ObjCInterfaceRecord &) override
void visitObjCCategory(const ObjCCategoryRecord &) override
void visitGlobal(const GlobalRecord &) override
Symbol * addGlobal(EncodeKind Kind, StringRef Name, SymbolFlags Flags, const Target &Targ)
Definition: SymbolSet.cpp:24
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr StringLiteral ObjC2ClassNamePrefix
Definition: Symbol.h:63
@ EHType
Is OBJC_EHTYPE* symbol.
@ Class
Is OBJC_CLASS* symbol.
@ MetaClass
Is OBJC_METACLASS* symbol.
SimpleSymbol parseSymbol(StringRef SymName)
Get symbol classification by parsing the name of a symbol.
Definition: Symbol.cpp:75
constexpr StringLiteral ObjC2MetaClassNamePrefix
Definition: Symbol.h:64
constexpr StringLiteral ObjC2EHTypePrefix
Definition: Symbol.h:65
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18