1 //===- llvm/TextAPI/RecordSlice.h - TAPI RecordSlice ------------*- C++ -*-===//
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 /// Defines the TAPI Record Visitor.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TEXTAPI_RECORDVISITOR_H
14 #define LLVM_TEXTAPI_RECORDVISITOR_H
15 
16 #include "llvm/TextAPI/Record.h"
17 #include "llvm/TextAPI/SymbolSet.h"
18 
19 namespace llvm {
20 namespace MachO {
21 
22 /// Base class for any usage of traversing over collected Records.
23 class RecordVisitor {
24 public:
25   virtual ~RecordVisitor();
26 
27   virtual void visitGlobal(const GlobalRecord &) = 0;
28   virtual void visitObjCInterface(const ObjCInterfaceRecord &);
29   virtual void visitObjCCategory(const ObjCCategoryRecord &);
30 };
31 
32 /// Specialized RecordVisitor for collecting exported symbols
33 /// and undefined symbols if RecordSlice being visited represents a
34 /// flat-namespaced library.
35 class SymbolConverter : public RecordVisitor {
36 public:
37   SymbolConverter(SymbolSet *Symbols, const Target &T,
38                   const bool RecordUndefs = false)
Symbols(Symbols)39       : Symbols(Symbols), Targ(T), RecordUndefs(RecordUndefs) {}
40   void visitGlobal(const GlobalRecord &) override;
41   void visitObjCInterface(const ObjCInterfaceRecord &) override;
42   void visitObjCCategory(const ObjCCategoryRecord &) override;
43 
44 private:
45   void addIVars(const ArrayRef<ObjCIVarRecord *>, StringRef ContainerName);
46   SymbolSet *Symbols;
47   const Target Targ;
48   const bool RecordUndefs;
49 };
50 
51 } // end namespace MachO.
52 } // end namespace llvm.
53 
54 #endif // LLVM_TEXTAPI_RECORDVISITOR_H
55