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