1 //===- llvm/TextAPI/Symbol.h - TAPI Symbol ----------------------*- C++ -*-===//
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 #ifndef LLVM_TEXTAPI_MACHO_SYMBOL_H
10 #define LLVM_TEXTAPI_MACHO_SYMBOL_H
12 #include "llvm/ADT/BitmaskEnum.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/Error.h"
15 #include "llvm/Support/raw_ostream.h"
16 #include "llvm/TextAPI/MachO/ArchitectureSet.h"
24 enum class SymbolFlags
: uint8_t {
28 /// Thread-local value symbol
29 ThreadLocalValue
= 1U << 0,
31 /// Weak defined symbol
32 WeakDefined
= 1U << 1,
34 /// Weak referenced symbol
35 WeakReferenced
= 1U << 2,
40 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Undefined
),
45 enum class SymbolKind
: uint8_t {
48 ObjectiveCClassEHType
,
49 ObjectiveCInstanceVariable
,
54 constexpr Symbol(SymbolKind Kind
, StringRef Name
,
55 ArchitectureSet Architectures
, SymbolFlags Flags
)
56 : Name(Name
), Architectures(Architectures
), Kind(Kind
), Flags(Flags
) {}
58 SymbolKind
getKind() const { return Kind
; }
59 StringRef
getName() const { return Name
; }
60 ArchitectureSet
getArchitectures() const { return Architectures
; }
61 void addArchitectures(ArchitectureSet Archs
) { Architectures
|= Archs
; }
62 SymbolFlags
getFlags() const { return Flags
; }
64 bool isWeakDefined() const {
65 return (Flags
& SymbolFlags::WeakDefined
) == SymbolFlags::WeakDefined
;
68 bool isWeakReferenced() const {
69 return (Flags
& SymbolFlags::WeakReferenced
) == SymbolFlags::WeakReferenced
;
72 bool isThreadLocalValue() const {
73 return (Flags
& SymbolFlags::ThreadLocalValue
) ==
74 SymbolFlags::ThreadLocalValue
;
77 bool isUndefined() const {
78 return (Flags
& SymbolFlags::Undefined
) == SymbolFlags::Undefined
;
81 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
82 void dump(raw_ostream
&OS
) const;
83 void dump() const { dump(llvm::errs()); }
88 ArchitectureSet Architectures
;
93 } // end namespace MachO.
94 } // end namespace llvm.
96 #endif // LLVM_TEXTAPI_MACHO_SYMBOL_H