LLDB  mainline
CompilerDecl.h
Go to the documentation of this file.
1 //===-- CompilerDecl.h ------------------------------------------*- 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 liblldb_CompilerDecl_h_
10 #define liblldb_CompilerDecl_h_
11 
14 #include "lldb/lldb-private.h"
15 
16 namespace lldb_private {
17 
18 class CompilerDecl {
19 public:
20  // Constructors and Destructors
21  CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {}
22 
23  CompilerDecl(TypeSystem *type_system, void *decl)
24  : m_type_system(type_system), m_opaque_decl(decl) {}
25 
27 
28  // Tests
29 
30  explicit operator bool() const { return IsValid(); }
31 
32  bool operator<(const CompilerDecl &rhs) const {
33  if (m_type_system == rhs.m_type_system)
34  return m_opaque_decl < rhs.m_opaque_decl;
35  return m_type_system < rhs.m_type_system;
36  }
37 
38  bool IsValid() const {
39  return m_type_system != nullptr && m_opaque_decl != nullptr;
40  }
41 
42  bool IsClang() const;
43 
44  // Accessors
45 
46  TypeSystem *GetTypeSystem() const { return m_type_system; }
47 
48  void *GetOpaqueDecl() const { return m_opaque_decl; }
49 
50  void SetDecl(TypeSystem *type_system, void *decl) {
51  m_type_system = type_system;
52  m_opaque_decl = decl;
53  }
54 
55  void Clear() {
56  m_type_system = nullptr;
57  m_opaque_decl = nullptr;
58  }
59 
60  ConstString GetName() const;
61 
63 
65 
66  // If this decl represents a function, return the return type
68 
69  // If this decl represents a function, return the number of arguments for the
70  // function
71  size_t GetNumFunctionArguments() const;
72 
73  // If this decl represents a function, return the argument type given a zero
74  // based argument index
75  CompilerType GetFunctionArgumentType(size_t arg_idx) const;
76 
77 private:
78  TypeSystem *m_type_system;
79  void *m_opaque_decl;
80 };
81 
82 bool operator==(const CompilerDecl &lhs, const CompilerDecl &rhs);
83 bool operator!=(const CompilerDecl &lhs, const CompilerDecl &rhs);
84 
85 } // namespace lldb_private
86 
87 #endif // #ifndef liblldb_CompilerDecl_h_
CompilerType GetFunctionReturnType() const
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
ConstString GetMangledName() const
bool operator<(const CompilerDecl &rhs) const
Definition: CompilerDecl.h:32
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:973
CompilerDecl(TypeSystem *type_system, void *decl)
Definition: CompilerDecl.h:23
CompilerType GetFunctionArgumentType(size_t arg_idx) const
CompilerDeclContext GetDeclContext() const
TypeSystem * GetTypeSystem() const
Definition: CompilerDecl.h:46
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:979
void SetDecl(TypeSystem *type_system, void *decl)
Definition: CompilerDecl.h:50
A uniqued constant string class.
Definition: ConstString.h:38
ConstString GetName() const
size_t GetNumFunctionArguments() const
void * GetOpaqueDecl() const
Definition: CompilerDecl.h:48