diff options
Diffstat (limited to 'lldb/include')
29 files changed, 702 insertions, 1188 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index e08c1aeeaed..3729b2f84b9 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -164,10 +164,6 @@ public: bool IsTypeComplete (); - // DEPRECATED: but needed for Xcode right now - static bool - IsPointerType (void * clang_type); - bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); diff --git a/lldb/include/lldb/Core/DataBufferHeap.h b/lldb/include/lldb/Core/DataBufferHeap.h index dfd5d7e18ab..dac9a28befb 100644 --- a/lldb/include/lldb/Core/DataBufferHeap.h +++ b/lldb/include/lldb/Core/DataBufferHeap.h @@ -121,6 +121,9 @@ public: void CopyData (const void *src, lldb::offset_t src_len); + void + Clear(); + private: //------------------------------------------------------------------ // This object uses a std::vector<uint8_t> to store its data. This diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 3ca7301a5df..5461ca73d08 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -21,6 +21,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Error.h" #include "lldb/Core/Scalar.h" +#include "lldb/Symbol/ClangASTType.h" namespace lldb_private { @@ -46,7 +47,6 @@ public: // m_context contains... // ==================== eContextTypeInvalid, // undefined - eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)") eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector register) eContextTypeLLDBType, // lldb_private::Type * eContextTypeVariable // lldb_private::Variable * @@ -77,7 +77,13 @@ public: return *this; } - bool + void + Clear () + { + length = 0; + } + + bool SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order) { this->length = length; @@ -124,8 +130,11 @@ public: Value & operator=(const Value &rhs); - lldb::clang_type_t + const ClangASTType & GetClangType(); + + void + SetClangType (const ClangASTType &clang_type); ValueType GetValueType() const; @@ -173,7 +182,7 @@ public: GetType(); Scalar & - ResolveValue (ExecutionContext *exe_ctx, clang::ASTContext *ast_context); + ResolveValue (ExecutionContext *exe_ctx); const Scalar & GetScalar() const @@ -227,7 +236,7 @@ public: ResizeData(size_t len); bool - ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context); + ValueOf(ExecutionContext *exe_ctx); Variable * GetVariable(); @@ -239,11 +248,10 @@ public: GetValueDefaultFormat (); uint64_t - GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr); + GetValueByteSize (Error *error_ptr); Error GetValueAsData (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, DataExtractor &data, uint32_t data_offset, Module *module); // Can be NULL @@ -257,11 +265,15 @@ public: bool GetData (DataExtractor &data); + void + Clear(); + protected: Scalar m_value; Vector m_vector; - ValueType m_value_type; + ClangASTType m_clang_type; void * m_context; + ValueType m_value_type; ContextType m_context_type; DataBufferHeap m_data_buffer; }; diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 26fa3aad61d..0d965d6ccc0 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -596,10 +596,7 @@ public: virtual ~ValueObject(); - clang::ASTContext * - GetClangAST (); - - lldb::clang_type_t + ClangASTType GetClangType (); //------------------------------------------------------------------ @@ -624,7 +621,7 @@ public: GetObjectRuntimeLanguage(); virtual uint32_t - GetTypeInfo (lldb::clang_type_t *pointee_or_element_clang_type = NULL); + GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL); virtual bool IsPointerType (); @@ -718,12 +715,6 @@ public: return m_is_array_item_for_pointer; } - virtual bool - SetClangAST (clang::ASTContext *ast) - { - return false; - } - virtual const char * GetValueAsCString (); @@ -1337,10 +1328,7 @@ protected: // Sublasses must implement the functions below. //------------------------------------------------------------------ - virtual clang::ASTContext * - GetClangASTImpl () = 0; - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl () = 0; const char * diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index 2ddee7aaa1f..1538d7a5563 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -66,10 +66,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); ClangASTType m_cast_type; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index b071a0f3510..780529a4af1 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -81,20 +81,13 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl () - { - return m_clang_ast; - } - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl () { return m_clang_type; } - clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from - void *m_clang_type; // The type of the child in question within the parent (m_parent_sp) + ClangASTType m_clang_type; ConstString m_type_name; uint64_t m_byte_size; int32_t m_byte_offset; @@ -111,8 +104,7 @@ protected: friend class ValueObject; friend class ValueObjectConstResult; ValueObjectChild (ValueObject &parent, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, uint64_t byte_size, int32_t byte_offset, diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index bce25e59e77..4964d0589a0 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -34,16 +34,14 @@ public: static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, const DataExtractor &data, lldb::addr_t address = LLDB_INVALID_ADDRESS); static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, @@ -52,8 +50,7 @@ public: static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, lldb::addr_t address, AddressType address_type, @@ -61,7 +58,6 @@ public: static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, Value &value, const ConstString &name); @@ -87,13 +83,6 @@ public: virtual bool IsInScope (); - virtual bool - SetClangAST (clang::ASTContext *ast) - { - m_clang_ast = ast; - return true; - } - void SetByteSize (size_t size); @@ -139,13 +128,9 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); - clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from ConstString m_type_name; uint64_t m_byte_size; @@ -159,15 +144,13 @@ private: lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, const DataExtractor &data, lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, @@ -175,15 +158,13 @@ private: lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, lldb::addr_t address, AddressType address_type, uint32_t addr_byte_size); ValueObjectConstResult (ExecutionContextScope *exe_scope, - clang::ASTContext *clang_ast, const Value &value, const ConstString &name); diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h index fbc3e7c694d..9063276b019 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h @@ -27,8 +27,7 @@ class ValueObjectConstResultChild : public ValueObjectChild public: ValueObjectConstResultChild (ValueObject &parent, - clang::ASTContext *clang_ast, - void *clang_type, + const ClangASTType &clang_type, const ConstString &name, uint32_t byte_size, int32_t byte_offset, @@ -45,7 +44,7 @@ public: virtual ValueObject * CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); - virtual lldb::clang_type_t + virtual ClangASTType GetClangType () { return ValueObjectChild::GetClangType(); diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 12f75bdae93..c0f6baade3f 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -109,10 +109,7 @@ protected: return true; } - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); Address m_address; ///< The variable that this value object is based upon diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index 21bd75a678d..627d73eb4b2 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -63,10 +63,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); Address m_address; ///< The variable that this value object is based upon diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 73f6e583ad6..6820629f08e 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -56,10 +56,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; @@ -113,10 +110,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; @@ -173,17 +167,14 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; RegisterInfo m_reg_info; RegisterValue m_reg_value; ConstString m_type_name; - void *m_clang_type; + ClangASTType m_clang_type; private: void diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index 75c57c12f77..f1d8c885c25 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -140,10 +140,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); virtual void diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index 897ce82d959..8a30b00f6bb 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -71,10 +71,7 @@ protected: virtual bool UpdateValue (); - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t + virtual ClangASTType GetClangTypeImpl (); lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon diff --git a/lldb/include/lldb/DataFormatters/FormatNavigator.h b/lldb/include/lldb/DataFormatters/FormatNavigator.h index 0d3a833660b..a738cfd069e 100644 --- a/lldb/include/lldb/DataFormatters/FormatNavigator.h +++ b/lldb/include/lldb/DataFormatters/FormatNavigator.h @@ -288,8 +288,8 @@ public: uint32_t* why = NULL) { uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice; - clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType()); - bool ret = Get(valobj, type, entry, use_dynamic, value); + ClangASTType ast_type(valobj.GetClangType()); + bool ret = Get(valobj, ast_type, entry, use_dynamic, value); if (ret) entry = MapValueType(entry); else @@ -523,29 +523,23 @@ protected: bool Get_Impl (ValueObject& valobj, - clang::QualType type, + ClangASTType clang_type, MapValueType& entry, lldb::DynamicValueType use_dynamic, uint32_t& reason) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - if (type.isNull()) + if (!clang_type.IsValid()) { if (log) - log->Printf("[Get_Impl] type is NULL, returning"); + log->Printf("[Get_Impl] type is invalid, returning"); return false; } - type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict(); - const clang::Type* typePtr = type.getTypePtrOrNull(); - if (!typePtr) - { - if (log) - log->Printf("[Get_Impl] type is NULL, returning"); - return false; - } - ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str()); + clang_type = clang_type.RemoveFastQualifiers(); + + ConstString typeName(clang_type.GetConstTypeName()); if (valobj.GetBitfieldBitSize() > 0) { @@ -569,33 +563,30 @@ protected: log->Printf("[Get_Impl] no direct match"); // strip pointers and references and see if that helps - if (typePtr->isReferenceType()) + if (clang_type.IsReferenceType()) { if (log) log->Printf("[Get_Impl] stripping reference"); - if (Get_Impl(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences()) + if (Get_Impl(valobj, clang_type.GetNonReferenceType(), entry, use_dynamic, reason) && !entry->SkipsReferences()) { reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference; return true; } } - else if (typePtr->isPointerType()) + else if (clang_type.IsPointerType()) { if (log) log->Printf("[Get_Impl] stripping pointer"); - clang::QualType pointee = typePtr->getPointeeType(); - if (Get_Impl(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers()) + if (Get_Impl(valobj, clang_type.GetPointeeType(), entry, use_dynamic, reason) && !entry->SkipsPointers()) { reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference; return true; } } - bool canBeObjCDynamic = ClangASTContext::IsPossibleDynamicType (valobj.GetClangAST(), - type.getAsOpaquePtr(), - NULL, - false, // no C++ - true); // yes ObjC + bool canBeObjCDynamic = valobj.GetClangType().IsPossibleDynamicType (NULL, + false, // no C++ + true); // yes ObjC if (canBeObjCDynamic) { @@ -611,8 +602,7 @@ protected: } if (log) log->Printf("[Get_Impl] dynamic disabled or failed - stripping ObjC pointer"); - clang::QualType pointee = typePtr->getPointeeType(); - if (Get_Impl(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers()) + if (Get_Impl(valobj, clang_type.GetPointeeType(), entry, use_dynamic, reason) && !entry->SkipsPointers()) { reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference; return true; @@ -620,12 +610,11 @@ protected: } // try to strip typedef chains - const clang::TypedefType* type_tdef = type->getAs<clang::TypedefType>(); - if (type_tdef) + if (clang_type.IsTypedefType()) { if (log) log->Printf("[Get_Impl] stripping typedef"); - if ((Get_Impl(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades()) + if ((Get_Impl(valobj, clang_type.GetTypedefedType(), entry, use_dynamic, reason)) && entry->Cascades()) { reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs; return true; @@ -639,40 +628,35 @@ protected: // we are separately passing in valobj and type because the valobj is fixed (and is used for ObjC discovery and bitfield size) // but the type can change (e.g. stripping pointers, ...) bool Get (ValueObject& valobj, - clang::QualType type, + ClangASTType clang_type, MapValueType& entry, lldb::DynamicValueType use_dynamic, uint32_t& reason) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - if (Get_Impl (valobj,type,entry,use_dynamic,reason)) + if (Get_Impl (valobj, clang_type, entry, use_dynamic, reason)) return true; // try going to the unqualified type do { if (log) log->Printf("[Get] trying the unqualified type"); - lldb::clang_type_t opaque_type = type.getAsOpaquePtr(); - if (!opaque_type) - { - if (log) - log->Printf("[Get] could not get the opaque_type"); + if (!clang_type.IsValid()) break; - } - ClangASTType unqual_clang_ast_type = ClangASTType::GetFullyUnqualifiedType(valobj.GetClangAST(),opaque_type); + + ClangASTType unqual_clang_ast_type = clang_type.GetFullyUnqualifiedType(); if (!unqual_clang_ast_type.IsValid()) { if (log) log->Printf("[Get] could not get the unqual_clang_ast_type"); break; } - clang::QualType unqualified_qual_type = clang::QualType::getFromOpaquePtr(unqual_clang_ast_type.GetOpaqueQualType()); - if (unqualified_qual_type.getTypePtrOrNull() != type.getTypePtrOrNull()) + if (unqual_clang_ast_type.GetOpaqueQualType() != clang_type.GetOpaqueQualType()) { if (log) log->Printf("[Get] unqualified type is there and is not the same, let's try"); - if (Get_Impl (valobj,unqualified_qual_type,entry,use_dynamic,reason)) + if (Get_Impl (valobj, unqual_clang_ast_type,entry, use_dynamic, reason)) return true; } else if (log) @@ -689,7 +673,7 @@ protected: { if (log) log->Printf("[Get] has a static value - actually use it"); - if (Get(*static_value_sp.get(), clang::QualType::getFromOpaquePtr(static_value_sp->GetClangType()) , entry, use_dynamic, reason)) + if (Get(*static_value_sp.get(), static_value_sp->GetClangType(), entry, use_dynamic, reason)) { reason |= lldb_private::eFormatterChoiceCriterionWentToStaticValue; return true; diff --git a/lldb/include/lldb/Expression/ASTDumper.h b/lldb/include/lldb/Expression/ASTDumper.h index 5118eb38b42..47f7ea460b8 100644 --- a/lldb/include/lldb/Expression/ASTDumper.h +++ b/lldb/include/lldb/Expression/ASTDumper.h @@ -28,6 +28,7 @@ public: ASTDumper (const clang::Type *type); ASTDumper (clang::QualType type); ASTDumper (lldb::clang_type_t type); + ASTDumper (const ClangASTType &clang_type); const char *GetCString(); void ToSTDERR(); diff --git a/lldb/include/lldb/Expression/ClangASTSource.h b/lldb/include/lldb/Expression/ClangASTSource.h index 020a815d0da..3e41a9e69e9 100644 --- a/lldb/include/lldb/Expression/ClangASTSource.h +++ b/lldb/include/lldb/Expression/ClangASTSource.h @@ -404,10 +404,8 @@ protected: /// @return /// The imported type. //------------------------------------------------------------------ - void * - GuardedCopyType (clang::ASTContext *dest_context, - clang::ASTContext *source_context, - void *clang_type); + ClangASTType + GuardedCopyType (const ClangASTType &src_type); friend struct NameSearchContext; @@ -434,7 +432,7 @@ struct NameSearchContext { ClangASTImporter::NamespaceMapSP m_namespace_map; ///< The mapping of all namespaces found for this request back to their modules const clang::DeclarationName &m_decl_name; ///< The name being looked for const clang::DeclContext *m_decl_context; ///< The DeclContext to put declarations into - llvm::SmallSet <lldb::clang_type_t, 5> m_function_types; ///< All the types of functions that have been reported, so we don't report conflicts + llvm::SmallSet <ClangASTType, 5> m_function_types; ///< All the types of functions that have been reported, so we don't report conflicts struct { bool variable : 1; @@ -479,7 +477,7 @@ struct NameSearchContext { /// @param[in] type /// The opaque QualType for the VarDecl being registered. //------------------------------------------------------------------ - clang::NamedDecl *AddVarDecl(void *type); + clang::NamedDecl *AddVarDecl(const ClangASTType &type); //------------------------------------------------------------------ /// Create a FunDecl with the name being searched for and the provided @@ -488,7 +486,7 @@ struct NameSearchContext { /// @param[in] type /// The opaque QualType for the FunDecl being registered. //------------------------------------------------------------------ - clang::NamedDecl *AddFunDecl(void *type); + clang::NamedDecl *AddFunDecl(const ClangASTType &type); //------------------------------------------------------------------ /// Create a FunDecl with the name being searched for and generic @@ -504,7 +502,7 @@ struct NameSearchContext { /// @param[in] type /// The opaque QualType for the TypeDecl being registered. //------------------------------------------------------------------ - clang::NamedDecl *AddTypeDecl(void *type); + clang::NamedDecl *AddTypeDecl(const ClangASTType &clang_type); //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h index b8be7f031e5..b2a43e0ac75 100644 --- a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h @@ -549,8 +549,8 @@ private: /// @param[in] var /// The variable to evaluate. /// - /// @param[in] parser_ast_context - /// The AST context of the parser, to store the found type in. + /// @param[out] var_location + /// The variable location value to fill in /// /// @param[out] found_type /// The type of the found value, as it was found in the user process. @@ -566,11 +566,11 @@ private: /// The Decl to be looked up. /// /// @return - /// The LLDB Value for the variable. + /// Return true if the value was successfully filled in. //------------------------------------------------------------------ - Value * + bool GetVariableValue (lldb::VariableSP &var, - clang::ASTContext *parser_ast_context, + lldb_private::Value &var_location, TypeFromUser *found_type = NULL, TypeFromParser *parser_type = NULL); diff --git a/lldb/include/lldb/Expression/ClangExpressionVariable.h b/lldb/include/lldb/Expression/ClangExpressionVariable.h index 4f0ba6798b6..620e604fb18 100644 --- a/lldb/include/lldb/Expression/ClangExpressionVariable.h +++ b/lldb/include/lldb/Expression/ClangExpressionVariable.h @@ -25,6 +25,7 @@ #include "lldb/lldb-public.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" +#include "lldb/Core/Value.h" #include "lldb/Symbol/TaggedASTType.h" namespace llvm { @@ -98,7 +99,7 @@ public: m_parser_type(), m_named_decl (NULL), m_llvm_value (NULL), - m_lldb_value (NULL), + m_lldb_value (), m_lldb_var (), m_lldb_sym (NULL) { @@ -107,7 +108,7 @@ public: TypeFromParser m_parser_type; ///< The type of the variable according to the parser const clang::NamedDecl *m_named_decl; ///< The Decl corresponding to this variable llvm::Value *m_llvm_value; ///< The IR value corresponding to this variable; usually a GlobalValue - lldb_private::Value *m_lldb_value; ///< The value found in LLDB for this variable + lldb_private::Value m_lldb_value; ///< The value found in LLDB for this variable lldb::VariableSP m_lldb_var; ///< The original variable for this variable const lldb_private::Symbol *m_lldb_sym; ///< The original symbol for this variable, if it was a symbol }; @@ -215,17 +216,11 @@ public: void SetRegisterInfo (const RegisterInfo *reg_info); - lldb::clang_type_t + ClangASTType GetClangType (); void - SetClangType (lldb::clang_type_t); - - clang::ASTContext * - GetClangAST (); - - void - SetClangAST (clang::ASTContext *ast); + SetClangType (const ClangASTType &clang_type); TypeFromUser GetTypeFromUser (); @@ -420,8 +415,7 @@ public: { lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size)); var_sp->SetName (name); - var_sp->SetClangType (user_type.GetOpaqueQualType()); - var_sp->SetClangAST (user_type.GetASTContext()); + var_sp->SetClangType (user_type); m_variables.push_back(var_sp); return var_sp; } diff --git a/lldb/include/lldb/Expression/ClangFunction.h b/lldb/include/lldb/Expression/ClangFunction.h index ca7619f27d4..3f96f7bd311 100644 --- a/lldb/include/lldb/Expression/ClangFunction.h +++ b/lldb/include/lldb/Expression/ClangFunction.h @@ -112,8 +112,7 @@ public: /// be overridden using WriteFunctionArguments(). //------------------------------------------------------------------ ClangFunction (ExecutionContextScope &exe_scope, - ClangASTContext *ast_context, - void *return_qualtype, + const ClangASTType &return_type, const Address& function_address, const ValueList &arg_value_list); @@ -624,7 +623,7 @@ private: Function *m_function_ptr; ///< The function we're going to call. May be NULL if we don't have debug info for the function. Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type. - lldb::clang_type_t m_function_return_qual_type; ///< The opaque clang qual type for the function return type. + ClangASTType m_function_return_type; ///< The opaque clang qual type for the function return type. ClangASTContext *m_clang_ast_context; ///< This is the clang_ast_context that we're getting types from the and value, and the function return the function pointer is NULL. std::string m_wrapper_function_name; ///< The name of the wrapper function. diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index 35fa0a90e3d..2692831ecc8 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -250,7 +250,6 @@ public: //------------------------------------------------------------------ bool Evaluate (ExecutionContextScope *exe_scope, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, lldb::addr_t loclist_base_load_addr, @@ -264,7 +263,6 @@ public: //------------------------------------------------------------------ bool Evaluate (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, @@ -281,9 +279,6 @@ public: /// expression. The location expression may access the target's /// memory, especially if it comes from the expression parser. /// - /// @param[in] ast_context - /// The context in which to interpret types. - /// /// @param[in] opcodes /// This is a static method so the opcodes need to be provided /// explicitly. @@ -334,7 +329,6 @@ public: //------------------------------------------------------------------ static bool Evaluate (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index b3da283d610..75fc07b480e 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -35,31 +35,6 @@ class Declaration; class ClangASTContext { public: - enum { - eTypeHasChildren = (1u << 0), - eTypeHasValue = (1u << 1), - eTypeIsArray = (1u << 2), - eTypeIsBlock = (1u << 3), - eTypeIsBuiltIn = (1u << 4), - eTypeIsClass = (1u << 5), - eTypeIsCPlusPlus = (1u << 6), - eTypeIsEnumeration = (1u << 7), - eTypeIsFuncPrototype = (1u << 8), - eTypeIsMember = (1u << 9), - eTypeIsObjC = (1u << 10), - eTypeIsPointer = (1u << 11), - eTypeIsReference = (1u << 12), - eTypeIsStructUnion = (1u << 13), - eTypeIsTemplate = (1u << 14), - eTypeIsTypedef = (1u << 15), - eTypeIsVector = (1u << 16), - eTypeIsScalar = (1u << 17), - eTypeIsInteger = (1u << 18), - eTypeIsFloat = (1u << 19), - eTypeIsComplex = (1u << 20), - eTypeIsSigned = (1u << 21) - }; - typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *); typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); @@ -123,20 +98,6 @@ public: void RemoveExternalSource (); - - bool - GetCompleteType (lldb::clang_type_t clang_type); - - static bool - GetCompleteType (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - bool - IsCompleteType (lldb::clang_type_t clang_type); - - static bool - IsCompleteType (clang::ASTContext *ast, - lldb::clang_type_t clang_type); bool GetCompleteDecl (clang::Decl *decl) @@ -175,70 +136,48 @@ public: //------------------------------------------------------------------ // Basic Types //------------------------------------------------------------------ - - lldb::clang_type_t + ClangASTType GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding, uint32_t bit_size); - - static lldb::clang_type_t + + static ClangASTType GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast, lldb::Encoding encoding, uint32_t bit_size); - lldb::clang_type_t - GetBuiltinTypeForDWARFEncodingAndBitSize ( - const char *type_name, - uint32_t dw_ate, - uint32_t bit_size); + ClangASTType + GetBasicType (lldb::BasicType type); - static lldb::clang_type_t - GetBuiltInType_void(clang::ASTContext *ast); + static ClangASTType + GetBasicType (clang::ASTContext *ast, lldb::BasicType type); - lldb::clang_type_t - GetBuiltInType_void() - { - return GetBuiltInType_void(getASTContext()); - } + static ClangASTType + GetBasicType (clang::ASTContext *ast, const ConstString &name); - lldb::clang_type_t - GetBuiltInType_bool(); + static lldb::BasicType + GetBasicTypeEnumeration (const ConstString &name); - lldb::clang_type_t - GetBuiltInType_objc_id(); - - static lldb::clang_type_t - GetBuiltInType_objc_id(clang::ASTContext *ast); + ClangASTType + GetBuiltinTypeForDWARFEncodingAndBitSize ( + const char *type_name, + uint32_t dw_ate, + uint32_t bit_size); - lldb::clang_type_t - GetBuiltInType_objc_Class(); + ClangASTType + GetCStringType(bool is_const); - static lldb::clang_type_t + static ClangASTType GetUnknownAnyType(clang::ASTContext *ast); - lldb::clang_type_t + ClangASTType GetUnknownAnyType() { return ClangASTContext::GetUnknownAnyType(getASTContext()); } - - lldb::clang_type_t - GetBuiltInType_objc_selector(); - - lldb::clang_type_t - GetCStringType(bool is_const); - - lldb::clang_type_t - GetVoidType(); - lldb::clang_type_t - GetVoidType(clang::ASTContext *ast); + uint32_t + GetPointerByteSize (); - lldb::clang_type_t - GetVoidPtrType(bool is_const); - - static lldb::clang_type_t - GetVoidPtrType(clang::ASTContext *ast, bool is_const); - static clang::DeclContext * GetTranslationUnitDecl (clang::ASTContext *ast); @@ -254,10 +193,9 @@ public: bool &is_instance_method, ConstString &language_object_name); - static lldb::clang_type_t + static ClangASTType CopyType(clang::ASTContext *dest_context, - clang::ASTContext *source_context, - lldb::clang_type_t clang_type); + ClangASTType source_type); static clang::Decl * CopyDecl (clang::ASTContext *dest_context, @@ -265,146 +203,42 @@ public: clang::Decl *source_decl); static bool - AreTypesSame(clang::ASTContext *ast, - lldb::clang_type_t type1, - lldb::clang_type_t type2, + AreTypesSame(ClangASTType type1, + ClangASTType type2, bool ignore_qualifiers = false); - bool - AreTypesSame(lldb::clang_type_t type1, - lldb::clang_type_t type2, - bool ignore_qualifiers = false) - { - return ClangASTContext::AreTypesSame(getASTContext(), type1, type2, ignore_qualifiers); - } - - - lldb::clang_type_t + ClangASTType GetTypeForDecl (clang::TagDecl *decl); - lldb::clang_type_t + ClangASTType GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl); - static lldb::BasicType - GetLLDBBasicTypeEnumeration (lldb::clang_type_t clang_type); - //------------------------------------------------------------------ - // CVR modifiers + // Structure, Unions, Classes //------------------------------------------------------------------ - static lldb::clang_type_t - AddConstModifier (lldb::clang_type_t clang_type); + static clang::AccessSpecifier + ConvertAccessTypeToAccessSpecifier (lldb::AccessType access); - static lldb::clang_type_t - AddRestrictModifier (lldb::clang_type_t clang_type); + static clang::AccessSpecifier + UnifyAccessSpecifiers (clang::AccessSpecifier lhs, clang::AccessSpecifier rhs); - static lldb::clang_type_t - AddVolatileModifier (lldb::clang_type_t clang_type); + static uint32_t + GetNumBaseClasses (const clang::CXXRecordDecl *cxx_record_decl, + bool omit_empty_base_classes); - //------------------------------------------------------------------ - // Structure, Unions, Classes - //------------------------------------------------------------------ + static uint32_t + GetIndexForRecordBase (const clang::RecordDecl *record_decl, + const clang::CXXBaseSpecifier *base_spec, + bool omit_empty_base_classes); - lldb::clang_type_t + ClangASTType CreateRecordType (clang::DeclContext *decl_ctx, lldb::AccessType access_type, const char *name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata = NULL); - - static clang::FieldDecl * - AddFieldToRecordType (clang::ASTContext *ast, - lldb::clang_type_t record_qual_type, - const char *name, - lldb::clang_type_t field_type, - lldb::AccessType access, - uint32_t bitfield_bit_size); - - clang::FieldDecl * - AddFieldToRecordType (lldb::clang_type_t record_qual_type, - const char *name, - lldb::clang_type_t field_type, - lldb::AccessType access, - uint32_t bitfield_bit_size) - { - return ClangASTContext::AddFieldToRecordType (getASTContext(), - record_qual_type, - name, - field_type, - access, - bitfield_bit_size); - } - - clang::VarDecl * - AddVariableToRecordType (lldb::clang_type_t record_opaque_type, - const char *name, - lldb::clang_type_t var_opaque_type, - lldb::AccessType access) - { - return ClangASTContext::AddVariableToRecordType (getASTContext(), - record_opaque_type, - name, - var_opaque_type, - access); - } - - static clang::VarDecl * - AddVariableToRecordType (clang::ASTContext *ast, - lldb::clang_type_t record_opaque_type, - const char *name, - lldb::clang_type_t var_opaque_type, - lldb::AccessType access); - - static void - BuildIndirectFields (clang::ASTContext *ast, - lldb::clang_type_t record_qual_type); - - void - BuildIndirectFields (lldb::clang_type_t record_qual_type) - { - ClangASTContext::BuildIndirectFields(getASTContext(), - record_qual_type); - } - - static clang::CXXMethodDecl * - AddMethodToCXXRecordType (clang::ASTContext *ast, - lldb::clang_type_t record_opaque_type, - const char *name, - lldb::clang_type_t method_type, - lldb::AccessType access, - bool is_virtual, - bool is_static, - bool is_inline, - bool is_explicit, - bool is_attr_used, - bool is_artificial); - - clang::CXXMethodDecl * - AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type, - const char *name, - lldb::clang_type_t method_type, - lldb::AccessType access, - bool is_virtual, - bool is_static, - bool is_inline, - bool is_explicit, - bool is_attr_used, - bool is_artificial) - - { - return ClangASTContext::AddMethodToCXXRecordType (getASTContext(), - record_opaque_type, - name, - method_type, - access, - is_virtual, - is_static, - is_inline, - is_explicit, - is_attr_used, - is_artificial); - } class TemplateParameterInfos { @@ -453,7 +287,7 @@ public: int kind, const TemplateParameterInfos &infos); - lldb::clang_type_t + ClangASTType CreateClassTemplateSpecializationType (clang::ClassTemplateSpecializationDecl *class_template_specialization_decl); static clang::DeclContext * @@ -479,292 +313,16 @@ public: static bool RecordHasFields (const clang::RecordDecl *record_decl); - void - SetDefaultAccessForRecordFields (lldb::clang_type_t clang_type, - int default_accessibility, - int *assigned_accessibilities, - size_t num_assigned_accessibilities); - lldb::clang_type_t + ClangASTType CreateObjCClass (const char *name, clang::DeclContext *decl_ctx, bool isForwardDecl, bool isInternal, ClangASTMetadata *metadata = NULL); - - static clang::FieldDecl * - AddObjCClassIVar (clang::ASTContext *ast, - lldb::clang_type_t class_opaque_type, - const char *name, - lldb::clang_type_t ivar_opaque_type, - lldb::AccessType access, - uint32_t bitfield_bit_size, - bool isSynthesized); - - clang::FieldDecl * - AddObjCClassIVar (lldb::clang_type_t class_opaque_type, - const char *name, - lldb::clang_type_t ivar_opaque_type, - lldb::AccessType access, - uint32_t bitfield_bit_size, - bool isSynthesized) - { - return ClangASTContext::AddObjCClassIVar (getASTContext(), - class_opaque_type, - name, - ivar_opaque_type, - access, - bitfield_bit_size, - isSynthesized); - } - - static bool - AddObjCClassProperty - ( - clang::ASTContext *ast, - lldb::clang_type_t class_opaque_type, - const char *property_name, - lldb::clang_type_t property_opaque_type, // The property type is only required if you don't have an ivar decl - clang::ObjCIvarDecl *ivar_decl, - const char *property_setter_name, - const char *property_getter_name, - uint32_t property_attributes, - ClangASTMetadata *metadata = NULL - ); - - bool - AddObjCClassProperty - ( - lldb::clang_type_t class_opaque_type, - const char *property_name, - lldb::clang_type_t property_opaque_type, - clang::ObjCIvarDecl *ivar_decl, - const char *property_setter_name, - const char *property_getter_name, - uint32_t property_attributes, - ClangASTMetadata *metadata = NULL - ) - { - return ClangASTContext::AddObjCClassProperty (getASTContext(), - class_opaque_type, - property_name, - property_opaque_type, - ivar_decl, - property_setter_name, - property_getter_name, - property_attributes, - metadata); - } - - bool - SetObjCSuperClass (lldb::clang_type_t class_clang_type, - lldb::clang_type_t superclass_clang_type); - - static bool - ObjCTypeHasIVars (lldb::clang_type_t class_clang_type, bool check_superclass); - - static bool - ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, - bool check_superclass); - - - static clang::ObjCMethodDecl * - AddMethodToObjCObjectType (clang::ASTContext *ast, - lldb::clang_type_t class_opaque_type, - const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - lldb::clang_type_t method_opaque_type, - lldb::AccessType access, - bool is_artificial); - - clang::ObjCMethodDecl * - AddMethodToObjCObjectType (lldb::clang_type_t class_opaque_type, - const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - lldb::clang_type_t method_opaque_type, - lldb::AccessType access, - bool is_artificial) - { - return AddMethodToObjCObjectType (getASTContext(), - class_opaque_type, - name, - method_opaque_type, - access, is_artificial); - } - - static bool - SetHasExternalStorage (lldb::clang_type_t clang_type, bool has_extern); - - //------------------------------------------------------------------ - // Aggregate Types - //------------------------------------------------------------------ - static bool - IsAggregateType (lldb::clang_type_t clang_type); // Returns a mask containing bits from the ClangASTContext::eTypeXXX enumerations - static uint32_t - GetTypeInfo (lldb::clang_type_t clang_type, - clang::ASTContext *ast, // The AST for clang_type (can be NULL) - lldb::clang_type_t *pointee_or_element_type); // (can be NULL) - - static uint32_t - GetNumChildren (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - bool omit_empty_base_classes); - static uint32_t - GetNumDirectBaseClasses (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - static uint32_t - GetNumVirtualBaseClasses (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - static uint32_t - GetNumFields (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - static lldb::clang_type_t - GetDirectBaseClassAtIndex (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - size_t idx, - uint32_t *bit_offset_ptr); - - static lldb::clang_type_t - GetVirtualBaseClassAtIndex (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - size_t idx, - uint32_t *bit_offset_ptr); - - static lldb::clang_type_t - GetFieldAtIndex (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - size_t idx, - std::string& name, - uint64_t *bit_offset_ptr, - uint32_t *bitfield_bit_size_ptr, - bool *is_bitfield_ptr); - - static size_t - GetIndexOfFieldWithName (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - const char* name, - lldb::clang_type_t* field_clang_type = NULL, - uint64_t *bit_offset_ptr = NULL, - uint32_t *bitfield_bit_size_ptr = NULL, - bool *is_bitfield_ptr = NULL); - - static uint32_t - GetNumPointeeChildren (lldb::clang_type_t clang_type); - - lldb::clang_type_t - GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, - const char *parent_name, - lldb::clang_type_t parent_clang_type, - size_t idx, - bool transparent_pointers, - bool omit_empty_base_classes, - bool ignore_array_bounds, - std::string& child_name, - uint32_t &child_byte_size, - int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, - bool &child_is_deref_of_parent); - - static lldb::clang_type_t - GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, - clang::ASTContext *ast, - const char *parent_name, - lldb::clang_type_t parent_clang_type, - size_t idx, - bool transparent_pointers, - bool omit_empty_base_classes, - bool ignore_array_bounds, - std::string& child_name, - uint32_t &child_byte_size, - int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, - bool &child_is_deref_of_parent); - - // Lookup a child given a name. This function will match base class names - // and member member names in "clang_type" only, not descendants. - static uint32_t - GetIndexOfChildWithName (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - const char *name, - bool omit_empty_base_classes); - - // Lookup a child member given a name. This function will match member names - // only and will descend into "clang_type" children in search for the first - // member in this class, or any base class that matches "name". - // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>> - // so we catch all names that match a given child name, not just the first. - static size_t - GetIndexOfChildMemberWithName (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - const char *name, - bool omit_empty_base_classes, - std::vector<uint32_t>& child_indexes); - - size_t - GetNumTemplateArguments (lldb::clang_type_t clang_type) - { - return GetNumTemplateArguments(getASTContext(), clang_type); - } - - lldb::clang_type_t - GetTemplateArgument (lldb::clang_type_t clang_type, - size_t idx, - lldb::TemplateArgumentKind &kind) - { - return GetTemplateArgument(getASTContext(), clang_type, idx, kind); - } - - static size_t - GetNumTemplateArguments (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - static lldb::clang_type_t - GetTemplateArgument (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - size_t idx, - lldb::TemplateArgumentKind &kind); - - //------------------------------------------------------------------ - // clang::TagType - //------------------------------------------------------------------ - - bool - SetTagTypeKind (lldb::clang_type_t tag_qual_type, - int kind); - - //------------------------------------------------------------------ - // C++ Base Classes - //------------------------------------------------------------------ - - clang::CXXBaseSpecifier * - CreateBaseClassSpecifier (lldb::clang_type_t base_class_type, - lldb::AccessType access, - bool is_virtual, - bool base_of_class); - - static void - DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, - unsigned num_base_classes); - - bool - SetBaseClassesForClassType (lldb::clang_type_t class_clang_type, - clang::CXXBaseSpecifier const * const *base_classes, - unsigned num_base_classes); - - //------------------------------------------------------------------ - // DeclContext Functions - //------------------------------------------------------------------ - - static clang::DeclContext * - GetDeclContextForType (lldb::clang_type_t qual_type); //------------------------------------------------------------------ // Namespace Declarations @@ -781,21 +339,21 @@ public: clang::FunctionDecl * CreateFunctionDeclaration (clang::DeclContext *decl_ctx, const char *name, - lldb::clang_type_t function_Type, + const ClangASTType &function_Type, int storage, bool is_inline); - static lldb::clang_type_t + static ClangASTType CreateFunctionType (clang::ASTContext *ast, - lldb::clang_type_t result_type, - lldb::clang_type_t *args, + const ClangASTType &result_type, + const ClangASTType *args, unsigned num_args, bool is_variadic, unsigned type_quals); - lldb::clang_type_t - CreateFunctionType (lldb::clang_type_t result_type, - lldb::clang_type_t *args, + ClangASTType + CreateFunctionType (const ClangASTType &result_type, + const ClangASTType *args, unsigned num_args, bool is_variadic, unsigned type_quals) @@ -810,8 +368,8 @@ public: clang::ParmVarDecl * CreateParameterDeclaration (const char *name, - lldb::clang_type_t param_type, - int storage); + const ClangASTType ¶m_type, + int storage); void SetFunctionParameters (clang::FunctionDecl *function_decl, @@ -822,222 +380,54 @@ public: // Array Types //------------------------------------------------------------------ - lldb::clang_type_t - CreateArrayType (lldb::clang_type_t element_type, + ClangASTType + CreateArrayType (const ClangASTType &element_type, size_t element_count, bool is_vector); //------------------------------------------------------------------ - // Tag Declarations - //------------------------------------------------------------------ - bool - StartTagDeclarationDefinition (lldb::clang_type_t qual_type); - - bool - CompleteTagDeclarationDefinition (lldb::clang_type_t qual_type); - - //------------------------------------------------------------------ // Enumeration Types //------------------------------------------------------------------ - lldb::clang_type_t + ClangASTType CreateEnumerationType (const char *name, clang::DeclContext *decl_ctx, const Declaration &decl, - lldb::clang_type_t integer_qual_type); - - static lldb::clang_type_t - GetEnumerationIntegerType (lldb::clang_type_t enum_clang_type); - - bool - AddEnumerationValueToEnumerationType (lldb::clang_type_t enum_qual_type, - lldb::clang_type_t enumerator_qual_type, - const Declaration &decl, - const char *name, - int64_t enum_value, - uint32_t enum_value_bit_size); + const ClangASTType &integer_qual_type); //------------------------------------------------------------------ - // Pointers & References + // Floating point functions //------------------------------------------------------------------ - lldb::clang_type_t - CreatePointerType (lldb::clang_type_t clang_type); - - static lldb::clang_type_t - CreatePointerType (clang::ASTContext *ast, - lldb::clang_type_t clang_type); - - static lldb::clang_type_t - CreateLValueReferenceType (clang::ASTContext *ast_context, - lldb::clang_type_t clang_type); - - static lldb::clang_type_t - CreateRValueReferenceType (clang::ASTContext *ast_context, - lldb::clang_type_t clang_type); - - lldb::clang_type_t - CreateLValueReferenceType (lldb::clang_type_t clang_type) - { - return ClangASTContext::CreateLValueReferenceType(getASTContext(), clang_type); - } - - lldb::clang_type_t - CreateRValueReferenceType (lldb::clang_type_t clang_type) - { - return ClangASTContext::CreateRValueReferenceType(getASTContext(), clang_type); - } - - lldb::clang_type_t - CreateMemberPointerType (lldb::clang_type_t clang_pointee_type, - lldb::clang_type_t clang_class_type); - - uint64_t - GetPointerBitSize (); - - static bool - IsIntegerType (lldb::clang_type_t clang_type, bool &is_signed); - static bool - IsPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); - - static bool - IsReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); - - static bool - IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); - - static bool - IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - lldb::clang_type_t *target_type = NULL); - - static bool - IsPossibleDynamicType (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - lldb::clang_type_t *dynamic_pointee_type, // Can pass NULL - bool check_cplusplus, - bool check_objc); - - static bool - IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); - - static bool - IsFunctionPointerType (lldb::clang_type_t clang_type); - - static lldb::clang_type_t - GetAsArrayType (lldb::clang_type_t clang_type, - lldb::clang_type_t *member_type, - uint64_t *size, - bool *is_incomplete); - - static bool - IsArrayType (lldb::clang_type_t clang_type, - lldb::clang_type_t *member_type, - uint64_t *size, - bool *is_incomplete) - { - return GetAsArrayType(clang_type, member_type, size, is_incomplete) != 0; - } - - //------------------------------------------------------------------ - // Typedefs - //------------------------------------------------------------------ - lldb::clang_type_t - CreateTypedefType (const char *name, - lldb::clang_type_t clang_type, - clang::DeclContext *decl_ctx); - - //------------------------------------------------------------------ - // Type names - //------------------------------------------------------------------ - static bool - IsFloatingPointType (lldb::clang_type_t clang_type, uint32_t &count, bool &is_complex); - - // true iff this is one of the types that can "fit" - // in a Scalar object - static bool - IsScalarType (lldb::clang_type_t clang_type); - - static bool - IsPointerToScalarType (lldb::clang_type_t clang_type); - - static bool - IsArrayOfScalarType (lldb::clang_type_t clang_type); - - static bool - GetCXXClassName (lldb::clang_type_t clang_type, - std::string &class_name); - - static bool - IsCXXClassType (lldb::clang_type_t clang_type); - - static bool - IsBeingDefined (lldb::clang_type_t clang_type); - - static bool - IsObjCClassType (lldb::clang_type_t clang_type); - - static bool - IsObjCObjectPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type); - - static bool - GetObjCClassName (lldb::clang_type_t clang_type, - std::string &class_name); - - static bool - IsCharType (lldb::clang_type_t clang_type); - - static size_t - GetArraySize (lldb::clang_type_t clang_type); - - //static bool - //ConvertFloatValueToString (clang::ASTContext *ast, - // lldb::clang_type_t clang_type, - // const uint8_t* bytes, - // size_t byte_size, - // int apint_byte_order, - // std::string &float_str); - - static size_t - ConvertStringToFloatValue (clang::ASTContext *ast, - lldb::clang_type_t clang_type, - const char *s, - uint8_t *dst, - size_t dst_size); - - lldb::clang_type_t + ClangASTType GetFloatTypeFromBitSize (size_t bit_size) { return GetFloatTypeFromBitSize (getASTContext(), bit_size); } - static lldb::clang_type_t + static ClangASTType GetFloatTypeFromBitSize (clang::ASTContext *ast, size_t bit_size); - //------------------------------------------------------------------ - // Qualifiers - //------------------------------------------------------------------ - static unsigned - GetTypeQualifiers(lldb::clang_type_t clang_type); protected: //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these //------------------------------------------------------------------ std::string m_target_triple; - std::unique_ptr<clang::ASTContext> m_ast_ap; - std::unique_ptr<clang::LangOptions> m_language_options_ap; - std::unique_ptr<clang::FileManager> m_file_manager_ap; - std::unique_ptr<clang::FileSystemOptions> m_file_system_options_ap; - std::unique_ptr<clang::SourceManager> m_source_manager_ap; - std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; - std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; + std::unique_ptr<clang::ASTContext> m_ast_ap; + std::unique_ptr<clang::LangOptions> m_language_options_ap; + std::unique_ptr<clang::FileManager> m_file_manager_ap; + std::unique_ptr<clang::FileSystemOptions> m_file_system_options_ap; + std::unique_ptr<clang::SourceManager> m_source_manager_ap; + std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; + std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; llvm::IntrusiveRefCntPtr<clang::TargetOptions> m_target_options_rp; - std::unique_ptr<clang::TargetInfo> m_target_info_ap; - std::unique_ptr<clang::IdentifierTable> m_identifier_table_ap; - std::unique_ptr<clang::SelectorTable> m_selector_table_ap; - std::unique_ptr<clang::Builtin::Context> m_builtins_ap; + std::unique_ptr<clang::TargetInfo> m_target_info_ap; + std::unique_ptr<clang::IdentifierTable> m_identifier_table_ap; + std::unique_ptr<clang::SelectorTable> m_selector_table_ap; + std::unique_ptr<clang::Builtin::Context> m_builtins_ap; CompleteTagDeclCallback m_callback_tag_decl; CompleteObjCInterfaceDeclCallback m_callback_objc_decl; void * m_callback_baton; + uint32_t m_pointer_byte_size; private: //------------------------------------------------------------------ // For ClangASTContext only diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index bc23230fbd9..10df7da893a 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -14,7 +14,6 @@ #include <set> #include "lldb/lldb-types.h" - #include "clang/AST/ASTImporter.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h index 63a2e1e6f55..d9e754e8ceb 100644 --- a/lldb/include/lldb/Symbol/ClangASTType.h +++ b/lldb/include/lldb/Symbol/ClangASTType.h @@ -13,6 +13,7 @@ #include <string> #include "lldb/lldb-private.h" #include "lldb/Core/ClangForward.h" +#include "clang/AST/Type.h" namespace lldb_private { @@ -29,16 +30,46 @@ namespace lldb_private { class ClangASTType { public: - + enum { + eTypeHasChildren = (1u << 0), + eTypeHasValue = (1u << 1), + eTypeIsArray = (1u << 2), + eTypeIsBlock = (1u << 3), + eTypeIsBuiltIn = (1u << 4), + eTypeIsClass = (1u << 5), + eTypeIsCPlusPlus = (1u << 6), + eTypeIsEnumeration = (1u << 7), + eTypeIsFuncPrototype = (1u << 8), + eTypeIsMember = (1u << 9), + eTypeIsObjC = (1u << 10), + eTypeIsPointer = (1u << 11), + eTypeIsReference = (1u << 12), + eTypeIsStructUnion = (1u << 13), + eTypeIsTemplate = (1u << 14), + eTypeIsTypedef = (1u << 15), + eTypeIsVector = (1u << 16), + eTypeIsScalar = (1u << 17), + eTypeIsInteger = (1u << 18), + eTypeIsFloat = (1u << 19), + eTypeIsComplex = (1u << 20), + eTypeIsSigned = (1u << 21) + }; + + + //---------------------------------------------------------------------- + // Constructors and Destructors + //---------------------------------------------------------------------- ClangASTType (clang::ASTContext *ast_context, lldb::clang_type_t type) : m_type (type), m_ast (ast_context) { } - - ClangASTType (const ClangASTType &tw) : - m_type (tw.m_type), - m_ast (tw.m_ast) + + ClangASTType (clang::ASTContext *ast_context, clang::QualType qual_type); + + ClangASTType (const ClangASTType &rhs) : + m_type (rhs.m_type), + m_ast (rhs.m_ast) { } @@ -48,125 +79,500 @@ public: { } - virtual ~ClangASTType(); + ~ClangASTType(); + //---------------------------------------------------------------------- + // Operators + //---------------------------------------------------------------------- + const ClangASTType & - operator= (const ClangASTType &atb) + operator= (const ClangASTType &rhs) { - m_type = atb.m_type; - m_ast = atb.m_ast; + m_type = rhs.m_type; + m_ast = rhs.m_ast; return *this; } + + //---------------------------------------------------------------------- + // Tests + //---------------------------------------------------------------------- + + operator bool () const + { + return m_type != NULL && m_ast != NULL; + } + + bool + operator < (const ClangASTType &rhs) const + { + if (m_ast == rhs.m_ast) + return m_type < rhs.m_type; + return m_ast < rhs.m_ast; + } + bool IsValid () const { return m_type != NULL && m_ast != NULL; } + + bool + IsArrayType (ClangASTType *element_type, + uint64_t *size, + bool *is_incomplete) const; - lldb::clang_type_t - GetOpaqueQualType() const - { - return m_type; + bool + IsArrayOfScalarType () const; + + bool + IsAggregateType () const; + + bool + IsBeingDefined () const; + + bool + IsCharType () const; + + bool + IsCompleteType () const; + + bool + IsConst() const; + + bool + IsCStringType (uint32_t &length) const; + + bool + IsCXXClassType () const; + + bool + IsDefined() const; + + bool + IsFloatingPointType (uint32_t &count, bool &is_complex) const; + + bool + IsFunctionType (bool *is_variadic_ptr = NULL) const; + + bool + IsVariadicFunctionType () const; + + bool + IsFunctionPointerType () const; + + bool + IsIntegerType (bool &is_signed) const; + + bool + IsObjCClassType () const; + + bool + IsObjCClassTypeAndHasIVars (bool check_superclass) const; + + bool + IsObjCObjectOrInterfaceType () const; + + bool + IsObjCObjectPointerType (ClangASTType *target_type = NULL); + + bool + IsPolymorphicClass () const; + + bool + IsPossibleCPlusPlusDynamicType (ClangASTType *target_type = NULL) const + { + return IsPossibleDynamicType (target_type, true, false); } + bool + IsPossibleDynamicType (ClangASTType *target_type, // Can pass NULL + bool check_cplusplus, + bool check_objc) const; + + + bool + IsPointerToScalarType () const; + + bool + IsPointerType (ClangASTType *pointee_type = NULL) const; + + bool + IsPointerOrReferenceType (ClangASTType *pointee_type = NULL) const; + + bool + IsReferenceType (ClangASTType *pointee_type = NULL) const; + + bool + IsScalarType () const; + + bool + IsTypedefType () const; + + bool + IsVoidType () const; + + bool + GetCXXClassName (std::string &class_name) const; + + bool + GetObjCClassName (std::string &class_name); + + + //---------------------------------------------------------------------- + // Type Completion + //---------------------------------------------------------------------- + + bool + GetCompleteType () const; + + //---------------------------------------------------------------------- + // AST related queries + //---------------------------------------------------------------------- + + size_t + GetPointerByteSize () const; + + //---------------------------------------------------------------------- + // Accessors + //---------------------------------------------------------------------- + clang::ASTContext * GetASTContext() const - { - return m_ast; + { + return m_ast; } + + ConstString + GetConstQualifiedTypeName () const; - static ClangASTType - GetCanonicalType (clang::ASTContext *ast, lldb::clang_type_t clang_type); + ConstString + GetConstTypeName () const; + + std::string + GetTypeName () const; - ClangASTType - GetCanonicalType () + uint32_t + GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL) const; + + lldb::LanguageType + GetMinimumLanguage (); + + lldb::clang_type_t + GetOpaqueQualType() const { - return GetCanonicalType (GetASTContext(), GetOpaqueQualType()); + return m_type; } - ConstString - GetConstTypeName (); + lldb::TypeClass + GetTypeClass () const; - ConstString - GetConstQualifiedTypeName (); + void + SetClangType (clang::ASTContext *ast, lldb::clang_type_t type) + { + m_ast = ast; + m_type = type; + } - static lldb::BasicType - GetBasicTypeEnumeration (const ConstString &name); + void + SetClangType (clang::ASTContext *ast, clang::QualType qual_type); - static ClangASTType - GetBasicType (clang::ASTContext *ast, lldb::BasicType type); + unsigned + GetTypeQualifiers() const; + + //---------------------------------------------------------------------- + // Creating related types + //---------------------------------------------------------------------- - static ClangASTType - GetBasicType (clang::ASTContext *ast, const ConstString &name); + ClangASTType + AddConstModifier () const; - static ConstString - GetConstTypeName (clang::ASTContext *ast, - lldb::clang_type_t clang_type); + ClangASTType + AddRestrictModifier () const; + + ClangASTType + AddVolatileModifier () const; + + // Using the current type, create a new typedef to that type using "typedef_name" + // as the name and "decl_ctx" as the decl context. + ClangASTType + CreateTypedefType (const char *typedef_name, + clang::DeclContext *decl_ctx) const; + + ClangASTType + GetArrayElementType (uint64_t& stride) const; + + ClangASTType + GetCanonicalType () const; - static ConstString - GetConstQualifiedTypeName (clang::ASTContext *ast, - lldb::clang_type_t clang_type); + ClangASTType + GetFullyUnqualifiedType () const; + + // Returns -1 if this isn't a function of if the fucntion doesn't have a prototype + // Returns a value >= 0 if there is a prototype. + int + GetFunctionArgumentCount () const; + + ClangASTType + GetFunctionArgumentTypeAtIndex (size_t idx); - static std::string - GetTypeNameForQualType (clang::ASTContext *ast, - clang::QualType qual_type); + ClangASTType + GetFunctionReturnType () const; + + ClangASTType + GetLValueReferenceType () const; + + ClangASTType + GetNonReferenceType () const; - static std::string - GetTypeNameForOpaqueQualType (clang::ASTContext *ast, - lldb::clang_type_t opaque_qual_type); + ClangASTType + GetPointeeType () const; + + ClangASTType + GetPointerType () const; + + ClangASTType + GetRValueReferenceType () const; - uint64_t - GetClangTypeByteSize (); + // If the current object represents a typedef type, get the underlying type + ClangASTType + GetTypedefedType () const; - static uint64_t - GetClangTypeByteSize (clang::ASTContext *ast_context, - lldb::clang_type_t clang_type); + ClangASTType + RemoveFastQualifiers () const; + //---------------------------------------------------------------------- + // Create related types using the current type's AST + //---------------------------------------------------------------------- + ClangASTType + GetBasicTypeFromAST (lldb::BasicType basic_type) const; + + //---------------------------------------------------------------------- + // Exploring the type + //---------------------------------------------------------------------- + uint64_t - GetClangTypeBitWidth (); + GetByteSize () const; - static uint64_t - GetClangTypeBitWidth (clang::ASTContext *ast_context, lldb::clang_type_t opaque_clang_qual_type); + uint64_t + GetBitSize () const; + + lldb::Encoding + GetEncoding (uint64_t &count) const; + + lldb::Format + GetFormat () const; + + size_t + GetTypeBitAlign () const; + + uint32_t + GetNumChildren (bool omit_empty_base_classes) const; + + lldb::BasicType + GetBasicTypeEnumeration () const; + static lldb::BasicType + GetBasicTypeEnumeration (const ConstString &name); + + uint32_t + GetNumDirectBaseClasses () const; + + uint32_t + GetNumVirtualBaseClasses () const; + + uint32_t + GetNumFields () const; + + ClangASTType + GetDirectBaseClassAtIndex (size_t idx, + uint32_t *bit_offset_ptr) const; + + ClangASTType + GetVirtualBaseClassAtIndex (size_t idx, + uint32_t *bit_offset_ptr) const; + + ClangASTType + GetFieldAtIndex (size_t idx, + std::string& name, + uint64_t *bit_offset_ptr, + uint32_t *bitfield_bit_size_ptr, + bool *is_bitfield_ptr) const; + + uint32_t + GetIndexOfFieldWithName (const char* name, + ClangASTType* field_clang_type = NULL, + uint64_t *bit_offset_ptr = NULL, + uint32_t *bitfield_bit_size_ptr = NULL, + bool *is_bitfield_ptr = NULL) const; + + uint32_t + GetNumPointeeChildren () const; + + ClangASTType + GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, + const char *parent_name, + size_t idx, + bool transparent_pointers, + bool omit_empty_base_classes, + bool ignore_array_bounds, + std::string& child_name, + uint32_t &child_byte_size, + int32_t &child_byte_offset, + uint32_t &child_bitfield_bit_size, + uint32_t &child_bitfield_bit_offset, + bool &child_is_base_class, + bool &child_is_deref_of_parent) const; + + // Lookup a child given a name. This function will match base class names + // and member member names in "clang_type" only, not descendants. + uint32_t + GetIndexOfChildWithName (const char *name, + bool omit_empty_base_classes) const; + + // Lookup a child member given a name. This function will match member names + // only and will descend into "clang_type" children in search for the first + // member in this class, or any base class that matches "name". + // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>> + // so we catch all names that match a given child name, not just the first. size_t - GetTypeBitAlign (); + GetIndexOfChildMemberWithName (const char *name, + bool omit_empty_base_classes, + std::vector<uint32_t>& child_indexes) const; - static size_t - GetTypeBitAlign (clang::ASTContext *ast_context, lldb::clang_type_t clang_type); + size_t + GetNumTemplateArguments () const; + + ClangASTType + GetTemplateArgument (size_t idx, + lldb::TemplateArgumentKind &kind) const; - lldb::LanguageType - GetMinimumLanguage (); - static lldb::LanguageType - GetMinimumLanguage (clang::ASTContext *ctx, - lldb::clang_type_t clang_type); + //---------------------------------------------------------------------- + // Modifying RecordType + //---------------------------------------------------------------------- + clang::FieldDecl * + AddFieldToRecordType (const char *name, + const ClangASTType &field_type, + lldb::AccessType access, + uint32_t bitfield_bit_size); + + void + BuildIndirectFields (); + + clang::VarDecl * + AddVariableToRecordType (const char *name, + const ClangASTType &var_type, + lldb::AccessType access); + + clang::CXXMethodDecl * + AddMethodToCXXRecordType (const char *name, + const ClangASTType &method_type, + lldb::AccessType access, + bool is_virtual, + bool is_static, + bool is_inline, + bool is_explicit, + bool is_attr_used, + bool is_artificial); + + // C++ Base Classes + clang::CXXBaseSpecifier * + CreateBaseClassSpecifier (lldb::AccessType access, + bool is_virtual, + bool base_of_class); + + static void + DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, + unsigned num_base_classes); + + bool + SetBaseClassesForClassType (clang::CXXBaseSpecifier const * const *base_classes, + unsigned num_base_classes); + + + bool + SetObjCSuperClass (const ClangASTType &superclass_clang_type); + + bool + AddObjCClassProperty (const char *property_name, + const ClangASTType &property_clang_type, + clang::ObjCIvarDecl *ivar_decl, + const char *property_setter_name, + const char *property_getter_name, + uint32_t property_attributes, + ClangASTMetadata *metadata); + + clang::ObjCMethodDecl * + AddMethodToObjCObjectType (const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") + const ClangASTType &method_clang_type, + lldb::AccessType access, + bool is_artificial); - static lldb::TypeClass - GetTypeClass (clang::ASTContext *ast_context, - lldb::clang_type_t clang_type); + clang::DeclContext * + GetDeclContextForType () const; - lldb::TypeClass - GetTypeClass () const - { - return GetTypeClass (GetASTContext(), GetOpaqueQualType()); - } bool - IsPolymorphicClass () - { - return IsPolymorphicClass(GetASTContext(), GetOpaqueQualType()); - } + SetDefaultAccessForRecordFields (int default_accessibility, + int *assigned_accessibilities, + size_t num_assigned_accessibilities); + + bool + SetHasExternalStorage (bool has_extern); + + + //------------------------------------------------------------------ + // clang::TagType + //------------------------------------------------------------------ + + bool + SetTagTypeKind (int kind) const; + + //------------------------------------------------------------------ + // Tag Declarations + //------------------------------------------------------------------ + bool + StartTagDeclarationDefinition (); + + bool + CompleteTagDeclarationDefinition (); - static bool - IsPolymorphicClass (clang::ASTContext *ast_context, lldb::clang_type_t clang_type); + //---------------------------------------------------------------------- + // Modifying Enumeration types + //---------------------------------------------------------------------- + bool + AddEnumerationValueToEnumerationType (const ClangASTType &enumerator_qual_type, + const Declaration &decl, + const char *name, + int64_t enum_value, + uint32_t enum_value_bit_size); + + ClangASTType - GetFullyUnqualifiedType (); + GetEnumerationIntegerType () const; + + + //------------------------------------------------------------------ + // Pointers & References + //------------------------------------------------------------------ + + // Call this function using the class type when you want to make a + // member pointer type to pointee_type. + ClangASTType + CreateMemberPointerType (const ClangASTType &pointee_type) const; - static ClangASTType - GetFullyUnqualifiedType (clang::ASTContext *ast_context, lldb::clang_type_t clang_type); + // Converts "s" to a floating point value and place resulting floating + // point bytes in the "dst" buffer. + size_t + ConvertStringToFloatValue (const char *s, + uint8_t *dst, + size_t dst_size) const; + //---------------------------------------------------------------------- + // Dumping types + //---------------------------------------------------------------------- void DumpValue (ExecutionContext *exe_ctx, Stream *s, @@ -181,22 +587,6 @@ public: bool verbose, uint32_t depth); - static void - DumpValue (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - ExecutionContext *exe_ctx, - Stream *s, - lldb::Format format, - const DataExtractor &data, - lldb::offset_t data_offset, - size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, - bool show_types, - bool show_summary, - bool verbose, - uint32_t depth); - bool DumpTypeValue (Stream *s, lldb::Format format, @@ -207,164 +597,50 @@ public: uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope); - - static bool - DumpTypeValue (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - Stream *s, - lldb::Format format, - const DataExtractor &data, - lldb::offset_t data_offset, - size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope); - void DumpSummary (ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size); - - - static void - DumpSummary (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - ExecutionContext *exe_ctx, - Stream *s, - const DataExtractor &data, - lldb::offset_t data_offset, - size_t data_byte_size); - - void - DumpTypeDescription (); // Dump to stdout void - DumpTypeDescription (Stream *s); - - static void - DumpTypeDescription (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - Stream *s); - - lldb::Encoding - GetEncoding (uint64_t &count); - - static lldb::Encoding - GetEncoding (lldb::clang_type_t opaque_clang_qual_type, uint64_t &count); + DumpTypeDescription () const; // Dump to stdout - lldb::Format - GetFormat (); - - static lldb::Format - GetFormat (lldb::clang_type_t opaque_clang_qual_type); - - uint64_t - GetTypeByteSize() const; + void + DumpTypeDescription (Stream *s) const; - static uint64_t - GetTypeByteSize(clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type); - bool GetValueAsScalar (const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, - Scalar &value); - - static bool - GetValueAsScalar (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - const DataExtractor &data, - lldb::offset_t data_offset, - size_t data_byte_size, - Scalar &value); - - - bool - IsDefined(); - - static bool - IsDefined (lldb::clang_type_t opaque_clang_qual_type); + Scalar &value) const; bool - IsConst(); - - static bool - IsConst (lldb::clang_type_t opaque_clang_qual_type); - - bool SetValueFromScalar (const Scalar &value, Stream &strm); - static bool - SetValueFromScalar (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - const Scalar &value, - Stream &strm); - - void - SetClangType (clang::ASTContext *ast, lldb::clang_type_t type) - { - m_type = type; - m_ast = ast; - } - bool ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, DataExtractor &data); - static bool - ReadFromMemory (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - ExecutionContext *exe_ctx, - lldb::addr_t addr, - AddressType address_type, - DataExtractor &data); - bool WriteToMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, StreamString &new_value); - static bool - WriteToMemory (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type, - ExecutionContext *exe_ctx, - lldb::addr_t addr, - AddressType address_type, - StreamString &new_value); - - lldb::clang_type_t - GetPointeeType () const; - - static lldb::clang_type_t - GetPointeeType (lldb::clang_type_t opaque_clang_qual_type); - - lldb::clang_type_t - GetArrayElementType (uint64_t& stride); - static lldb::clang_type_t - GetArrayElementType (clang::ASTContext* ast, - lldb::clang_type_t opaque_clang_qual_type, - uint64_t& stride); + clang::RecordDecl * + GetAsRecordDecl () const; - lldb::clang_type_t - GetPointerType () const; + clang::CXXRecordDecl * + GetAsCXXRecordDecl () const; - static lldb::clang_type_t - GetPointerType (clang::ASTContext *ast_context, - lldb::clang_type_t opaque_clang_qual_type); - - static lldb::clang_type_t - RemoveFastQualifiers (lldb::clang_type_t); - - static clang::CXXRecordDecl * - GetAsCXXRecordDecl (lldb::clang_type_t opaque_clang_qual_type); + clang::ObjCInterfaceDecl * + GetAsObjCInterfaceDecl () const; void Clear() @@ -373,9 +649,25 @@ public: m_ast = NULL; } + clang::QualType + GetQualType () const + { + if (m_type) + return clang::QualType::getFromOpaquePtr(m_type); + return clang::QualType(); + } + clang::QualType + GetCanonicalQualType () const + { + if (m_type) + return clang::QualType::getFromOpaquePtr(m_type).getCanonicalType(); + return clang::QualType(); + } + private: lldb::clang_type_t m_type; clang::ASTContext *m_ast; + }; bool operator == (const ClangASTType &lhs, const ClangASTType &rhs); diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index 55cc819496c..787f81c5ad2 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -564,19 +564,9 @@ public: //------------------------------------------------------------------ const Type* GetType() const; - - lldb::clang_type_t - GetReturnClangType (); - - // The Number of arguments, or -1 for an unprototyped function. - int - GetArgumentCount (); - - lldb::clang_type_t - GetArgumentTypeAtIndex (size_t idx); - - bool - IsVariadic (); + + ClangASTType + GetClangType (); uint32_t GetPrologueByteSize (); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index ef433d33684..5b774e3a7d1 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -128,7 +128,7 @@ public: virtual size_t ParseTypes (const SymbolContext& sc) = 0; virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0; virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0; - virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) = 0; + virtual bool ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) = 0; virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { return NULL; } virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { return NULL; } virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0; diff --git a/lldb/include/lldb/Symbol/TaggedASTType.h b/lldb/include/lldb/Symbol/TaggedASTType.h index fbd18972281..c44a5356f86 100644 --- a/lldb/include/lldb/Symbol/TaggedASTType.h +++ b/lldb/include/lldb/Symbol/TaggedASTType.h @@ -20,16 +20,30 @@ namespace lldb_private template <unsigned int C> class TaggedASTType : public ClangASTType { public: + TaggedASTType (const ClangASTType &clang_type) : + ClangASTType(clang_type) + { + } + TaggedASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) : - ClangASTType(ast_context, type) { } + ClangASTType(ast_context, type) + { + } TaggedASTType (const TaggedASTType<C> &tw) : - ClangASTType(tw) { } + ClangASTType(tw) + { + } TaggedASTType () : - ClangASTType() { } + ClangASTType() + { + } - virtual ~TaggedASTType() { } + virtual + ~TaggedASTType() + { + } TaggedASTType<C> &operator= (const TaggedASTType<C> &tw) { diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index e95441b5e30..50b22fe96b9 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -16,6 +16,7 @@ #include "lldb/Core/UserID.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/Declaration.h" + #include <set> namespace lldb_private { @@ -84,7 +85,7 @@ public: lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration& decl, - lldb::clang_type_t clang_qual_type, + const ClangASTType &clang_qual_type, ResolveState clang_type_resolve_state); // This makes an invalid type. Used for functions that return a Type when they @@ -226,23 +227,20 @@ public: // Get the clang type, and resolve definitions for any // class/struct/union/enum types completely. - lldb::clang_type_t + ClangASTType GetClangFullType (); // Get the clang type, and resolve definitions enough so that the type could // have layout performed. This allows ptrs and refs to class/struct/union/enum // types remain forward declarations. - lldb::clang_type_t + ClangASTType GetClangLayoutType (); // Get the clang type and leave class/struct/union/enum types as forward // declarations if they haven't already been fully defined. - lldb::clang_type_t + ClangASTType GetClangForwardType (); - clang::ASTContext * - GetClangAST (); - ClangASTContext & GetClangASTContext (); @@ -264,21 +262,10 @@ public: uint32_t GetEncodingMask (); - - void * - CreateClangPointerType (Type *type); - - void * + + ClangASTType CreateClangTypedefType (Type *typedef_type, Type *base_type); - // For C++98 references (&) - void * - CreateClangLValueReferenceType (Type *type); - - // For C++0x references (&&) - void * - CreateClangRValueReferenceType (Type *type); - bool IsRealObjCClass(); @@ -303,7 +290,7 @@ protected: EncodingDataType m_encoding_uid_type; uint64_t m_byte_size; Declaration m_decl; - lldb::clang_type_t m_clang_type; + ClangASTType m_clang_type; struct Flags { ResolveState clang_type_resolve_state : 2; diff --git a/lldb/include/lldb/Symbol/TypeHierarchyNavigator.h b/lldb/include/lldb/Symbol/TypeHierarchyNavigator.h deleted file mode 100644 index d1657c02686..00000000000 --- a/lldb/include/lldb/Symbol/TypeHierarchyNavigator.h +++ /dev/null @@ -1,75 +0,0 @@ -//===-- TypeHierarchyNavigator.h ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_TypeHierarchyNavigator_h_ -#define lldb_TypeHierarchyNavigator_h_ - -// C Includes -// C++ Includes - -// Other libraries and framework includes -#include "clang/AST/DeclCXX.h" -#include "clang/AST/Type.h" -#include "clang/AST/DeclObjC.h" - -// Project includes -#include "lldb/lldb-public.h" -#include "lldb/lldb-enumerations.h" - -namespace lldb_private { - -class TypeHierarchyNavigator { - -public: - - enum RelationshipToCurrentType - { - eRootType, - eCXXBaseClass, - eCXXVBaseClass, - eObjCBaseClass, - eStrippedPointer, - eStrippedReference, - eStrippedTypedef - }; - - typedef bool (*TypeHierarchyNavigatorCallback)(const clang::QualType& qual_type, - RelationshipToCurrentType reason_why_here, - void* callback_baton); - - TypeHierarchyNavigator(const clang::QualType& qual_type, - ValueObject& val_obj, - void* callback_baton = NULL) : - m_root_type(qual_type), - m_value_object(val_obj), - m_default_callback_baton(callback_baton) - { - } - - bool - LoopThrough(TypeHierarchyNavigatorCallback callback, - void* callback_baton = NULL); - -private: - - bool - LoopThrough(const clang::QualType& qual_type, - TypeHierarchyNavigatorCallback callback, - RelationshipToCurrentType reason_why_here, - void* callback_baton); - - const clang::QualType& m_root_type; - ValueObject& m_value_object; - void* m_default_callback_baton; - -}; - -} // namespace lldb_private - -#endif // lldb_TypeHierarchyNavigator_h_ diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h b/lldb/include/lldb/Target/ThreadPlanStepOut.h index 9097eff26e2..918c023885a 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepOut.h +++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h @@ -63,7 +63,7 @@ private: bool m_stop_others; lldb::ThreadPlanSP m_step_through_inline_plan_sp; lldb::ThreadPlanSP m_step_out_plan_sp; - Function *m_immediate_step_from_function; + Function *m_immediate_step_from_function; lldb::ValueObjectSP m_return_valobj_sp; friend ThreadPlan * |