CompilerDecl.h revision 309124
1//===-- CompilerDecl.h ------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_CompilerDecl_h_ 11#define liblldb_CompilerDecl_h_ 12 13#include "lldb/lldb-private.h" 14#include "lldb/Core/ConstString.h" 15#include "lldb/Symbol/CompilerType.h" 16 17namespace lldb_private { 18 19class CompilerDecl 20{ 21public: 22 //---------------------------------------------------------------------- 23 // Constructors and Destructors 24 //---------------------------------------------------------------------- 25 CompilerDecl () : 26 m_type_system (nullptr), 27 m_opaque_decl (nullptr) 28 { 29 } 30 31 CompilerDecl (TypeSystem *type_system, void *decl) : 32 m_type_system (type_system), 33 m_opaque_decl (decl) 34 { 35 } 36 37 ~CompilerDecl () 38 { 39 } 40 41 //---------------------------------------------------------------------- 42 // Tests 43 //---------------------------------------------------------------------- 44 45 explicit operator bool () const 46 { 47 return IsValid (); 48 } 49 50 bool 51 operator < (const CompilerDecl &rhs) const 52 { 53 if (m_type_system == rhs.m_type_system) 54 return m_opaque_decl < rhs.m_opaque_decl; 55 return m_type_system < rhs.m_type_system; 56 } 57 58 bool 59 IsValid () const 60 { 61 return m_type_system != nullptr && m_opaque_decl != nullptr; 62 } 63 64 bool 65 IsClang () const; 66 67 //---------------------------------------------------------------------- 68 // Accessors 69 //---------------------------------------------------------------------- 70 71 TypeSystem * 72 GetTypeSystem() const 73 { 74 return m_type_system; 75 } 76 77 void * 78 GetOpaqueDecl() const 79 { 80 return m_opaque_decl; 81 } 82 83 void 84 SetDecl (TypeSystem* type_system, void* decl) 85 { 86 m_type_system = type_system; 87 m_opaque_decl = decl; 88 } 89 90 void 91 Clear() 92 { 93 m_type_system = nullptr; 94 m_opaque_decl = nullptr; 95 } 96 97 ConstString 98 GetName () const; 99 100 ConstString 101 GetMangledName () const; 102 103 CompilerDeclContext 104 GetDeclContext() const; 105 106 // If this decl represents a function, return the return type 107 CompilerType 108 GetFunctionReturnType() const; 109 110 // If this decl represents a function, return the number of arguments for the function 111 size_t 112 GetNumFunctionArguments() const; 113 114 // If this decl represents a function, return the argument type given a zero based argument index 115 CompilerType 116 GetFunctionArgumentType (size_t arg_idx) const; 117 118private: 119 TypeSystem *m_type_system; 120 void *m_opaque_decl; 121}; 122 123bool operator == (const CompilerDecl &lhs, const CompilerDecl &rhs); 124bool operator != (const CompilerDecl &lhs, const CompilerDecl &rhs); 125 126 127} // namespace lldb_private 128 129#endif // #ifndef liblldb_CompilerDecl_h_ 130