LLVM  10.0.0svn
Symbol.h
Go to the documentation of this file.
1 //===- llvm/TextAPI/Symbol.h - TAPI Symbol ----------------------*- 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 #ifndef LLVM_TEXTAPI_MACHO_SYMBOL_H
10 #define LLVM_TEXTAPI_MACHO_SYMBOL_H
11 
12 #include "llvm/ADT/BitmaskEnum.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/Error.h"
18 
19 namespace llvm {
20 namespace MachO {
21 
22 // clang-format off
23 
24 /// Symbol flags.
25 enum class SymbolFlags : uint8_t {
26  /// No flags
27  None = 0,
28 
29  /// Thread-local value symbol
30  ThreadLocalValue = 1U << 0,
31 
32  /// Weak defined symbol
33  WeakDefined = 1U << 1,
34 
35  /// Weak referenced symbol
36  WeakReferenced = 1U << 2,
37 
38  /// Undefined
39  Undefined = 1U << 3,
40 
41  /// Rexported
42  Rexported = 1U << 4,
43 
44  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Rexported),
45 };
46 
47 // clang-format on
48 
49 enum class SymbolKind : uint8_t {
54 };
55 
57 class Symbol {
58 public:
60  : Name(Name), Targets(std::move(Targets)), Kind(Kind), Flags(Flags) {}
61 
62  void addTarget(Target target) { Targets.emplace_back(target); }
63  SymbolKind getKind() const { return Kind; }
64  StringRef getName() const { return Name; }
66  return mapToArchitectureSet(Targets);
67  }
68  SymbolFlags getFlags() const { return Flags; }
69 
70  bool isWeakDefined() const {
72  }
73 
74  bool isWeakReferenced() const {
76  }
77 
78  bool isThreadLocalValue() const {
79  return (Flags & SymbolFlags::ThreadLocalValue) ==
81  }
82 
83  bool isUndefined() const {
85  }
86 
87  bool isReexported() const {
89  }
90 
93  const_target_range targets() const { return {Targets}; }
94 
97  std::function<bool(const Target &)>>;
100  const_filtered_target_range targets(ArchitectureSet architectures) const;
101 
102 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
103  void dump(raw_ostream &OS) const;
104  void dump() const { dump(llvm::errs()); }
105 #endif
106 
107 private:
108  StringRef Name;
109  TargetList Targets;
111  SymbolFlags Flags;
112 };
113 
114 } // end namespace MachO.
115 } // end namespace llvm.
116 
117 #endif // LLVM_TEXTAPI_MACHO_SYMBOL_H
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
SymbolFlags getFlags() const
Definition: Symbol.h:68
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:320
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
ArchitectureSet mapToArchitectureSet(ArrayRef< Target > Targets)
Definition: Target.cpp:67
void addTarget(Target target)
Definition: Symbol.h:62
StringRef getName() const
Definition: Symbol.h:64
Definition: BitVector.h:937
bool isWeakReferenced() const
Definition: Symbol.h:74
SymbolFlags
Symbol flags.
Definition: Symbol.h:25
void dump() const
Definition: Symbol.h:104
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool isThreadLocalValue() const
Definition: Symbol.h:78
bool isUndefined() const
Definition: Symbol.h:83
TargetList::const_iterator const_target_iterator
Definition: Symbol.h:91
A range adaptor for a pair of iterators.
ArchitectureSet getArchitectures() const
Definition: Symbol.h:65
bool isReexported() const
Definition: Symbol.h:87
bool isWeakDefined() const
Definition: Symbol.h:70
SymbolKind getKind() const
Definition: Symbol.h:63
const_target_range targets() const
Definition: Symbol.h:93
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Specialization of filter_iterator_base for forward iteration only.
Definition: STLExtras.h:348
Symbol(SymbolKind Kind, StringRef Name, TargetList Targets, SymbolFlags Flags)
Definition: Symbol.h:59
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48