1 //===-- CompilerDecl.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_CompilerDecl_h_
11 #define liblldb_CompilerDecl_h_
13 #include "lldb/Symbol/CompilerType.h"
14 #include "lldb/Utility/ConstString.h"
15 #include "lldb/lldb-private.h"
17 namespace lldb_private {
21 //----------------------------------------------------------------------
22 // Constructors and Destructors
23 //----------------------------------------------------------------------
24 CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {}
26 CompilerDecl(TypeSystem *type_system, void *decl)
27 : m_type_system(type_system), m_opaque_decl(decl) {}
31 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
35 explicit operator bool() const { return IsValid(); }
37 bool operator<(const CompilerDecl &rhs) const {
38 if (m_type_system == rhs.m_type_system)
39 return m_opaque_decl < rhs.m_opaque_decl;
40 return m_type_system < rhs.m_type_system;
43 bool IsValid() const {
44 return m_type_system != nullptr && m_opaque_decl != nullptr;
49 //----------------------------------------------------------------------
51 //----------------------------------------------------------------------
53 TypeSystem *GetTypeSystem() const { return m_type_system; }
55 void *GetOpaqueDecl() const { return m_opaque_decl; }
57 void SetDecl(TypeSystem *type_system, void *decl) {
58 m_type_system = type_system;
63 m_type_system = nullptr;
64 m_opaque_decl = nullptr;
67 ConstString GetName() const;
69 ConstString GetMangledName() const;
71 CompilerDeclContext GetDeclContext() const;
73 // If this decl represents a function, return the return type
74 CompilerType GetFunctionReturnType() const;
76 // If this decl represents a function, return the number of arguments for the
78 size_t GetNumFunctionArguments() const;
80 // If this decl represents a function, return the argument type given a zero
81 // based argument index
82 CompilerType GetFunctionArgumentType(size_t arg_idx) const;
85 TypeSystem *m_type_system;
89 bool operator==(const CompilerDecl &lhs, const CompilerDecl &rhs);
90 bool operator!=(const CompilerDecl &lhs, const CompilerDecl &rhs);
92 } // namespace lldb_private
94 #endif // #ifndef liblldb_CompilerDecl_h_