1 //===- RecordVisitor.cpp --------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 /// Implements the TAPI Record Visitor.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/TextAPI/RecordVisitor.h"
16 using namespace llvm::MachO
;
18 RecordVisitor::~RecordVisitor() {}
19 void RecordVisitor::visitObjCInterface(const ObjCInterfaceRecord
&) {}
20 void RecordVisitor::visitObjCCategory(const ObjCCategoryRecord
&) {}
22 static bool shouldSkipRecord(const Record
&R
, const bool RecordUndefs
) {
26 // Skip non exported symbols unless for flat namespace libraries.
27 return !(RecordUndefs
&& R
.isUndefined());
30 void SymbolConverter::visitGlobal(const GlobalRecord
&GR
) {
31 auto [SymName
, SymKind
] = parseSymbol(GR
.getName(), GR
.getFlags());
32 if (shouldSkipRecord(GR
, RecordUndefs
))
34 Symbols
->addGlobal(SymKind
, SymName
, GR
.getFlags(), Targ
);
37 void SymbolConverter::addIVars(const ArrayRef
<ObjCIVarRecord
*> IVars
,
38 StringRef ContainerName
) {
39 for (auto *IV
: IVars
) {
40 if (shouldSkipRecord(*IV
, RecordUndefs
))
43 ObjCIVarRecord::createScopedName(ContainerName
, IV
->getName());
44 Symbols
->addGlobal(SymbolKind::ObjectiveCInstanceVariable
, Name
,
45 IV
->getFlags(), Targ
);
49 void SymbolConverter::visitObjCInterface(const ObjCInterfaceRecord
&ObjCR
) {
50 if (!shouldSkipRecord(ObjCR
, RecordUndefs
)) {
51 Symbols
->addGlobal(SymbolKind::ObjectiveCClass
, ObjCR
.getName(),
52 ObjCR
.getFlags(), Targ
);
53 if (ObjCR
.hasExceptionAttribute())
54 Symbols
->addGlobal(SymbolKind::ObjectiveCClassEHType
, ObjCR
.getName(),
55 ObjCR
.getFlags(), Targ
);
58 addIVars(ObjCR
.getObjCIVars(), ObjCR
.getName());
59 for (const auto *Cat
: ObjCR
.getObjCCategories())
60 addIVars(Cat
->getObjCIVars(), ObjCR
.getName());
63 void SymbolConverter::visitObjCCategory(const ObjCCategoryRecord
&Cat
) {
64 addIVars(Cat
.getObjCIVars(), Cat
.getName());