diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol')
22 files changed, 2126 insertions, 1840 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/Block.cpp b/contrib/llvm/tools/lldb/source/Symbol/Block.cpp index 4ab86e5..6a5c651 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Block.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Block.cpp @@ -24,7 +24,7 @@ using namespace lldb_private; Block::Block(lldb::user_id_t uid) : UserID(uid), - m_parent_scope (NULL), + m_parent_scope (nullptr), m_children (), m_ranges (), m_inlineInfoSP (), @@ -62,7 +62,7 @@ Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel leve } } - if (m_inlineInfoSP.get() != NULL) + if (m_inlineInfoSP.get() != nullptr) { bool show_fullpaths = (level == eDescriptionLevelVerbose); m_inlineInfoSP->Dump(s, show_fullpaths); @@ -83,15 +83,15 @@ Block::Dump(Stream *s, addr_t base_addr, int32_t depth, bool show_context) const } } - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<const void*>(this)); s->Indent(); - *s << "Block" << ((const UserID&)*this); + *s << "Block" << static_cast<const UserID&>(*this); const Block* parent_block = GetParent(); if (parent_block) { s->Printf(", parent = {0x%8.8" PRIx64 "}", parent_block->GetID()); } - if (m_inlineInfoSP.get() != NULL) + if (m_inlineInfoSP.get() != nullptr) { bool show_fullpaths = false; m_inlineInfoSP->Dump(s, show_fullpaths); @@ -100,12 +100,12 @@ Block::Dump(Stream *s, addr_t base_addr, int32_t depth, bool show_context) const if (!m_ranges.IsEmpty()) { *s << ", ranges ="; - + size_t num_ranges = m_ranges.GetSize(); for (size_t i=0; i<num_ranges; ++i) { const Range &range = m_ranges.GetEntryRef(i); - if (parent_block != NULL && parent_block->Contains(range) == false) + if (parent_block != nullptr && parent_block->Contains(range) == false) *s << '!'; else *s << ' '; @@ -139,7 +139,7 @@ Block::FindBlockByID (user_id_t block_id) if (block_id == GetID()) return this; - Block *matching_block = NULL; + Block *matching_block = nullptr; collection::const_iterator pos, end = m_children.end(); for (pos = m_children.begin(); pos != end; ++pos) { @@ -171,7 +171,7 @@ Block::CalculateSymbolContextCompileUnit () { if (m_parent_scope) return m_parent_scope->CalculateSymbolContextCompileUnit (); - return NULL; + return nullptr; } Function * @@ -179,7 +179,7 @@ Block::CalculateSymbolContextFunction () { if (m_parent_scope) return m_parent_scope->CalculateSymbolContextFunction (); - return NULL; + return nullptr; } Block * @@ -214,7 +214,7 @@ Block::DumpAddressRanges (Stream *s, lldb::addr_t base_addr) bool Block::Contains (addr_t range_offset) const { - return m_ranges.FindEntryThatContains(range_offset) != NULL; + return m_ranges.FindEntryThatContains(range_offset) != nullptr; } bool @@ -226,7 +226,7 @@ Block::Contains (const Block *block) const // Walk the parent chain for "block" and see if any if them match this block const Block *block_parent; for (block_parent = block->GetParent(); - block_parent != NULL; + block_parent != nullptr; block_parent = block_parent->GetParent()) { if (this == block_parent) @@ -238,7 +238,7 @@ Block::Contains (const Block *block) const bool Block::Contains (const Range& range) const { - return m_ranges.FindEntryThatContains (range) != NULL; + return m_ranges.FindEntryThatContains (range) != nullptr; } Block * @@ -246,7 +246,7 @@ Block::GetParent () const { if (m_parent_scope) return m_parent_scope->CalculateSymbolContextBlock(); - return NULL; + return nullptr; } Block * @@ -268,7 +268,7 @@ Block::GetInlinedParent () else return parent_block->GetInlinedParent(); } - return NULL; + return nullptr; } @@ -472,7 +472,7 @@ Block::GetBlockVariableList (bool can_create) { if (m_parsed_block_variables == false) { - if (m_variable_list_sp.get() == NULL && can_create) + if (m_variable_list_sp.get() == nullptr && can_create) { m_parsed_block_variables = true; SymbolContext sc; @@ -505,7 +505,7 @@ Block::AppendBlockVariables (bool can_create, { Block *child_block = pos->get(); if (stop_if_child_block_is_inlined_function == false || - child_block->GetInlinedFunctionInfo() == NULL) + child_block->GetInlinedFunctionInfo() == nullptr) { num_variables_added += child_block->AppendBlockVariables (can_create, get_child_block_variables, @@ -529,7 +529,7 @@ Block::AppendVariables uint32_t num_variables_added = 0; VariableListSP variable_list_sp(GetBlockVariableList(can_create)); - bool is_inlined_function = GetInlinedFunctionInfo() != NULL; + bool is_inlined_function = GetInlinedFunctionInfo() != nullptr; if (variable_list_sp.get()) { num_variables_added = variable_list_sp->GetSize(); @@ -556,17 +556,17 @@ Block::GetClangDeclContext() CalculateSymbolContext (&sc); if (!sc.module_sp) - return NULL; + return nullptr; SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); if (!sym_vendor) - return NULL; + return nullptr; SymbolFile *sym_file = sym_vendor->GetSymbolFile(); if (!sym_file) - return NULL; + return nullptr; return sym_file->GetClangDeclContextForTypeUID (sc, m_uid); } @@ -606,7 +606,7 @@ Block::GetSibling() const if (parent_block) return parent_block->GetSiblingForChild (this); } - return NULL; + return nullptr; } // A parent of child blocks can be asked to find a sibling block given // one of its child blocks @@ -626,6 +626,6 @@ Block::GetSiblingForChild (const Block *child_block) const } } } - return NULL; + return nullptr; } diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp index 4f30ccf..aae96bf 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp @@ -16,7 +16,7 @@ // Other libraries and framework includes // Clang headers like to use NDEBUG inside of them to enable/disable debug -// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing +// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing // or another. This is bad because it means that if clang was built in release // mode, it assumes that you are building in release mode which is not always // the case. You can end up with functions that are defined as empty in header @@ -79,6 +79,16 @@ using namespace lldb_private; using namespace llvm; using namespace clang; +typedef llvm::DenseMap<clang::ASTContext *, ClangASTContext*> ClangASTMap; + +static ClangASTMap & +GetASTMap() +{ + static ClangASTMap g_map; + return g_map; +} + + clang::AccessSpecifier ClangASTContext::ConvertAccessTypeToAccessSpecifier (AccessType access) { @@ -103,7 +113,7 @@ ParseLangArgs { // FIXME: Cleanup per-file based stuff. - // Set some properties which depend soley on the input kind; it would be nice + // Set some properties which depend solely on the input kind; it would be nice // to move these to the language standard, and have the driver resolve the // input kind + language standard. if (IK == IK_Asm) { @@ -276,9 +286,9 @@ ClangASTContext::ClangASTContext (const char *target_triple) : m_identifier_table_ap(), m_selector_table_ap(), m_builtins_ap(), - m_callback_tag_decl (NULL), - m_callback_objc_decl (NULL), - m_callback_baton (NULL), + m_callback_tag_decl (nullptr), + m_callback_objc_decl (nullptr), + m_callback_baton (nullptr), m_pointer_byte_size (0) { @@ -291,6 +301,11 @@ ClangASTContext::ClangASTContext (const char *target_triple) : //---------------------------------------------------------------------- ClangASTContext::~ClangASTContext() { + if (m_ast_ap.get()) + { + GetASTMap().erase(m_ast_ap.get()); + } + m_builtins_ap.reset(); m_selector_table_ap.reset(); m_identifier_table_ap.reset(); @@ -342,12 +357,12 @@ ClangASTContext::HasExternalSource () { ASTContext *ast = getASTContext(); if (ast) - return ast->getExternalSource () != NULL; + return ast->getExternalSource () != nullptr; return false; } void -ClangASTContext::SetExternalSource (llvm::OwningPtr<ExternalASTSource> &ast_source_ap) +ClangASTContext::SetExternalSource (llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_ap) { ASTContext *ast = getASTContext(); if (ast) @@ -365,7 +380,7 @@ ClangASTContext::RemoveExternalSource () if (ast) { - llvm::OwningPtr<ExternalASTSource> empty_ast_source_ap; + llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_ap; ast->setExternalSource (empty_ast_source_ap); ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false); //ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(false); @@ -377,15 +392,14 @@ ClangASTContext::RemoveExternalSource () ASTContext * ClangASTContext::getASTContext() { - if (m_ast_ap.get() == NULL) + if (m_ast_ap.get() == nullptr) { m_ast_ap.reset(new ASTContext (*getLanguageOptions(), *getSourceManager(), - getTargetInfo(), *getIdentifierTable(), *getSelectorTable(), - *getBuiltinContext(), - 0)); + *getBuiltinContext())); + m_ast_ap->InitBuiltinTypes(*getTargetInfo()); if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) { @@ -394,14 +408,23 @@ ClangASTContext::getASTContext() } m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false); + + GetASTMap().insert(std::make_pair(m_ast_ap.get(), this)); } return m_ast_ap.get(); } +ClangASTContext* +ClangASTContext::GetASTContext (clang::ASTContext* ast) +{ + ClangASTContext *clang_ast = GetASTMap().lookup(ast); + return clang_ast; +} + Builtin::Context * ClangASTContext::getBuiltinContext() { - if (m_builtins_ap.get() == NULL) + if (m_builtins_ap.get() == nullptr) m_builtins_ap.reset (new Builtin::Context()); return m_builtins_ap.get(); } @@ -409,15 +432,15 @@ ClangASTContext::getBuiltinContext() IdentifierTable * ClangASTContext::getIdentifierTable() { - if (m_identifier_table_ap.get() == NULL) - m_identifier_table_ap.reset(new IdentifierTable (*ClangASTContext::getLanguageOptions(), NULL)); + if (m_identifier_table_ap.get() == nullptr) + m_identifier_table_ap.reset(new IdentifierTable (*ClangASTContext::getLanguageOptions(), nullptr)); return m_identifier_table_ap.get(); } LangOptions * ClangASTContext::getLanguageOptions() { - if (m_language_options_ap.get() == NULL) + if (m_language_options_ap.get() == nullptr) { m_language_options_ap.reset(new LangOptions()); ParseLangArgs(*m_language_options_ap, IK_ObjCXX); @@ -429,7 +452,7 @@ ClangASTContext::getLanguageOptions() SelectorTable * ClangASTContext::getSelectorTable() { - if (m_selector_table_ap.get() == NULL) + if (m_selector_table_ap.get() == nullptr) m_selector_table_ap.reset (new SelectorTable()); return m_selector_table_ap.get(); } @@ -437,7 +460,7 @@ ClangASTContext::getSelectorTable() clang::FileManager * ClangASTContext::getFileManager() { - if (m_file_manager_ap.get() == NULL) + if (m_file_manager_ap.get() == nullptr) { clang::FileSystemOptions file_system_options; m_file_manager_ap.reset(new clang::FileManager(file_system_options)); @@ -448,7 +471,7 @@ ClangASTContext::getFileManager() clang::SourceManager * ClangASTContext::getSourceManager() { - if (m_source_manager_ap.get() == NULL) + if (m_source_manager_ap.get() == nullptr) m_source_manager_ap.reset(new clang::SourceManager(*getDiagnosticsEngine(), *getFileManager())); return m_source_manager_ap.get(); } @@ -456,7 +479,7 @@ ClangASTContext::getSourceManager() clang::DiagnosticsEngine * ClangASTContext::getDiagnosticsEngine() { - if (m_diagnostics_engine_ap.get() == NULL) + if (m_diagnostics_engine_ap.get() == nullptr) { llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs()); m_diagnostics_engine_ap.reset(new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions())); @@ -494,23 +517,21 @@ private: DiagnosticConsumer * ClangASTContext::getDiagnosticConsumer() { - if (m_diagnostic_consumer_ap.get() == NULL) + if (m_diagnostic_consumer_ap.get() == nullptr) m_diagnostic_consumer_ap.reset(new NullDiagnosticConsumer); return m_diagnostic_consumer_ap.get(); } -TargetOptions * -ClangASTContext::getTargetOptions() -{ - if (m_target_options_rp.getPtr() == NULL && !m_target_triple.empty()) +std::shared_ptr<TargetOptions> & +ClangASTContext::getTargetOptions() { + if (m_target_options_rp.get() == nullptr && !m_target_triple.empty()) { - m_target_options_rp.reset (); - m_target_options_rp = new TargetOptions(); - if (m_target_options_rp.getPtr() != NULL) + m_target_options_rp = std::make_shared<TargetOptions>(); + if (m_target_options_rp.get() != nullptr) m_target_options_rp->Triple = m_target_triple; } - return m_target_options_rp.getPtr(); + return m_target_options_rp; } @@ -518,7 +539,7 @@ TargetInfo * ClangASTContext::getTargetInfo() { // target_triple should be something like "x86_64-apple-macosx" - if (m_target_info_ap.get() == NULL && !m_target_triple.empty()) + if (m_target_info_ap.get() == nullptr && !m_target_triple.empty()) m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(), getTargetOptions())); return m_target_info_ap.get(); } @@ -650,7 +671,7 @@ ClangASTContext::GetBasicTypeEnumeration (const ConstString &name) g_type_map.Append(ConstString("__int128_t").GetCString(), eBasicTypeInt128); g_type_map.Append(ConstString("__uint128_t").GetCString(), eBasicTypeUnsignedInt128); - // Miscelaneous + // Miscellaneous g_type_map.Append(ConstString("bool").GetCString(), eBasicTypeBool); g_type_map.Append(ConstString("float").GetCString(), eBasicTypeFloat); g_type_map.Append(ConstString("double").GetCString(), eBasicTypeDouble); @@ -696,7 +717,7 @@ ClangASTContext::GetBasicType (ASTContext *ast, lldb::BasicType basic_type) { if (ast) { - clang_type_t clang_type = NULL; + clang_type_t clang_type = nullptr; switch (basic_type) { @@ -811,7 +832,7 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name ASTContext *ast = getASTContext(); #define streq(a,b) strcmp(a,b) == 0 - assert (ast != NULL); + assert (ast != nullptr); if (ast) { switch (dw_ate) @@ -1134,9 +1155,9 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, ClangASTMetadata *metadata) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); @@ -1160,7 +1181,7 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, decl_ctx, SourceLocation(), SourceLocation(), - is_anonymous ? NULL : &ast->Idents.get(name)); + is_anonymous ? nullptr : &ast->Idents.get(name)); if (is_anonymous) decl->setAnonymousStructOrUnion(true); @@ -1194,7 +1215,7 @@ CreateTemplateParameterList (ASTContext *ast, { const char *name = template_param_infos.names[i]; - IdentifierInfo *identifier_info = NULL; + IdentifierInfo *identifier_info = nullptr; if (name && name[0]) identifier_info = &ast->Idents.get(name); if (template_param_infos.args[i].getKind() == TemplateArgument::Integral) @@ -1208,7 +1229,7 @@ CreateTemplateParameterList (ASTContext *ast, identifier_info, template_param_infos.args[i].getIntegralType(), parameter_pack, - NULL)); + nullptr)); } else @@ -1277,7 +1298,7 @@ ClangASTContext::CreateFunctionTemplateSpecializationInfo (FunctionDecl *func_de func_decl->setFunctionTemplateSpecialization (func_tmpl_decl, &template_args, - NULL); + nullptr); } @@ -1290,8 +1311,8 @@ ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx, { ASTContext *ast = getASTContext(); - ClassTemplateDecl *class_template_decl = NULL; - if (decl_ctx == NULL) + ClassTemplateDecl *class_template_decl = nullptr; + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); IdentifierInfo &identifier_info = ast->Idents.get(class_name); @@ -1337,7 +1358,7 @@ ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx, decl_name, template_param_list, template_cxx_decl, - NULL); + nullptr); if (class_template_decl) { @@ -1373,7 +1394,7 @@ ClangASTContext::CreateClassTemplateSpecializationDecl (DeclContext *decl_ctx, class_template_decl, &template_param_infos.args.front(), template_param_infos.args.size(), - NULL); + nullptr); class_template_specialization_decl->setSpecializationKind(TSK_ExplicitSpecialization); @@ -1392,222 +1413,6 @@ ClangASTContext::CreateClassTemplateSpecializationType (ClassTemplateSpecializat return ClangASTType(); } -static bool -IsOperator (const char *name, OverloadedOperatorKind &op_kind) -{ - if (name == NULL || name[0] == '\0') - return false; - -#define OPERATOR_PREFIX "operator" -#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1) - - const char *post_op_name = NULL; - - bool no_space = true; - - if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH)) - return false; - - post_op_name = name + OPERATOR_PREFIX_LENGTH; - - if (post_op_name[0] == ' ') - { - post_op_name++; - no_space = false; - } - -#undef OPERATOR_PREFIX -#undef OPERATOR_PREFIX_LENGTH - - // This is an operator, set the overloaded operator kind to invalid - // in case this is a conversion operator... - op_kind = NUM_OVERLOADED_OPERATORS; - - switch (post_op_name[0]) - { - default: - if (no_space) - return false; - break; - case 'n': - if (no_space) - return false; - if (strcmp (post_op_name, "new") == 0) - op_kind = OO_New; - else if (strcmp (post_op_name, "new[]") == 0) - op_kind = OO_Array_New; - break; - - case 'd': - if (no_space) - return false; - if (strcmp (post_op_name, "delete") == 0) - op_kind = OO_Delete; - else if (strcmp (post_op_name, "delete[]") == 0) - op_kind = OO_Array_Delete; - break; - - case '+': - if (post_op_name[1] == '\0') - op_kind = OO_Plus; - else if (post_op_name[2] == '\0') - { - if (post_op_name[1] == '=') - op_kind = OO_PlusEqual; - else if (post_op_name[1] == '+') - op_kind = OO_PlusPlus; - } - break; - - case '-': - if (post_op_name[1] == '\0') - op_kind = OO_Minus; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_MinusEqual; break; - case '-': op_kind = OO_MinusMinus; break; - case '>': op_kind = OO_Arrow; break; - } - } - else if (post_op_name[3] == '\0') - { - if (post_op_name[2] == '*') - op_kind = OO_ArrowStar; break; - } - break; - - case '*': - if (post_op_name[1] == '\0') - op_kind = OO_Star; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_StarEqual; - break; - - case '/': - if (post_op_name[1] == '\0') - op_kind = OO_Slash; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_SlashEqual; - break; - - case '%': - if (post_op_name[1] == '\0') - op_kind = OO_Percent; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_PercentEqual; - break; - - - case '^': - if (post_op_name[1] == '\0') - op_kind = OO_Caret; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_CaretEqual; - break; - - case '&': - if (post_op_name[1] == '\0') - op_kind = OO_Amp; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_AmpEqual; break; - case '&': op_kind = OO_AmpAmp; break; - } - } - break; - - case '|': - if (post_op_name[1] == '\0') - op_kind = OO_Pipe; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_PipeEqual; break; - case '|': op_kind = OO_PipePipe; break; - } - } - break; - - case '~': - if (post_op_name[1] == '\0') - op_kind = OO_Tilde; - break; - - case '!': - if (post_op_name[1] == '\0') - op_kind = OO_Exclaim; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_ExclaimEqual; - break; - - case '=': - if (post_op_name[1] == '\0') - op_kind = OO_Equal; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_EqualEqual; - break; - - case '<': - if (post_op_name[1] == '\0') - op_kind = OO_Less; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '<': op_kind = OO_LessLess; break; - case '=': op_kind = OO_LessEqual; break; - } - } - else if (post_op_name[3] == '\0') - { - if (post_op_name[2] == '=') - op_kind = OO_LessLessEqual; - } - break; - - case '>': - if (post_op_name[1] == '\0') - op_kind = OO_Greater; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '>': op_kind = OO_GreaterGreater; break; - case '=': op_kind = OO_GreaterEqual; break; - } - } - else if (post_op_name[1] == '>' && - post_op_name[2] == '=' && - post_op_name[3] == '\0') - { - op_kind = OO_GreaterGreaterEqual; - } - break; - - case ',': - if (post_op_name[1] == '\0') - op_kind = OO_Comma; - break; - - case '(': - if (post_op_name[1] == ')' && post_op_name[2] == '\0') - op_kind = OO_Call; - break; - - case '[': - if (post_op_name[1] == ']' && post_op_name[2] == '\0') - op_kind = OO_Subscript; - break; - } - - return true; -} - static inline bool check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params) { @@ -1615,7 +1420,7 @@ check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params) if(op_kind == OO_Call) return true; - // The parameter count doens't include "this" + // The parameter count doesn't include "this" if (num_params == 0) return unary; if (num_params == 1) @@ -1686,7 +1491,7 @@ ClangASTContext::FieldIsBitfield uint32_t& bitfield_bit_size ) { - if (ast == NULL || field == NULL) + if (ast == nullptr || field == nullptr) return false; if (field->isBitField()) @@ -1708,7 +1513,7 @@ ClangASTContext::FieldIsBitfield bool ClangASTContext::RecordHasFields (const RecordDecl *record_decl) { - if (record_decl == NULL) + if (record_decl == nullptr) return false; if (!record_decl->field_empty()) @@ -1744,16 +1549,16 @@ ClangASTContext::CreateObjCClass ) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); assert (name && name[0]); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast, decl_ctx, SourceLocation(), &ast->Idents.get(name), - NULL, + nullptr, SourceLocation(), /*isForwardDecl,*/ isInternal); @@ -1804,10 +1609,10 @@ ClangASTContext::GetNumBaseClasses (const CXXRecordDecl *cxx_record_decl, bool o NamespaceDecl * ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *decl_ctx) { - NamespaceDecl *namespace_decl = NULL; + NamespaceDecl *namespace_decl = nullptr; ASTContext *ast = getASTContext(); TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl (); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = translation_unit_decl; if (name) @@ -1828,7 +1633,7 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d SourceLocation(), SourceLocation(), &identifier_info, - NULL); + nullptr); decl_ctx->addDecl (namespace_decl); } @@ -1845,8 +1650,8 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d false, SourceLocation(), SourceLocation(), - NULL, - NULL); + nullptr, + nullptr); translation_unit_decl->setAnonymousNamespace (namespace_decl); translation_unit_decl->addDecl (namespace_decl); assert (namespace_decl == translation_unit_decl->getAnonymousNamespace()); @@ -1864,8 +1669,8 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d false, SourceLocation(), SourceLocation(), - NULL, - NULL); + nullptr, + nullptr); parent_namespace_decl->setAnonymousNamespace (namespace_decl); parent_namespace_decl->addDecl (namespace_decl); assert (namespace_decl == parent_namespace_decl->getAnonymousNamespace()); @@ -1910,9 +1715,9 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, int storage, bool is_inline) { - FunctionDecl *func_decl = NULL; + FunctionDecl *func_decl = nullptr; ASTContext *ast = getASTContext(); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); @@ -1927,7 +1732,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, SourceLocation(), DeclarationName (&ast->Idents.get(name)), function_clang_type.GetQualType(), - NULL, + nullptr, (FunctionDecl::StorageClass)storage, is_inline, hasWrittenPrototype, @@ -1941,7 +1746,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, SourceLocation(), DeclarationName (), function_clang_type.GetQualType(), - NULL, + nullptr, (FunctionDecl::StorageClass)storage, is_inline, hasWrittenPrototype, @@ -1965,7 +1770,7 @@ ClangASTContext::CreateFunctionType (ASTContext *ast, bool is_variadic, unsigned type_quals) { - assert (ast != NULL); + assert (ast != nullptr); std::vector<QualType> qual_type_args; for (unsigned i=0; i<num_args; ++i) qual_type_args.push_back (args[i].GetQualType()); @@ -1973,12 +1778,10 @@ ClangASTContext::CreateFunctionType (ASTContext *ast, // TODO: Detect calling convention in DWARF? FunctionProtoType::ExtProtoInfo proto_info; proto_info.Variadic = is_variadic; - proto_info.ExceptionSpecType = EST_None; + proto_info.ExceptionSpec = EST_None; proto_info.TypeQuals = type_quals; proto_info.RefQualifier = RQ_None; - proto_info.NumExceptions = 0; - proto_info.Exceptions = NULL; - + return ClangASTType (ast, ast->getFunctionType (result_type.GetQualType(), qual_type_args, proto_info).getAsOpaquePtr()); @@ -1988,16 +1791,16 @@ ParmVarDecl * ClangASTContext::CreateParameterDeclaration (const char *name, const ClangASTType ¶m_type, int storage) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); return ParmVarDecl::Create(*ast, ast->getTranslationUnitDecl(), SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL, + name && name[0] ? &ast->Idents.get(name) : nullptr, param_type.GetQualType(), - NULL, + nullptr, (VarDecl::StorageClass)storage, - 0); + nullptr); } void @@ -2018,7 +1821,7 @@ ClangASTContext::CreateArrayType (const ClangASTType &element_type, if (element_type.IsValid()) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); if (is_vector) { @@ -2071,8 +1874,8 @@ ClangASTContext::CreateEnumerationType decl_ctx, SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL, - NULL, + name && name[0] ? &ast->Idents.get(name) : nullptr, + nullptr, false, // IsScoped false, // IsScopedUsingClassTag false); // IsFixed @@ -2131,6 +1934,63 @@ ClangASTContext::CreateEnumerationType // return false; //} +ClangASTType +ClangASTContext::GetIntTypeFromBitSize (clang::ASTContext *ast, + size_t bit_size, bool is_signed) +{ + if (ast) + { + if (is_signed) + { + if (bit_size == ast->getTypeSize(ast->SignedCharTy)) + return ClangASTType(ast, ast->SignedCharTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->ShortTy)) + return ClangASTType(ast, ast->ShortTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->IntTy)) + return ClangASTType(ast, ast->IntTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->LongTy)) + return ClangASTType(ast, ast->LongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->LongLongTy)) + return ClangASTType(ast, ast->LongLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->Int128Ty)) + return ClangASTType(ast, ast->Int128Ty.getAsOpaquePtr()); + } + else + { + if (bit_size == ast->getTypeSize(ast->UnsignedCharTy)) + return ClangASTType(ast, ast->UnsignedCharTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedShortTy)) + return ClangASTType(ast, ast->UnsignedShortTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedIntTy)) + return ClangASTType(ast, ast->UnsignedIntTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedLongTy)) + return ClangASTType(ast, ast->UnsignedLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy)) + return ClangASTType(ast, ast->UnsignedLongLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty)) + return ClangASTType(ast, ast->UnsignedInt128Ty.getAsOpaquePtr()); + } + } + return ClangASTType(); +} + +ClangASTType +ClangASTContext::GetPointerSizedIntType (clang::ASTContext *ast, bool is_signed) +{ + if (ast) + return GetIntTypeFromBitSize(ast, ast->getTypeSize(ast->VoidPtrTy), is_signed); + return ClangASTType(); +} ClangASTType ClangASTContext::GetFloatTypeFromBitSize (clang::ASTContext *ast, @@ -2223,7 +2083,7 @@ ClangASTContext::GetMetadata (clang::ASTContext *ast, if (external_source && external_source->HasMetadata(object)) return external_source->GetMetadata(object); else - return NULL; + return nullptr; } clang::DeclContext * diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTImporter.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTImporter.cpp index afdca97..6579afb 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTImporter.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTImporter.cpp @@ -106,7 +106,7 @@ ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast, return result; } - return NULL; + return nullptr; } lldb::clang_type_t @@ -117,7 +117,7 @@ ClangASTImporter::DeportType (clang::ASTContext *dst_ctx, MinionSP minion_sp (GetMinion (dst_ctx, src_ctx)); if (!minion_sp) - return NULL; + return nullptr; std::set<NamedDecl *> decls_to_deport; std::set<NamedDecl *> decls_already_deported; @@ -130,7 +130,7 @@ ClangASTImporter::DeportType (clang::ASTContext *dst_ctx, minion_sp->ExecuteDeportWorkQueues(); if (!result) - return NULL; + return nullptr; return result; @@ -142,39 +142,36 @@ ClangASTImporter::DeportDecl (clang::ASTContext *dst_ctx, clang::Decl *decl) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) log->Printf(" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from (ASTContext*)%p to (ASTContex*)%p", - decl->getDeclKindName(), - decl, - src_ctx, - dst_ctx); - + decl->getDeclKindName(), static_cast<void*>(decl), + static_cast<void*>(src_ctx), + static_cast<void*>(dst_ctx)); + MinionSP minion_sp (GetMinion (dst_ctx, src_ctx)); - + if (!minion_sp) - return NULL; - + return nullptr; + std::set<NamedDecl *> decls_to_deport; std::set<NamedDecl *> decls_already_deported; - + minion_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported); - + clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl); minion_sp->ExecuteDeportWorkQueues(); - + if (!result) - return NULL; - + return nullptr; + if (log) log->Printf(" [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p", - decl->getDeclKindName(), - decl, - result->getDeclKindName(), - result); - + decl->getDeclKindName(), static_cast<void*>(decl), + result->getDeclKindName(), static_cast<void*>(result)); + return result; } @@ -183,11 +180,10 @@ ClangASTImporter::CompleteDecl (clang::Decl *decl) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - if (log) + if (log) log->Printf(" [ClangASTImporter] CompleteDecl called on (%sDecl*)%p", - decl->getDeclKindName(), - decl); - + decl->getDeclKindName(), static_cast<void*>(decl)); + if (ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl)) { if (!interface_decl->getDefinition()) @@ -412,9 +408,10 @@ void ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) - log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", dst_ast); + log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", + static_cast<void*>(dst_ast)); m_metadata_map.erase(dst_ast); } @@ -423,17 +420,18 @@ void ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *src_ast) { ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast); - + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) - log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", src_ast, dst_ast); - + log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", + static_cast<void*>(src_ast), static_cast<void*>(dst_ast)); + if (!md) return; - + md->m_minions.erase(src_ast); - + for (OriginMap::iterator iter = md->m_origins.begin(); iter != md->m_origins.end(); ) @@ -503,8 +501,8 @@ ClangASTImporter::Minion::ExecuteDeportWorkQueues () to_context_md->m_origins.erase(decl); } - m_decls_to_deport = NULL; - m_decls_already_deported = NULL; + m_decls_to_deport = nullptr; + m_decls_already_deported = nullptr; } void @@ -572,64 +570,64 @@ clang::Decl * ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) { ClangASTMetrics::RegisterClangImport(); - + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + + lldb::user_id_t user_id = LLDB_INVALID_UID; + ClangASTMetadata *metadata = m_master.GetDeclMetadata(from); + if (metadata) + user_id = metadata->GetUserID(); + if (log) { - lldb::user_id_t user_id; - ClangASTMetadata *metadata = m_master.GetDeclMetadata(from); - if (metadata) - user_id = metadata->GetUserID(); - if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) { std::string name_string; llvm::raw_string_ostream name_stream(name_string); from_named_decl->printName(name_stream); name_stream.flush(); - + log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from (Decl*)%p), metadata 0x%" PRIx64, - from->getDeclKindName(), - to, - name_string.c_str(), - from, + from->getDeclKindName(), static_cast<void*>(to), + name_string.c_str(), static_cast<void*>(from), user_id); } else { log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p (from (Decl*)%p), metadata 0x%" PRIx64, - from->getDeclKindName(), - to, - from, - user_id); + from->getDeclKindName(), static_cast<void*>(to), + static_cast<void*>(from), user_id); } } ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext()); ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx); - + if (from_context_md) { OriginMap &origins = from_context_md->m_origins; - + OriginMap::iterator origin_iter = origins.find(from); - + if (origin_iter != origins.end()) { - to_context_md->m_origins[to] = origin_iter->second; - + if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() || + user_id != LLDB_INVALID_UID) + { + to_context_md->m_origins[to] = origin_iter->second; + } + MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx); - + if (direct_completer.get() != this) direct_completer->ASTImporter::Imported(origin_iter->second.decl, to); - + if (log) log->Printf(" [ClangASTImporter] Propagated origin (Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to (ASTContext*)%p", - origin_iter->second.decl, - origin_iter->second.ctx, - &from->getASTContext(), - &to->getASTContext()); + static_cast<void*>(origin_iter->second.decl), + static_cast<void*>(origin_iter->second.ctx), + static_cast<void*>(&from->getASTContext()), + static_cast<void*>(&to->getASTContext())); } else { @@ -638,27 +636,31 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) if (isa<TagDecl>(to) || isa<ObjCInterfaceDecl>(to)) { NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to); - + if (!m_decls_already_deported->count(to_named_decl)) m_decls_to_deport->insert(to_named_decl); } - } - to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from); + if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() || + user_id != LLDB_INVALID_UID) + { + to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from); + } + if (log) log->Printf(" [ClangASTImporter] Decl has no origin information in (ASTContext*)%p", - &from->getASTContext()); + static_cast<void*>(&from->getASTContext())); } - + if (clang::NamespaceDecl *to_namespace = dyn_cast<clang::NamespaceDecl>(to)) { clang::NamespaceDecl *from_namespace = dyn_cast<clang::NamespaceDecl>(from); - + NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps; - + NamespaceMetaMap::iterator namespace_map_iter = namespace_maps.find(from_namespace); - + if (namespace_map_iter != namespace_maps.end()) to_context_md->m_namespace_maps[to_namespace] = namespace_map_iter->second; } @@ -666,21 +668,21 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) else { to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); - + if (log) log->Printf(" [ClangASTImporter] Sourced origin (Decl*)%p/(ASTContext*)%p into (ASTContext*)%p", - from, - m_source_ctx, - &to->getASTContext()); + static_cast<void*>(from), + static_cast<void*>(m_source_ctx), + static_cast<void*>(&to->getASTContext())); } - + if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from)) { TagDecl *to_tag_decl = dyn_cast<TagDecl>(to); - + to_tag_decl->setHasExternalLexicalStorage(); to_tag_decl->setMustBuildLookupTable(); - + if (log) log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]", (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""), @@ -688,32 +690,32 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"), (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete")); } - + if (isa<NamespaceDecl>(from)) { NamespaceDecl *to_namespace_decl = dyn_cast<NamespaceDecl>(to); - + m_master.BuildNamespaceMap(to_namespace_decl); - + to_namespace_decl->setHasExternalVisibleStorage(); } - + if (isa<ObjCInterfaceDecl>(from)) { ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to); - + to_interface_decl->setHasExternalLexicalStorage(); to_interface_decl->setHasExternalVisibleStorage(); - + /*to_interface_decl->setExternallyCompleted();*/ - + if (log) log->Printf(" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes %s%s%s", (to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""), (to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""), (to_interface_decl->hasDefinition() ? " HasDefinition" : "")); } - + return clang::ASTImporter::Imported(from, to); } @@ -722,12 +724,12 @@ clang::Decl *ClangASTImporter::Minion::GetOriginalDecl (clang::Decl *To) ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&To->getASTContext()); if (!to_context_md) - return NULL; + return nullptr; OriginMap::iterator iter = to_context_md->m_origins.find(To); if (iter == to_context_md->m_origins.end()) - return NULL; + return nullptr; return const_cast<clang::Decl*>(iter->second.decl); } diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTType.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTType.cpp index 40f6462..a0878ae 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTType.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTType.cpp @@ -22,6 +22,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Type.h" +#include "clang/AST/VTableBuilder.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/IdentifierTable.h" @@ -50,11 +51,9 @@ using namespace lldb; using namespace lldb_private; -using namespace clang; -using namespace llvm; static bool -GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion = true) +GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion = true) { const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -63,7 +62,7 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion case clang::Type::IncompleteArray: case clang::Type::VariableArray: { - const ArrayType *array_type = dyn_cast<ArrayType>(qual_type.getTypePtr()); + const clang::ArrayType *array_type = llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr()); if (array_type) return GetCompleteQualType (ast, array_type->getElementType(), allow_completion); @@ -73,10 +72,10 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion case clang::Type::Record: case clang::Type::Enum: { - const TagType *tag_type = dyn_cast<TagType>(qual_type.getTypePtr()); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()); if (tag_type) { - TagDecl *tag_decl = tag_type->getDecl(); + clang::TagDecl *tag_decl = tag_type->getDecl(); if (tag_decl) { if (tag_decl->isCompleteDefinition()) @@ -89,7 +88,7 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion { if (ast) { - ExternalASTSource *external_ast_source = ast->getExternalSource(); + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); if (external_ast_source) { external_ast_source->CompleteType(tag_decl); @@ -107,10 +106,10 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion case clang::Type::ObjCObject: case clang::Type::ObjCInterface: { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); // We currently can't complete objective C types through the newly added ASTContext // because it only supports TagDecl objects right now... if (class_interface_decl) @@ -125,7 +124,7 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion { if (ast) { - ExternalASTSource *external_ast_source = ast->getExternalSource(); + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); if (external_ast_source) { external_ast_source->CompleteType (class_interface_decl); @@ -140,13 +139,13 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion break; case clang::Type::Typedef: - return GetCompleteQualType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType(), allow_completion); + return GetCompleteQualType (ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(), allow_completion); case clang::Type::Elaborated: - return GetCompleteQualType (ast, cast<ElaboratedType>(qual_type)->getNamedType(), allow_completion); + return GetCompleteQualType (ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(), allow_completion); case clang::Type::Paren: - return GetCompleteQualType (ast, cast<ParenType>(qual_type)->desugar(), allow_completion); + return GetCompleteQualType (ast, llvm::cast<clang::ParenType>(qual_type)->desugar(), allow_completion); default: break; @@ -155,18 +154,18 @@ GetCompleteQualType (ASTContext *ast, QualType qual_type, bool allow_completion return true; } -static ObjCIvarDecl::AccessControl +static clang::ObjCIvarDecl::AccessControl ConvertAccessTypeToObjCIvarAccessControl (AccessType access) { switch (access) { - case eAccessNone: return ObjCIvarDecl::None; - case eAccessPublic: return ObjCIvarDecl::Public; - case eAccessPrivate: return ObjCIvarDecl::Private; - case eAccessProtected: return ObjCIvarDecl::Protected; - case eAccessPackage: return ObjCIvarDecl::Package; + case eAccessNone: return clang::ObjCIvarDecl::None; + case eAccessPublic: return clang::ObjCIvarDecl::Public; + case eAccessPrivate: return clang::ObjCIvarDecl::Private; + case eAccessProtected: return clang::ObjCIvarDecl::Protected; + case eAccessPackage: return clang::ObjCIvarDecl::Package; } - return ObjCIvarDecl::None; + return clang::ObjCIvarDecl::None; } //---------------------------------------------------------------------- @@ -194,7 +193,7 @@ ClangASTType::IsAggregateType () const if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -209,11 +208,11 @@ ClangASTType::IsAggregateType () const case clang::Type::ObjCInterface: return true; case clang::Type::Elaborated: - return ClangASTType(m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsAggregateType(); + return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsAggregateType(); case clang::Type::Typedef: - return ClangASTType(m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsAggregateType(); + return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsAggregateType(); case clang::Type::Paren: - return ClangASTType(m_ast, cast<ParenType>(qual_type)->desugar()).IsAggregateType(); + return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsAggregateType(); default: break; } @@ -228,7 +227,7 @@ ClangASTType::IsArrayType (ClangASTType *element_type_ptr, { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -238,14 +237,14 @@ ClangASTType::IsArrayType (ClangASTType *element_type_ptr, case clang::Type::ConstantArray: if (element_type_ptr) - element_type_ptr->SetClangType (m_ast, cast<ConstantArrayType>(qual_type)->getElementType()); + element_type_ptr->SetClangType (m_ast, llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType()); if (size) - *size = cast<ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX); + *size = llvm::cast<clang::ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX); return true; case clang::Type::IncompleteArray: if (element_type_ptr) - element_type_ptr->SetClangType (m_ast, cast<IncompleteArrayType>(qual_type)->getElementType()); + element_type_ptr->SetClangType (m_ast, llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType()); if (size) *size = 0; if (is_incomplete) @@ -254,28 +253,28 @@ ClangASTType::IsArrayType (ClangASTType *element_type_ptr, case clang::Type::VariableArray: if (element_type_ptr) - element_type_ptr->SetClangType (m_ast, cast<VariableArrayType>(qual_type)->getElementType()); + element_type_ptr->SetClangType (m_ast, llvm::cast<clang::VariableArrayType>(qual_type)->getElementType()); if (size) *size = 0; return true; case clang::Type::DependentSizedArray: if (element_type_ptr) - element_type_ptr->SetClangType (m_ast, cast<DependentSizedArrayType>(qual_type)->getElementType()); + element_type_ptr->SetClangType (m_ast, llvm::cast<clang::DependentSizedArrayType>(qual_type)->getElementType()); if (size) *size = 0; return true; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsArrayType (element_type_ptr, + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsArrayType (element_type_ptr, size, is_incomplete); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsArrayType (element_type_ptr, + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsArrayType (element_type_ptr, size, is_incomplete); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsArrayType (element_type_ptr, + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsArrayType (element_type_ptr, size, is_incomplete); } @@ -352,7 +351,7 @@ ClangASTType::IsCStringType (uint32_t &length) const { // We know the size of the array and it could be a C string // since it is an array of characters - length = cast<ConstantArrayType>(GetCanonicalQualType().getTypePtr())->getSize().getLimitedValue(); + length = llvm::cast<clang::ConstantArrayType>(GetCanonicalQualType().getTypePtr())->getSize().getLimitedValue(); } return true; @@ -366,7 +365,7 @@ ClangASTType::IsFunctionType (bool *is_variadic_ptr) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); if (qual_type->isFunctionType()) { @@ -387,16 +386,16 @@ ClangASTType::IsFunctionType (bool *is_variadic_ptr) const default: break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionType(); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionType(); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsFunctionType(); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsFunctionType(); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsFunctionType(); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsFunctionType(); case clang::Type::LValueReference: case clang::Type::RValueReference: { - const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr()); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr()); if (reference_type) return ClangASTType (m_ast, reference_type->getPointeeType()).IsFunctionType(); } @@ -406,13 +405,109 @@ ClangASTType::IsFunctionType (bool *is_variadic_ptr) const return false; } +// Used to detect "Homogeneous Floating-point Aggregates" +uint32_t +ClangASTType::IsHomogeneousAggregate (ClangASTType* base_type_ptr) const +{ + if (!IsValid()) + return 0; + + clang::QualType qual_type(GetCanonicalQualType()); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Record: + if (GetCompleteType ()) + { + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + { + if (cxx_record_decl->getNumBases() || + cxx_record_decl->isDynamicClass()) + return 0; + } + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + if (record_type) + { + const clang::RecordDecl *record_decl = record_type->getDecl(); + if (record_decl) + { + // We are looking for a structure that contains only floating point types + clang::RecordDecl::field_iterator field_pos, field_end = record_decl->field_end(); + uint32_t num_fields = 0; + bool is_hva = false; + bool is_hfa = false; + clang::QualType base_qual_type; + for (field_pos = record_decl->field_begin(); field_pos != field_end; ++field_pos) + { + clang::QualType field_qual_type = field_pos->getType(); + if (field_qual_type->isFloatingType()) + { + if (field_qual_type->isComplexType()) + return 0; + else + { + if (num_fields == 0) + base_qual_type = field_qual_type; + else + { + if (is_hva) + return 0; + is_hfa = true; + if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr()) + return 0; + } + } + } + else if (field_qual_type->isVectorType() || field_qual_type->isExtVectorType()) + { + const clang::VectorType *array = llvm::cast<clang::VectorType>(field_qual_type.getTypePtr()); + if (array && array->getNumElements() <= 4) + { + if (num_fields == 0) + base_qual_type = array->getElementType(); + else + { + if (is_hfa) + return 0; + is_hva = true; + if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr()) + return 0; + } + } + else + return 0; + } + else + return 0; + ++num_fields; + } + if (base_type_ptr) + *base_type_ptr = ClangASTType (m_ast, base_qual_type); + return num_fields; + } + } + } + break; + + case clang::Type::Typedef: + return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsHomogeneousAggregate (base_type_ptr); + + case clang::Type::Elaborated: + return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsHomogeneousAggregate (base_type_ptr); + default: + break; + } + return 0; +} + size_t ClangASTType::GetNumberOfFunctionArguments () const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); - const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + clang::QualType qual_type (GetCanonicalQualType()); + const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr()); if (func) return func->getNumParams(); } @@ -424,8 +519,8 @@ ClangASTType::GetFunctionArgumentAtIndex (const size_t index) { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); - const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + clang::QualType qual_type (GetCanonicalQualType()); + const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr()); if (func) { if (index < func->getNumParams()) @@ -440,7 +535,7 @@ ClangASTType::IsFunctionPointerType () const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); if (qual_type->isFunctionPointerType()) return true; @@ -451,16 +546,16 @@ ClangASTType::IsFunctionPointerType () const default: break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionPointerType(); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionPointerType(); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsFunctionPointerType(); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsFunctionPointerType(); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsFunctionPointerType(); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsFunctionPointerType(); case clang::Type::LValueReference: case clang::Type::RValueReference: { - const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr()); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr()); if (reference_type) return ClangASTType (m_ast, reference_type->getPointeeType()).IsFunctionPointerType(); } @@ -477,8 +572,8 @@ ClangASTType::IsIntegerType (bool &is_signed) const if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); - const BuiltinType *builtin_type = dyn_cast<BuiltinType>(qual_type->getCanonicalTypeInternal()); + clang::QualType qual_type (GetCanonicalQualType()); + const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal()); if (builtin_type) { @@ -497,12 +592,12 @@ ClangASTType::IsPointerType (ClangASTType *pointee_type) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: - switch (cast<clang::BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { default: break; @@ -513,26 +608,26 @@ ClangASTType::IsPointerType (ClangASTType *pointee_type) const return false; case clang::Type::ObjCObjectPointer: if (pointee_type) - pointee_type->SetClangType (m_ast, cast<ObjCObjectPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::BlockPointer: if (pointee_type) - pointee_type->SetClangType (m_ast, cast<BlockPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType (m_ast, llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::Pointer: if (pointee_type) - pointee_type->SetClangType (m_ast, cast<PointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType (m_ast, llvm::cast<clang::PointerType>(qual_type)->getPointeeType()); return true; case clang::Type::MemberPointer: if (pointee_type) - pointee_type->SetClangType (m_ast, cast<MemberPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType (m_ast, llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerType(pointee_type); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsPointerType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPointerType(pointee_type); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsPointerType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPointerType(pointee_type); default: break; } @@ -548,12 +643,12 @@ ClangASTType::IsPointerOrReferenceType (ClangASTType *pointee_type) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: - switch (cast<clang::BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { default: break; @@ -564,34 +659,34 @@ ClangASTType::IsPointerOrReferenceType (ClangASTType *pointee_type) const return false; case clang::Type::ObjCObjectPointer: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<ObjCObjectPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::BlockPointer: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<BlockPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::Pointer: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<PointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::PointerType>(qual_type)->getPointeeType()); return true; case clang::Type::MemberPointer: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<MemberPointerType>(qual_type)->getPointeeType()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType()); return true; case clang::Type::LValueReference: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<LValueReferenceType>(qual_type)->desugar()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::LValueReferenceType>(qual_type)->desugar()); return true; case clang::Type::RValueReference: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<LValueReferenceType>(qual_type)->desugar()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::RValueReferenceType>(qual_type)->desugar()); return true; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerOrReferenceType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerOrReferenceType(pointee_type); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsPointerOrReferenceType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPointerOrReferenceType(pointee_type); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsPointerOrReferenceType(pointee_type); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPointerOrReferenceType(pointee_type); default: break; } @@ -603,29 +698,33 @@ ClangASTType::IsPointerOrReferenceType (ClangASTType *pointee_type) const bool -ClangASTType::IsReferenceType (ClangASTType *pointee_type) const +ClangASTType::IsReferenceType (ClangASTType *pointee_type, bool* is_rvalue) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::LValueReference: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<LValueReferenceType>(qual_type)->desugar()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::LValueReferenceType>(qual_type)->desugar()); + if (is_rvalue) + *is_rvalue = false; return true; case clang::Type::RValueReference: if (pointee_type) - pointee_type->SetClangType(m_ast, cast<LValueReferenceType>(qual_type)->desugar()); + pointee_type->SetClangType(m_ast, llvm::cast<clang::RValueReferenceType>(qual_type)->desugar()); + if (is_rvalue) + *is_rvalue = true; return true; case clang::Type::Typedef: - return ClangASTType(m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsReferenceType(pointee_type); + return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsReferenceType(pointee_type, is_rvalue); case clang::Type::Elaborated: - return ClangASTType(m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).IsReferenceType(pointee_type); + return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsReferenceType(pointee_type, is_rvalue); case clang::Type::Paren: - return ClangASTType(m_ast, cast<clang::ParenType>(qual_type)->desugar()).IsReferenceType(pointee_type); + return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsReferenceType(pointee_type, is_rvalue); default: break; @@ -641,19 +740,19 @@ ClangASTType::IsFloatingPointType (uint32_t &count, bool &is_complex) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); - if (const BuiltinType *BT = dyn_cast<BuiltinType>(qual_type->getCanonicalTypeInternal())) + if (const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal())) { clang::BuiltinType::Kind kind = BT->getKind(); - if (kind >= BuiltinType::Float && kind <= BuiltinType::LongDouble) + if (kind >= clang::BuiltinType::Float && kind <= clang::BuiltinType::LongDouble) { count = 1; is_complex = false; return true; } } - else if (const ComplexType *CT = dyn_cast<ComplexType>(qual_type->getCanonicalTypeInternal())) + else if (const clang::ComplexType *CT = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal())) { if (ClangASTType (m_ast, CT->getElementType()).IsFloatingPointType (count, is_complex)) { @@ -662,7 +761,7 @@ ClangASTType::IsFloatingPointType (uint32_t &count, bool &is_complex) const return true; } } - else if (const VectorType *VT = dyn_cast<VectorType>(qual_type->getCanonicalTypeInternal())) + else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal())) { if (ClangASTType (m_ast, VT->getElementType()).IsFloatingPointType (count, is_complex)) { @@ -684,23 +783,23 @@ ClangASTType::IsDefined() const if (!IsValid()) return false; - QualType qual_type(GetQualType()); - const TagType *tag_type = dyn_cast<TagType>(qual_type.getTypePtr()); + clang::QualType qual_type(GetQualType()); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()); if (tag_type) { - TagDecl *tag_decl = tag_type->getDecl(); + clang::TagDecl *tag_decl = tag_type->getDecl(); if (tag_decl) return tag_decl->isCompleteDefinition(); return false; } else { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) - return class_interface_decl->getDefinition() != NULL; + return class_interface_decl->getDefinition() != nullptr; return false; } } @@ -712,9 +811,9 @@ ClangASTType::IsObjCClassType () const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); - const ObjCObjectPointerType *obj_pointer_type = dyn_cast<ObjCObjectPointerType>(qual_type); + const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type); if (obj_pointer_type) return obj_pointer_type->isObjCClassType(); @@ -735,18 +834,18 @@ ClangASTType::IsPolymorphicClass () const { if (IsValid()) { - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); if (record_decl) { - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) return cxx_record_decl->isPolymorphic(); } @@ -765,16 +864,16 @@ ClangASTType::IsPossibleDynamicType (ClangASTType *dynamic_pointee_type, bool check_cplusplus, bool check_objc) const { - QualType pointee_qual_type; + clang::QualType pointee_qual_type; if (m_type) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); bool success = false; const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: - if (check_objc && cast<BuiltinType>(qual_type)->getKind() == BuiltinType::ObjCId) + if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() == clang::BuiltinType::ObjCId) { if (dynamic_pointee_type) dynamic_pointee_type->SetClangType(m_ast, m_type); @@ -786,37 +885,37 @@ ClangASTType::IsPossibleDynamicType (ClangASTType *dynamic_pointee_type, if (check_objc) { if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(m_ast, cast<ObjCObjectPointerType>(qual_type)->getPointeeType()); + dynamic_pointee_type->SetClangType(m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType()); return true; } break; case clang::Type::Pointer: - pointee_qual_type = cast<PointerType>(qual_type)->getPointeeType(); + pointee_qual_type = llvm::cast<clang::PointerType>(qual_type)->getPointeeType(); success = true; break; case clang::Type::LValueReference: case clang::Type::RValueReference: - pointee_qual_type = cast<ReferenceType>(qual_type)->getPointeeType(); + pointee_qual_type = llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType(); success = true; break; case clang::Type::Typedef: return ClangASTType (m_ast, - cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPossibleDynamicType (dynamic_pointee_type, + llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPossibleDynamicType (dynamic_pointee_type, check_cplusplus, check_objc); case clang::Type::Elaborated: return ClangASTType (m_ast, - cast<ElaboratedType>(qual_type)->getNamedType()).IsPossibleDynamicType (dynamic_pointee_type, + llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPossibleDynamicType (dynamic_pointee_type, check_cplusplus, check_objc); case clang::Type::Paren: return ClangASTType (m_ast, - cast<ParenType>(qual_type)->desugar()).IsPossibleDynamicType (dynamic_pointee_type, + llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPossibleDynamicType (dynamic_pointee_type, check_cplusplus, check_objc); default: @@ -832,55 +931,55 @@ ClangASTType::IsPossibleDynamicType (ClangASTType *dynamic_pointee_type, switch (pointee_type_class) { case clang::Type::Builtin: - switch (cast<BuiltinType>(pointee_qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) { - case BuiltinType::UnknownAny: - case BuiltinType::Void: + case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::Void: if (dynamic_pointee_type) dynamic_pointee_type->SetClangType(m_ast, pointee_qual_type); return true; - case BuiltinType::NullPtr: - case BuiltinType::Bool: - case BuiltinType::Char_U: - case BuiltinType::UChar: - case BuiltinType::WChar_U: - case BuiltinType::Char16: - case BuiltinType::Char32: - case BuiltinType::UShort: - case BuiltinType::UInt: - case BuiltinType::ULong: - case BuiltinType::ULongLong: - case BuiltinType::UInt128: - case BuiltinType::Char_S: - case BuiltinType::SChar: - case BuiltinType::WChar_S: - case BuiltinType::Short: - case BuiltinType::Int: - case BuiltinType::Long: - case BuiltinType::LongLong: - case BuiltinType::Int128: - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: - case BuiltinType::Dependent: - case BuiltinType::Overload: - case BuiltinType::ObjCId: - case BuiltinType::ObjCClass: - case BuiltinType::ObjCSel: - case BuiltinType::BoundMember: - case BuiltinType::Half: - case BuiltinType::ARCUnbridgedCast: - case BuiltinType::PseudoObject: - case BuiltinType::BuiltinFn: - case BuiltinType::OCLEvent: - case BuiltinType::OCLImage1d: - case BuiltinType::OCLImage1dArray: - case BuiltinType::OCLImage1dBuffer: - case BuiltinType::OCLImage2d: - case BuiltinType::OCLImage2dArray: - case BuiltinType::OCLImage3d: - case BuiltinType::OCLSampler: + case clang::BuiltinType::NullPtr: + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: + case clang::BuiltinType::Dependent: + case clang::BuiltinType::Overload: + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + case clang::BuiltinType::BoundMember: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: + case clang::BuiltinType::PseudoObject: + case clang::BuiltinType::BuiltinFn: + case clang::BuiltinType::OCLEvent: + case clang::BuiltinType::OCLImage1d: + case clang::BuiltinType::OCLImage1dArray: + case clang::BuiltinType::OCLImage1dBuffer: + case clang::BuiltinType::OCLImage2d: + case clang::BuiltinType::OCLImage2dArray: + case clang::BuiltinType::OCLImage3d: + case clang::BuiltinType::OCLSampler: break; } break; @@ -888,7 +987,7 @@ ClangASTType::IsPossibleDynamicType (ClangASTType *dynamic_pointee_type, case clang::Type::Record: if (check_cplusplus) { - CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { bool is_complete = cxx_record_decl->isCompleteDefinition(); @@ -947,7 +1046,7 @@ ClangASTType::IsScalarType () const if (!IsValid()) return false; - return (GetTypeInfo (NULL) & eTypeIsScalar) != 0; + return (GetTypeInfo (nullptr) & eTypeIsScalar) != 0; } bool @@ -979,7 +1078,7 @@ bool ClangASTType::IsArrayOfScalarType () const { ClangASTType element_type; - if (IsArrayType(&element_type, NULL, NULL)) + if (IsArrayType(&element_type, nullptr, nullptr)) return element_type.IsScalarType(); return false; } @@ -990,9 +1089,9 @@ ClangASTType::GetCXXClassName (std::string &class_name) const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); - CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { class_name.assign (cxx_record_decl->getIdentifier()->getNameStart()); @@ -1010,8 +1109,8 @@ ClangASTType::IsCXXClassType () const if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); - if (qual_type->getAsCXXRecordDecl() != NULL) + clang::QualType qual_type (GetCanonicalQualType()); + if (qual_type->getAsCXXRecordDecl() != nullptr) return true; return false; } @@ -1021,8 +1120,8 @@ ClangASTType::IsBeingDefined () const { if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); - const clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type); + clang::QualType qual_type (GetCanonicalQualType()); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type); if (tag_type) return tag_type->isBeingDefined(); return false; @@ -1034,7 +1133,7 @@ ClangASTType::IsObjCObjectPointerType (ClangASTType *class_type_ptr) if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); if (qual_type->isObjCObjectPointerType()) { @@ -1043,11 +1142,11 @@ ClangASTType::IsObjCObjectPointerType (ClangASTType *class_type_ptr) if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) { - const ObjCObjectPointerType *obj_pointer_type = dyn_cast<ObjCObjectPointerType>(qual_type); - if (obj_pointer_type == NULL) + const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type); + if (obj_pointer_type == nullptr) class_type_ptr->Clear(); else - class_type_ptr->SetClangType (m_ast, QualType(obj_pointer_type->getInterfaceType(), 0)); + class_type_ptr->SetClangType (m_ast, clang::QualType(obj_pointer_type->getInterfaceType(), 0)); } } return true; @@ -1063,12 +1162,12 @@ ClangASTType::GetObjCClassName (std::string &class_name) if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); - const ObjCObjectType *object_type = dyn_cast<ObjCObjectType>(qual_type); + const clang::ObjCObjectType *object_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type); if (object_type) { - const ObjCInterfaceDecl *interface = object_type->getInterface(); + const clang::ObjCInterfaceDecl *interface = object_type->getInterface(); if (interface) { class_name = interface->getNameAsString(); @@ -1127,14 +1226,14 @@ ClangASTType::GetTypeName () const std::string type_name; if (IsValid()) { - PrintingPolicy printing_policy (m_ast->getPrintingPolicy()); - QualType qual_type(GetQualType()); + clang::PrintingPolicy printing_policy (m_ast->getPrintingPolicy()); + clang::QualType qual_type(GetQualType()); printing_policy.SuppressTagKeyword = true; printing_policy.LangOpts.WChar = true; - const TypedefType *typedef_type = qual_type->getAs<TypedefType>(); + const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>(); if (typedef_type) { - const TypedefNameDecl *typedef_decl = typedef_type->getDecl(); + const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); type_name = typedef_decl->getQualifiedNameAsString(); } else @@ -1145,6 +1244,11 @@ ClangASTType::GetTypeName () const return ConstString(type_name); } +ConstString +ClangASTType::GetDisplayTypeName () const +{ + return GetTypeName(); +} uint32_t ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const @@ -1155,14 +1259,14 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const if (pointee_or_element_clang_type) pointee_or_element_clang_type->Clear(); - QualType qual_type (GetQualType()); + clang::QualType qual_type (GetQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: { - const BuiltinType *builtin_type = dyn_cast<BuiltinType>(qual_type->getCanonicalTypeInternal()); + const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal()); uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue; switch (builtin_type->getKind()) @@ -1226,10 +1330,10 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::Complex: { uint32_t complex_type_flags = eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex; - const ComplexType *complex_type = dyn_cast<ComplexType>(qual_type->getCanonicalTypeInternal()); + const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal()); if (complex_type) { - QualType complex_element_type (complex_type->getElementType()); + clang::QualType complex_element_type (complex_type->getElementType()); if (complex_element_type->isIntegerType()) complex_type_flags |= eTypeIsFloat; else if (complex_element_type->isFloatingType()) @@ -1244,7 +1348,7 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::IncompleteArray: case clang::Type::VariableArray: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(m_ast, cast<ArrayType>(qual_type.getTypePtr())->getElementType()); + pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::ArrayType>(qual_type.getTypePtr())->getElementType()); return eTypeHasChildren | eTypeIsArray; case clang::Type::DependentName: return 0; @@ -1254,13 +1358,13 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::Enum: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(m_ast, cast<EnumType>(qual_type)->getDecl()->getIntegerType()); + pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::EnumType>(qual_type)->getDecl()->getIntegerType()); return eTypeIsEnumeration | eTypeHasValue; case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetTypeInfo (pointee_or_element_clang_type); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeInfo (pointee_or_element_clang_type); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetTypeInfo (pointee_or_element_clang_type); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeInfo (pointee_or_element_clang_type); case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue; case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue; @@ -1269,7 +1373,7 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::LValueReference: case clang::Type::RValueReference: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(m_ast, cast<ReferenceType>(qual_type.getTypePtr())->getPointeeType()); + pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())->getPointeeType()); return eTypeHasChildren | eTypeIsReference | eTypeHasValue; case clang::Type::MemberPointer: return eTypeIsPointer | eTypeIsMember | eTypeHasValue; @@ -1298,7 +1402,7 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::TemplateSpecialization: return eTypeIsTemplate; case clang::Type::Typedef: - return eTypeIsTypedef | ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTypeInfo (pointee_or_element_clang_type); + return eTypeIsTypedef | ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTypeInfo (pointee_or_element_clang_type); case clang::Type::TypeOfExpr: return 0; case clang::Type::TypeOf: return 0; case clang::Type::UnresolvedUsing: return 0; @@ -1307,7 +1411,7 @@ ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const case clang::Type::Vector: { uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector; - const VectorType *vector_type = dyn_cast<VectorType>(qual_type->getCanonicalTypeInternal()); + const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal()); if (vector_type) { if (vector_type->isIntegerType()) @@ -1331,14 +1435,14 @@ ClangASTType::GetMinimumLanguage () return lldb::eLanguageTypeC; // If the type is a reference, then resolve it to what it refers to first: - QualType qual_type (GetCanonicalQualType().getNonReferenceType()); + clang::QualType qual_type (GetCanonicalQualType().getNonReferenceType()); if (qual_type->isAnyPointerType()) { if (qual_type->isObjCObjectPointerType()) return lldb::eLanguageTypeObjC; - QualType pointee_type (qual_type->getPointeeType()); - if (pointee_type->getPointeeCXXRecordDecl() != NULL) + clang::QualType pointee_type (qual_type->getPointeeType()); + if (pointee_type->getPointeeCXXRecordDecl() != nullptr) return lldb::eLanguageTypeC_plus_plus; if (pointee_type->isObjCObjectOrInterfaceType()) return lldb::eLanguageTypeObjC; @@ -1358,51 +1462,51 @@ ClangASTType::GetMinimumLanguage () default: break; case clang::Type::Builtin: - switch (cast<BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { default: - case BuiltinType::Void: - case BuiltinType::Bool: - case BuiltinType::Char_U: - case BuiltinType::UChar: - case BuiltinType::WChar_U: - case BuiltinType::Char16: - case BuiltinType::Char32: - case BuiltinType::UShort: - case BuiltinType::UInt: - case BuiltinType::ULong: - case BuiltinType::ULongLong: - case BuiltinType::UInt128: - case BuiltinType::Char_S: - case BuiltinType::SChar: - case BuiltinType::WChar_S: - case BuiltinType::Short: - case BuiltinType::Int: - case BuiltinType::Long: - case BuiltinType::LongLong: - case BuiltinType::Int128: - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: + case clang::BuiltinType::Void: + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: break; - case BuiltinType::NullPtr: + case clang::BuiltinType::NullPtr: return eLanguageTypeC_plus_plus; - case BuiltinType::ObjCId: - case BuiltinType::ObjCClass: - case BuiltinType::ObjCSel: + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: return eLanguageTypeObjC; - case BuiltinType::Dependent: - case BuiltinType::Overload: - case BuiltinType::BoundMember: - case BuiltinType::UnknownAny: + case clang::BuiltinType::Dependent: + case clang::BuiltinType::Overload: + case clang::BuiltinType::BoundMember: + case clang::BuiltinType::UnknownAny: break; } break; case clang::Type::Typedef: - return ClangASTType(m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetMinimumLanguage(); + return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetMinimumLanguage(); } } return lldb::eLanguageTypeC; @@ -1414,7 +1518,7 @@ ClangASTType::GetTypeClass () const if (!IsValid()) return lldb::eTypeClassInvalid; - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); switch (qual_type->getTypeClass()) { @@ -1444,8 +1548,8 @@ ClangASTType::GetTypeClass () const case clang::Type::ObjCInterface: return lldb::eTypeClassObjCInterface; case clang::Type::Record: { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); if (record_decl->isUnion()) return lldb::eTypeClassUnion; else if (record_decl->isStruct()) @@ -1458,9 +1562,9 @@ ClangASTType::GetTypeClass () const case clang::Type::Typedef: return lldb::eTypeClassTypedef; case clang::Type::UnresolvedUsing: break; case clang::Type::Paren: - return ClangASTType(m_ast, cast<ParenType>(qual_type)->desugar()).GetTypeClass(); + return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeClass(); case clang::Type::Elaborated: - return ClangASTType(m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetTypeClass(); + return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeClass(); case clang::Type::Attributed: break; case clang::Type::TemplateTypeParm: break; @@ -1480,6 +1584,7 @@ ClangASTType::GetTypeClass () const // pointer type decayed from an array or function type. case clang::Type::Decayed: break; + case clang::Type::Adjusted: break; } // We don't know hot to display this type... return lldb::eTypeClassOther; @@ -1510,7 +1615,7 @@ ClangASTType::AddConstModifier () const { if (m_type) { - QualType result(GetQualType()); + clang::QualType result(GetQualType()); result.addConst(); return ClangASTType (m_ast, result); } @@ -1522,7 +1627,7 @@ ClangASTType::AddRestrictModifier () const { if (m_type) { - QualType result(GetQualType()); + clang::QualType result(GetQualType()); result.getQualifiers().setRestrict (true); return ClangASTType (m_ast, result); } @@ -1534,7 +1639,7 @@ ClangASTType::AddVolatileModifier () const { if (m_type) { - QualType result(GetQualType()); + clang::QualType result(GetQualType()); result.getQualifiers().setVolatile (true); return ClangASTType (m_ast, result); } @@ -1542,16 +1647,22 @@ ClangASTType::AddVolatileModifier () const } ClangASTType -ClangASTType::GetArrayElementType (uint64_t& stride) const +ClangASTType::GetArrayElementType (uint64_t *stride) const { if (IsValid()) { - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); + + const clang::Type *array_elem_type = qual_type.getTypePtr()->getArrayElementTypeNoTypeQual(); + + if (!array_elem_type) + return ClangASTType(); - ClangASTType element_type (m_ast, qual_type.getTypePtr()->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified()); + ClangASTType element_type (m_ast, array_elem_type->getCanonicalTypeUnqualified()); // TODO: the real stride will be >= this value.. find the real one! - stride = element_type.GetByteSize(); + if (stride) + *stride = element_type.GetByteSize(); return element_type; @@ -1567,8 +1678,8 @@ ClangASTType::GetCanonicalType () const return ClangASTType(); } -static QualType -GetFullyUnqualifiedType_Impl (ASTContext *ast, QualType qual_type) +static clang::QualType +GetFullyUnqualifiedType_Impl (clang::ASTContext *ast, clang::QualType qual_type) { if (qual_type->isPointerType()) qual_type = ast->getPointerType(GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType())); @@ -1594,7 +1705,7 @@ ClangASTType::GetFunctionArgumentCount () const { if (IsValid()) { - const FunctionProtoType* func = dyn_cast<FunctionProtoType>(GetCanonicalQualType()); + const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType()); if (func) return func->getNumParams(); } @@ -1606,7 +1717,7 @@ ClangASTType::GetFunctionArgumentTypeAtIndex (size_t idx) { if (IsValid()) { - const FunctionProtoType* func = dyn_cast<FunctionProtoType>(GetCanonicalQualType()); + const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType()); if (func) { const uint32_t num_args = func->getNumParams(); @@ -1622,8 +1733,8 @@ ClangASTType::GetFunctionReturnType () const { if (IsValid()) { - QualType qual_type(GetCanonicalQualType()); - const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + clang::QualType qual_type(GetCanonicalQualType()); + const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr()); if (func) return ClangASTType(m_ast, func->getReturnType()); } @@ -1665,19 +1776,19 @@ ClangASTType::CreateTypedefType (const char *typedef_name, { if (IsValid() && typedef_name && typedef_name[0]) { - QualType qual_type (GetQualType()); - if (decl_ctx == NULL) + clang::QualType qual_type (GetQualType()); + if (decl_ctx == nullptr) decl_ctx = m_ast->getTranslationUnitDecl(); - TypedefDecl *decl = TypedefDecl::Create (*m_ast, - decl_ctx, - SourceLocation(), - SourceLocation(), - &m_ast->Idents.get(typedef_name), - m_ast->getTrivialTypeSourceInfo(qual_type)); + clang::TypedefDecl *decl = clang::TypedefDecl::Create (*m_ast, + decl_ctx, + clang::SourceLocation(), + clang::SourceLocation(), + &m_ast->Idents.get(typedef_name), + m_ast->getTrivialTypeSourceInfo(qual_type)); - decl->setAccess(AS_public); // TODO respect proper access specifier + decl->setAccess(clang::AS_public); // TODO respect proper access specifier - // Get a uniqued QualType for the typedef decl type + // Get a uniqued clang::QualType for the typedef decl type return ClangASTType (m_ast, m_ast->getTypedefType (decl)); } return ClangASTType(); @@ -1689,7 +1800,7 @@ ClangASTType::GetPointeeType () const { if (m_type) { - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); return ClangASTType (m_ast, qual_type.getTypePtr()->getPointeeType()); } return ClangASTType(); @@ -1700,7 +1811,7 @@ ClangASTType::GetPointerType () const { if (IsValid()) { - QualType qual_type (GetQualType()); + clang::QualType qual_type (GetQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -1721,7 +1832,7 @@ ClangASTType::GetTypedefedType () const { if (IsValid()) { - const TypedefType *typedef_type = dyn_cast<TypedefType>(GetQualType()); + const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(GetQualType()); if (typedef_type) return ClangASTType (m_ast, typedef_type->getDecl()->getUnderlyingType()); } @@ -1733,7 +1844,7 @@ ClangASTType::RemoveFastQualifiers () const { if (m_type) { - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); qual_type.getQualifiers().removeFastQualifiers(); return ClangASTType (m_ast, qual_type); } @@ -1761,7 +1872,7 @@ ClangASTType::GetBitSize () const { if (GetCompleteType ()) { - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const uint32_t bit_size = m_ast->getTypeSize (qual_type); if (bit_size == 0) { @@ -1797,7 +1908,7 @@ ClangASTType::GetEncoding (uint64_t &count) const return lldb::eEncodingInvalid; count = 1; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); switch (qual_type->getTypeClass()) { @@ -1821,42 +1932,42 @@ ClangASTType::GetEncoding (uint64_t &count) const break; case clang::Type::Builtin: - switch (cast<BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { default: assert(0 && "Unknown builtin type!"); - case BuiltinType::Void: + case clang::BuiltinType::Void: break; - case BuiltinType::Bool: - case BuiltinType::Char_S: - case BuiltinType::SChar: - case BuiltinType::WChar_S: - case BuiltinType::Char16: - case BuiltinType::Char32: - case BuiltinType::Short: - case BuiltinType::Int: - case BuiltinType::Long: - case BuiltinType::LongLong: - case BuiltinType::Int128: return lldb::eEncodingSint; + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: return lldb::eEncodingSint; - case BuiltinType::Char_U: - case BuiltinType::UChar: - case BuiltinType::WChar_U: - case BuiltinType::UShort: - case BuiltinType::UInt: - case BuiltinType::ULong: - case BuiltinType::ULongLong: - case BuiltinType::UInt128: return lldb::eEncodingUint; + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: return lldb::eEncodingUint; - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: return lldb::eEncodingIEEE754; + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754; - case BuiltinType::ObjCClass: - case BuiltinType::ObjCId: - case BuiltinType::ObjCSel: return lldb::eEncodingUint; + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCSel: return lldb::eEncodingUint; - case BuiltinType::NullPtr: return lldb::eEncodingUint; + case clang::BuiltinType::NullPtr: return lldb::eEncodingUint; } break; // All pointer types are represented as unsigned integer encodings. @@ -1875,7 +1986,7 @@ ClangASTType::GetEncoding (uint64_t &count) const encoding = lldb::eEncodingIEEE754; else { - const ComplexType *complex_type = qual_type->getAsComplexIntegerType(); + const clang::ComplexType *complex_type = qual_type->getAsComplexIntegerType(); if (complex_type) encoding = ClangASTType(m_ast, complex_type->getElementType()).GetEncoding(count); else @@ -1889,13 +2000,13 @@ ClangASTType::GetEncoding (uint64_t &count) const case clang::Type::Record: break; case clang::Type::Enum: return lldb::eEncodingSint; case clang::Type::Typedef: - return ClangASTType(m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetEncoding(count); + return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetEncoding(count); case clang::Type::Elaborated: - return ClangASTType(m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetEncoding(count); + return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetEncoding(count); case clang::Type::Paren: - return ClangASTType(m_ast, cast<ParenType>(qual_type)->desugar()).GetEncoding(count); + return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: @@ -1916,6 +2027,7 @@ ClangASTType::GetEncoding (uint64_t &count) const case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::Atomic: + case clang::Type::Adjusted: break; // pointer type decayed from an array or function type. @@ -1932,7 +2044,7 @@ ClangASTType::GetFormat () const if (!IsValid()) return lldb::eFormatDefault; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); switch (qual_type->getTypeClass()) { @@ -1955,54 +2067,54 @@ ClangASTType::GetFormat () const break; case clang::Type::Builtin: - switch (cast<BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { //default: assert(0 && "Unknown builtin type!"); - case BuiltinType::UnknownAny: - case BuiltinType::Void: - case BuiltinType::BoundMember: + case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::Void: + case clang::BuiltinType::BoundMember: break; - case BuiltinType::Bool: return lldb::eFormatBoolean; - case BuiltinType::Char_S: - case BuiltinType::SChar: - case BuiltinType::WChar_S: - case BuiltinType::Char_U: - case BuiltinType::UChar: - case BuiltinType::WChar_U: return lldb::eFormatChar; - case BuiltinType::Char16: return lldb::eFormatUnicode16; - case BuiltinType::Char32: return lldb::eFormatUnicode32; - case BuiltinType::UShort: return lldb::eFormatUnsigned; - case BuiltinType::Short: return lldb::eFormatDecimal; - case BuiltinType::UInt: return lldb::eFormatUnsigned; - case BuiltinType::Int: return lldb::eFormatDecimal; - case BuiltinType::ULong: return lldb::eFormatUnsigned; - case BuiltinType::Long: return lldb::eFormatDecimal; - case BuiltinType::ULongLong: return lldb::eFormatUnsigned; - case BuiltinType::LongLong: return lldb::eFormatDecimal; - case BuiltinType::UInt128: return lldb::eFormatUnsigned; - case BuiltinType::Int128: return lldb::eFormatDecimal; - case BuiltinType::Float: return lldb::eFormatFloat; - case BuiltinType::Double: return lldb::eFormatFloat; - case BuiltinType::LongDouble: return lldb::eFormatFloat; - case BuiltinType::NullPtr: - case BuiltinType::Overload: - case BuiltinType::Dependent: - case BuiltinType::ObjCId: - case BuiltinType::ObjCClass: - case BuiltinType::ObjCSel: - case BuiltinType::Half: - case BuiltinType::ARCUnbridgedCast: - case BuiltinType::PseudoObject: - case BuiltinType::BuiltinFn: - case BuiltinType::OCLEvent: - case BuiltinType::OCLImage1d: - case BuiltinType::OCLImage1dArray: - case BuiltinType::OCLImage1dBuffer: - case BuiltinType::OCLImage2d: - case BuiltinType::OCLImage2dArray: - case BuiltinType::OCLImage3d: - case BuiltinType::OCLSampler: + case clang::BuiltinType::Bool: return lldb::eFormatBoolean; + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: return lldb::eFormatChar; + case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; + case clang::BuiltinType::Char32: return lldb::eFormatUnicode32; + case clang::BuiltinType::UShort: return lldb::eFormatUnsigned; + case clang::BuiltinType::Short: return lldb::eFormatDecimal; + case clang::BuiltinType::UInt: return lldb::eFormatUnsigned; + case clang::BuiltinType::Int: return lldb::eFormatDecimal; + case clang::BuiltinType::ULong: return lldb::eFormatUnsigned; + case clang::BuiltinType::Long: return lldb::eFormatDecimal; + case clang::BuiltinType::ULongLong: return lldb::eFormatUnsigned; + case clang::BuiltinType::LongLong: return lldb::eFormatDecimal; + case clang::BuiltinType::UInt128: return lldb::eFormatUnsigned; + case clang::BuiltinType::Int128: return lldb::eFormatDecimal; + case clang::BuiltinType::Float: return lldb::eFormatFloat; + case clang::BuiltinType::Double: return lldb::eFormatFloat; + case clang::BuiltinType::LongDouble: return lldb::eFormatFloat; + case clang::BuiltinType::NullPtr: + case clang::BuiltinType::Overload: + case clang::BuiltinType::Dependent: + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: + case clang::BuiltinType::PseudoObject: + case clang::BuiltinType::BuiltinFn: + case clang::BuiltinType::OCLEvent: + case clang::BuiltinType::OCLImage1d: + case clang::BuiltinType::OCLImage1dArray: + case clang::BuiltinType::OCLImage1dBuffer: + case clang::BuiltinType::OCLImage2d: + case clang::BuiltinType::OCLImage2dArray: + case clang::BuiltinType::OCLImage3d: + case clang::BuiltinType::OCLSampler: return lldb::eFormatHex; } break; @@ -2023,13 +2135,13 @@ ClangASTType::GetFormat () const case clang::Type::Record: break; case clang::Type::Enum: return lldb::eFormatEnum; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetFormat(); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetFormat(); case clang::Type::Auto: - return ClangASTType (m_ast, cast<AutoType>(qual_type)->desugar()).GetFormat(); + return ClangASTType (m_ast, llvm::cast<clang::AutoType>(qual_type)->desugar()).GetFormat(); case clang::Type::Paren: - return ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).GetFormat(); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetFormat(); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetFormat(); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -2048,6 +2160,7 @@ ClangASTType::GetFormat () const case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::Atomic: + case clang::Type::Adjusted: break; // pointer type decayed from an array or function type. @@ -2059,7 +2172,7 @@ ClangASTType::GetFormat () const } static bool -ObjCDeclHasIVars (ObjCInterfaceDecl *class_interface_decl, bool check_superclass) +ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, bool check_superclass) { while (class_interface_decl) { @@ -2081,15 +2194,15 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const return 0; uint32_t num_children = 0; - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: - switch (cast<BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { - case BuiltinType::ObjCId: // child is Class - case BuiltinType::ObjCClass: // child is Class + case clang::BuiltinType::ObjCId: // child is Class + case clang::BuiltinType::ObjCClass: // child is Class num_children = 1; break; @@ -2103,10 +2216,10 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::Record: if (GetCompleteQualType (m_ast, qual_type)) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) { if (omit_empty_base_classes) @@ -2115,12 +2228,12 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const // base classes contain any fields. This can help // limit the noise in variable views by not having to // show base classes that contain no members. - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class) { - const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); // Skip empty base classes if (ClangASTContext::RecordHasFields(base_class_decl) == false) @@ -2136,7 +2249,7 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const } } - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field) ++num_children; } @@ -2146,16 +2259,16 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::ObjCInterface: if (GetCompleteQualType (m_ast, qual_type)) { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); if (superclass_interface_decl) { if (omit_empty_base_classes) @@ -2175,8 +2288,8 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::ObjCObjectPointer: { - const ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(qual_type.getTypePtr()); - QualType pointee_type = pointer_type->getPointeeType(); + const clang::ObjCObjectPointerType *pointer_type = llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr()); + clang::QualType pointee_type = pointer_type->getPointeeType(); uint32_t num_pointee_children = ClangASTType (m_ast,pointee_type).GetNumChildren (omit_empty_base_classes); // If this type points to a simple type, then it has 1 child if (num_pointee_children == 0) @@ -2188,17 +2301,17 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::Vector: case clang::Type::ExtVector: - num_children = cast<VectorType>(qual_type.getTypePtr())->getNumElements(); + num_children = llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements(); break; case clang::Type::ConstantArray: - num_children = cast<ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue(); + num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue(); break; case clang::Type::Pointer: { - const PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr()); - QualType pointee_type (pointer_type->getPointeeType()); + const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr()); + clang::QualType pointee_type (pointer_type->getPointeeType()); uint32_t num_pointee_children = ClangASTType (m_ast,pointee_type).GetNumChildren (omit_empty_base_classes); if (num_pointee_children == 0) { @@ -2214,8 +2327,8 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::LValueReference: case clang::Type::RValueReference: { - const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr()); - QualType pointee_type = reference_type->getPointeeType(); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr()); + clang::QualType pointee_type = reference_type->getPointeeType(); uint32_t num_pointee_children = ClangASTType (m_ast, pointee_type).GetNumChildren (omit_empty_base_classes); // If this type points to a simple type, then it has 1 child if (num_pointee_children == 0) @@ -2227,15 +2340,15 @@ ClangASTType::GetNumChildren (bool omit_empty_base_classes) const case clang::Type::Typedef: - num_children = ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumChildren (omit_empty_base_classes); + num_children = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumChildren (omit_empty_base_classes); break; case clang::Type::Elaborated: - num_children = ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumChildren (omit_empty_base_classes); + num_children = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumChildren (omit_empty_base_classes); break; case clang::Type::Paren: - num_children = ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).GetNumChildren (omit_empty_base_classes); + num_children = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumChildren (omit_empty_base_classes); break; default: break; @@ -2248,11 +2361,11 @@ ClangASTType::GetBasicTypeEnumeration () const { if (IsValid()) { - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); if (type_class == clang::Type::Builtin) { - switch (cast<clang::BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { case clang::BuiltinType::Void: return eBasicTypeVoid; case clang::BuiltinType::Bool: return eBasicTypeBool; @@ -2316,14 +2429,14 @@ ClangASTType::GetNumDirectBaseClasses () const return 0; uint32_t count = 0; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) count = cxx_record_decl->getNumBases(); } @@ -2336,10 +2449,10 @@ ClangASTType::GetNumDirectBaseClasses () const case clang::Type::ObjCObject: if (GetCompleteType()) { - const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); + const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl && class_interface_decl->getSuperClass()) count = 1; @@ -2349,10 +2462,10 @@ ClangASTType::GetNumDirectBaseClasses () const case clang::Type::ObjCInterface: if (GetCompleteType()) { - const ObjCInterfaceType *objc_interface_type = qual_type->getAs<ObjCInterfaceType>(); + const clang::ObjCInterfaceType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>(); if (objc_interface_type) { - ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); if (class_interface_decl && class_interface_decl->getSuperClass()) count = 1; @@ -2362,15 +2475,15 @@ ClangASTType::GetNumDirectBaseClasses () const case clang::Type::Typedef: - count = ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumDirectBaseClasses (); + count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumDirectBaseClasses (); break; case clang::Type::Elaborated: - count = ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumDirectBaseClasses (); + count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumDirectBaseClasses (); break; case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetNumDirectBaseClasses (); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumDirectBaseClasses (); default: break; @@ -2385,29 +2498,29 @@ ClangASTType::GetNumVirtualBaseClasses () const return 0; uint32_t count = 0; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) count = cxx_record_decl->getNumVBases(); } break; case clang::Type::Typedef: - count = ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumVirtualBaseClasses(); + count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumVirtualBaseClasses(); break; case clang::Type::Elaborated: - count = ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumVirtualBaseClasses(); + count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumVirtualBaseClasses(); break; case clang::Type::Paren: - count = ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetNumVirtualBaseClasses(); + count = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumVirtualBaseClasses(); break; default: @@ -2423,21 +2536,21 @@ ClangASTType::GetNumFields () const return 0; uint32_t count = 0; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const RecordType *record_type = dyn_cast<RecordType>(qual_type.getTypePtr()); + const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr()); if (record_type) { - RecordDecl *record_decl = record_type->getDecl(); + clang::RecordDecl *record_decl = record_type->getDecl(); if (record_decl) { uint32_t field_idx = 0; - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field) ++field_idx; count = field_idx; @@ -2447,24 +2560,24 @@ ClangASTType::GetNumFields () const break; case clang::Type::Typedef: - count = ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumFields(); + count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumFields(); break; case clang::Type::Elaborated: - count = ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumFields(); + count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumFields(); break; case clang::Type::Paren: - count = ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetNumFields(); + count = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumFields(); break; case clang::Type::ObjCObjectPointer: if (GetCompleteType()) { - const ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType(); + const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType(); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl(); if (class_interface_decl) count = class_interface_decl->ivar_size(); @@ -2476,10 +2589,10 @@ ClangASTType::GetNumFields () const case clang::Type::ObjCInterface: if (GetCompleteType()) { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) count = class_interface_decl->ivar_size(); @@ -2499,18 +2612,18 @@ ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) c if (!IsValid()) return ClangASTType(); - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { uint32_t curr_idx = 0; - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class, ++curr_idx) @@ -2519,8 +2632,8 @@ ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) c { if (bit_offset_ptr) { - const ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl); - const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl); + const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); if (base_class->isVirtual()) *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; else @@ -2539,14 +2652,14 @@ ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) c case clang::Type::ObjCObject: if (idx == 0 && GetCompleteType()) { - const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); + const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); if (superclass_interface_decl) { if (bit_offset_ptr) @@ -2560,14 +2673,14 @@ ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) c case clang::Type::ObjCInterface: if (idx == 0 && GetCompleteType()) { - const ObjCObjectType *objc_interface_type = qual_type->getAs<ObjCInterfaceType>(); + const clang::ObjCObjectType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>(); if (objc_interface_type) { - ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); if (class_interface_decl) { - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); if (superclass_interface_decl) { if (bit_offset_ptr) @@ -2581,13 +2694,13 @@ ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) c case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr); default: break; @@ -2601,18 +2714,18 @@ ClangASTType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) if (!IsValid()) return ClangASTType(); - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { uint32_t curr_idx = 0; - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->vbases_begin(), base_class_end = cxx_record_decl->vbases_end(); base_class != base_class_end; ++base_class, ++curr_idx) @@ -2621,8 +2734,8 @@ ClangASTType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) { if (bit_offset_ptr) { - const ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl); - const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl); + const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; } @@ -2634,13 +2747,13 @@ ClangASTType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr); default: break; @@ -2650,7 +2763,7 @@ ClangASTType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) static clang_type_t GetObjCFieldAtIndex (clang::ASTContext *ast, - ObjCInterfaceDecl *class_interface_decl, + clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string& name, uint64_t *bit_offset_ptr, @@ -2661,22 +2774,22 @@ GetObjCFieldAtIndex (clang::ASTContext *ast, { if (idx < (class_interface_decl->ivar_size())) { - ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); + clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); uint32_t ivar_idx = 0; for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++ivar_idx) { if (ivar_idx == idx) { - const ObjCIvarDecl* ivar_decl = *ivar_pos; + const clang::ObjCIvarDecl* ivar_decl = *ivar_pos; - QualType ivar_qual_type(ivar_decl->getType()); + clang::QualType ivar_qual_type(ivar_decl->getType()); name.assign(ivar_decl->getNameAsString()); if (bit_offset_ptr) { - const ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl); + const clang::ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl); *bit_offset_ptr = interface_layout.getFieldOffset (ivar_idx); } @@ -2688,7 +2801,7 @@ GetObjCFieldAtIndex (clang::ASTContext *ast, if (is_bitfield && ast) { - Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth(); + clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth(); llvm::APSInt bitfield_apsint; if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *ast)) { @@ -2704,7 +2817,7 @@ GetObjCFieldAtIndex (clang::ASTContext *ast, } } } - return NULL; + return nullptr; } ClangASTType @@ -2717,17 +2830,17 @@ ClangASTType::GetFieldAtIndex (size_t idx, if (!IsValid()) return ClangASTType(); - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType()) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); uint32_t field_idx = 0; - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx) { if (idx == field_idx) @@ -2740,7 +2853,7 @@ ClangASTType::GetFieldAtIndex (size_t idx, // alignment (field_type_info.second) from the AST context. if (bit_offset_ptr) { - const ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); + const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); *bit_offset_ptr = record_layout.getFieldOffset (field_idx); } @@ -2752,7 +2865,7 @@ ClangASTType::GetFieldAtIndex (size_t idx, if (is_bitfield) { - Expr *bitfield_bit_size_expr = field->getBitWidth(); + clang::Expr *bitfield_bit_size_expr = field->getBitWidth(); llvm::APSInt bitfield_apsint; if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *m_ast)) { @@ -2772,10 +2885,10 @@ ClangASTType::GetFieldAtIndex (size_t idx, case clang::Type::ObjCObjectPointer: if (GetCompleteType()) { - const ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType(); + const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType(); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl(); return ClangASTType (m_ast, GetObjCFieldAtIndex(m_ast, class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr)); } } @@ -2785,11 +2898,11 @@ ClangASTType::GetFieldAtIndex (size_t idx, case clang::Type::ObjCInterface: if (GetCompleteType()) { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); return ClangASTType (m_ast, GetObjCFieldAtIndex(m_ast, class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr)); } } @@ -2797,7 +2910,7 @@ ClangASTType::GetFieldAtIndex (size_t idx, case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()). + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()). GetFieldAtIndex (idx, name, bit_offset_ptr, @@ -2805,7 +2918,7 @@ ClangASTType::GetFieldAtIndex (size_t idx, is_bitfield_ptr); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()). + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()). GetFieldAtIndex (idx, name, bit_offset_ptr, @@ -2813,7 +2926,7 @@ ClangASTType::GetFieldAtIndex (size_t idx, is_bitfield_ptr); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()). + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()). GetFieldAtIndex (idx, name, bit_offset_ptr, @@ -2859,12 +2972,12 @@ ClangASTType::GetNumPointeeChildren () const if (!IsValid()) return 0; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: - switch (cast<clang::BuiltinType>(qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { case clang::BuiltinType::UnknownAny: case clang::BuiltinType::Void: @@ -2930,9 +3043,9 @@ ClangASTType::GetNumPointeeChildren () const case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children... case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children... case clang::Type::UnresolvedUsing: return 0; - case clang::Type::Paren: return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetNumPointeeChildren (); - case clang::Type::Typedef: return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumPointeeChildren (); - case clang::Type::Elaborated: return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumPointeeChildren (); + case clang::Type::Paren: return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumPointeeChildren (); + case clang::Type::Typedef: return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumPointeeChildren (); + case clang::Type::Elaborated: return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumPointeeChildren (); case clang::Type::TypeOfExpr: return 0; case clang::Type::TypeOf: return 0; case clang::Type::Decltype: return 0; @@ -2956,7 +3069,6 @@ ClangASTType::GetNumPointeeChildren () const ClangASTType ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, - const char *parent_name, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -2967,12 +3079,13 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, - bool &child_is_deref_of_parent) const + bool &child_is_deref_of_parent, + ValueObject *valobj) const { if (!IsValid()) return ClangASTType(); - QualType parent_qual_type(GetCanonicalQualType()); + clang::QualType parent_qual_type(GetCanonicalQualType()); const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass(); child_bitfield_bit_size = 0; child_bitfield_bit_offset = 0; @@ -2985,7 +3098,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::Builtin: if (idx_is_valid) { - switch (cast<clang::BuiltinType>(parent_qual_type)->getKind()) + switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) { case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCClass: @@ -3002,39 +3115,106 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::Record: if (idx_is_valid && GetCompleteType()) { - const RecordType *record_type = cast<RecordType>(parent_qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); - const ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); + const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); uint32_t child_idx = 0; - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) { // We might have base classes to print out first - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class) { - const CXXRecordDecl *base_class_decl = NULL; + const clang::CXXRecordDecl *base_class_decl = nullptr; // Skip empty base classes if (omit_empty_base_classes) { - base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); if (ClangASTContext::RecordHasFields(base_class_decl) == false) continue; } if (idx == child_idx) { - if (base_class_decl == NULL) - base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + if (base_class_decl == nullptr) + base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); if (base_class->isVirtual()) - bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; + { + bool handled = false; + if (valobj) + { + Error err; + AddressType addr_type = eAddressTypeInvalid; + lldb::addr_t vtable_ptr_addr = valobj->GetCPPVTableAddress(addr_type); + + if (vtable_ptr_addr != LLDB_INVALID_ADDRESS && addr_type == eAddressTypeLoad) + { + + ExecutionContext exe_ctx (valobj->GetExecutionContextRef()); + Process *process = exe_ctx.GetProcessPtr(); + if (process) + { + clang::VTableContextBase *vtable_ctx = m_ast->getVTableContext(); + if (vtable_ctx) + { + if (vtable_ctx->isMicrosoft()) + { + clang::MicrosoftVTableContext *msoft_vtable_ctx = static_cast<clang::MicrosoftVTableContext *>(vtable_ctx); + + if (vtable_ptr_addr) + { + const lldb::addr_t vbtable_ptr_addr = vtable_ptr_addr + record_layout.getVBPtrOffset().getQuantity(); + + const lldb::addr_t vbtable_ptr = process->ReadPointerFromMemory(vbtable_ptr_addr, err); + if (vbtable_ptr != LLDB_INVALID_ADDRESS) + { + // Get the index into the virtual base table. The index is the index in uint32_t from vbtable_ptr + const unsigned vbtable_index = msoft_vtable_ctx->getVBTableIndex(cxx_record_decl, base_class_decl); + const lldb::addr_t base_offset_addr = vbtable_ptr + vbtable_index * 4; + const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err); + if (base_offset != UINT32_MAX) + { + handled = true; + bit_offset = base_offset * 8; + } + } + } + } + else + { + clang::ItaniumVTableContext *itanium_vtable_ctx = static_cast<clang::ItaniumVTableContext *>(vtable_ctx); + if (vtable_ptr_addr) + { + const lldb::addr_t vtable_ptr = process->ReadPointerFromMemory(vtable_ptr_addr, err); + if (vtable_ptr != LLDB_INVALID_ADDRESS) + { + clang::CharUnits base_offset_offset = itanium_vtable_ctx->getVirtualBaseOffsetOffset(cxx_record_decl, base_class_decl); + const lldb::addr_t base_offset_addr = vtable_ptr + base_offset_offset.getQuantity(); + const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err); + if (base_offset != UINT32_MAX) + { + handled = true; + bit_offset = base_offset * 8; + } + } + } + } + } + } + } + + } + if (!handled) + bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; + } else bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8; @@ -3057,7 +3237,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, } // Make sure index is in range... uint32_t field_idx = 0; - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx) { if (idx == child_idx) @@ -3088,18 +3268,18 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::ObjCInterface: if (idx_is_valid && GetCompleteType()) { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(parent_qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { uint32_t child_idx = 0; - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - const ASTRecordLayout &interface_layout = m_ast->getASTObjCInterfaceLayout(class_interface_decl); - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + const clang::ASTRecordLayout &interface_layout = m_ast->getASTObjCInterfaceLayout(class_interface_decl); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); if (superclass_interface_decl) { if (omit_empty_base_classes) @@ -3109,14 +3289,14 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, { if (idx == 0) { - QualType ivar_qual_type(m_ast->getObjCInterfaceType(superclass_interface_decl)); + clang::QualType ivar_qual_type(m_ast->getObjCInterfaceType(superclass_interface_decl)); child_name.assign(superclass_interface_decl->getNameAsString().c_str()); - std::pair<uint64_t, unsigned> ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr()); + clang::TypeInfo ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr()); - child_byte_size = ivar_type_info.first / 8; + child_byte_size = ivar_type_info.Width / 8; child_byte_offset = 0; child_is_base_class = true; @@ -3134,21 +3314,21 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, if (idx < (child_idx + class_interface_decl->ivar_size())) { - ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); + clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos) { if (child_idx == idx) { - ObjCIvarDecl* ivar_decl = *ivar_pos; + clang::ObjCIvarDecl* ivar_decl = *ivar_pos; - QualType ivar_qual_type(ivar_decl->getType()); + clang::QualType ivar_qual_type(ivar_decl->getType()); child_name.assign(ivar_decl->getNameAsString().c_str()); - std::pair<uint64_t, unsigned> ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr()); + clang::TypeInfo ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr()); - child_byte_size = ivar_type_info.first / 8; + child_byte_size = ivar_type_info.Width / 8; // Figure out the field offset within the current struct/union/class type // For ObjC objects, we can't trust the bit offset we get from the Clang AST, since @@ -3156,13 +3336,13 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // the changing size of base classes that are newer than this class. // So if we have a process around that we can ask about this object, do so. child_byte_offset = LLDB_INVALID_IVAR_OFFSET; - Process *process = NULL; + Process *process = nullptr; if (exe_ctx) process = exe_ctx->GetProcessPtr(); if (process) { ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime(); - if (objc_runtime != NULL) + if (objc_runtime != nullptr) { ClangASTType parent_ast_type (m_ast, parent_qual_type); child_byte_offset = objc_runtime->GetByteOffsetForIvar (parent_ast_type, ivar_decl->getNameAsString().c_str()); @@ -3172,7 +3352,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // Setting this to UINT32_MAX to make sure we don't compute it twice... bit_offset = UINT32_MAX; - if (child_byte_offset == LLDB_INVALID_IVAR_OFFSET) + if (child_byte_offset == static_cast<int32_t>(LLDB_INVALID_IVAR_OFFSET)) { bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx); child_byte_offset = bit_offset / 8; @@ -3209,7 +3389,6 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_is_deref_of_parent = false; bool tmp_child_is_deref_of_parent = false; return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3220,11 +3399,13 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - tmp_child_is_deref_of_parent); + tmp_child_is_deref_of_parent, + valobj); } else { child_is_deref_of_parent = true; + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; if (parent_name) { child_name.assign(1, '*'); @@ -3246,7 +3427,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::ExtVector: if (idx_is_valid) { - const VectorType *array = cast<VectorType>(parent_qual_type.getTypePtr()); + const clang::VectorType *array = llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr()); if (array) { ClangASTType element_type (m_ast, array->getElementType()); @@ -3267,7 +3448,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::IncompleteArray: if (ignore_array_bounds || idx_is_valid) { - const ArrayType *array = cast<ArrayType>(parent_qual_type.getTypePtr()); + const clang::ArrayType *array = llvm::cast<clang::ArrayType>(parent_qual_type.getTypePtr()); if (array) { ClangASTType element_type (m_ast, array->getElementType()); @@ -3299,7 +3480,6 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_is_deref_of_parent = false; bool tmp_child_is_deref_of_parent = false; return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3310,12 +3490,14 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - tmp_child_is_deref_of_parent); + tmp_child_is_deref_of_parent, + valobj); } else { child_is_deref_of_parent = true; + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; if (parent_name) { child_name.assign(1, '*'); @@ -3337,14 +3519,13 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::RValueReference: if (idx_is_valid) { - const ReferenceType *reference_type = cast<ReferenceType>(parent_qual_type.getTypePtr()); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(parent_qual_type.getTypePtr()); ClangASTType pointee_clang_type (m_ast, reference_type->getPointeeType()); if (transparent_pointers && pointee_clang_type.IsAggregateType ()) { child_is_deref_of_parent = false; bool tmp_child_is_deref_of_parent = false; return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3355,10 +3536,12 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - tmp_child_is_deref_of_parent); + tmp_child_is_deref_of_parent, + valobj); } else { + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; if (parent_name) { child_name.assign(1, '&'); @@ -3378,9 +3561,8 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, case clang::Type::Typedef: { - ClangASTType typedefed_clang_type (m_ast, cast<TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType()); + ClangASTType typedefed_clang_type (m_ast, llvm::cast<clang::TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType()); return typedefed_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3391,15 +3573,15 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - child_is_deref_of_parent); + child_is_deref_of_parent, + valobj); } break; case clang::Type::Elaborated: { - ClangASTType elaborated_clang_type (m_ast, cast<ElaboratedType>(parent_qual_type)->getNamedType()); + ClangASTType elaborated_clang_type (m_ast, llvm::cast<clang::ElaboratedType>(parent_qual_type)->getNamedType()); return elaborated_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3410,14 +3592,14 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - child_is_deref_of_parent); + child_is_deref_of_parent, + valobj); } case clang::Type::Paren: { ClangASTType paren_clang_type (m_ast, llvm::cast<clang::ParenType>(parent_qual_type)->desugar()); return paren_clang_type.GetChildClangTypeAtIndex (exe_ctx, - parent_name, idx, transparent_pointers, omit_empty_base_classes, @@ -3428,7 +3610,8 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - child_is_deref_of_parent); + child_is_deref_of_parent, + valobj); } @@ -3439,7 +3622,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, } static inline bool -BaseSpecifierIsEmpty (const CXXBaseSpecifier *b) +BaseSpecifierIsEmpty (const clang::CXXBaseSpecifier *b) { return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) == false; } @@ -3447,22 +3630,22 @@ BaseSpecifierIsEmpty (const CXXBaseSpecifier *b) static uint32_t GetIndexForRecordBase ( - const RecordDecl *record_decl, - const CXXBaseSpecifier *base_spec, + const clang::RecordDecl *record_decl, + const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes ) { uint32_t child_idx = 0; - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); // const char *super_name = record_decl->getNameAsCString(); - // const char *base_name = base_spec->getType()->getAs<RecordType>()->getDecl()->getNameAsCString(); + // const char *base_name = base_spec->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString(); // printf ("GetIndexForRecordChild (%s, %s)\n", super_name, base_name); // if (cxx_record_decl) { - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class) @@ -3475,7 +3658,7 @@ GetIndexForRecordBase // printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n", super_name, base_name, // child_idx, - // base_class->getType()->getAs<RecordType>()->getDecl()->getNameAsCString()); + // base_class->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString()); // // if (base_class == base_spec) @@ -3489,14 +3672,14 @@ GetIndexForRecordBase static uint32_t -GetIndexForRecordChild (const RecordDecl *record_decl, - NamedDecl *canonical_decl, +GetIndexForRecordChild (const clang::RecordDecl *record_decl, + clang::NamedDecl *canonical_decl, bool omit_empty_base_classes) { - uint32_t child_idx = ClangASTContext::GetNumBaseClasses (dyn_cast<CXXRecordDecl>(record_decl), + uint32_t child_idx = ClangASTContext::GetNumBaseClasses (llvm::dyn_cast<clang::CXXRecordDecl>(record_decl), omit_empty_base_classes); - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++child_idx) @@ -3549,24 +3732,24 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, { if (IsValid() && name && name[0]) { - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: if (GetCompleteType ()) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); uint32_t child_idx = 0; - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); // Try and find a field that matches NAME - RecordDecl::field_iterator field, field_end; - StringRef name_sref(name); + clang::RecordDecl::field_iterator field, field_end; + llvm::StringRef name_sref(name); for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++child_idx) @@ -3591,27 +3774,27 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, if (cxx_record_decl) { - const RecordDecl *parent_record_decl = cxx_record_decl; + const clang::RecordDecl *parent_record_decl = cxx_record_decl; //printf ("parent = %s\n", parent_record_decl->getNameAsCString()); //const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl(); // Didn't find things easily, lets let clang do its thang... - IdentifierInfo & ident_ref = m_ast->Idents.get(name_sref); - DeclarationName decl_name(&ident_ref); + clang::IdentifierInfo & ident_ref = m_ast->Idents.get(name_sref); + clang::DeclarationName decl_name(&ident_ref); - CXXBasePaths paths; - if (cxx_record_decl->lookupInBases(CXXRecordDecl::FindOrdinaryMember, + clang::CXXBasePaths paths; + if (cxx_record_decl->lookupInBases(clang::CXXRecordDecl::FindOrdinaryMember, decl_name.getAsOpaquePtr(), paths)) { - CXXBasePaths::const_paths_iterator path, path_end = paths.end(); + clang::CXXBasePaths::const_paths_iterator path, path_end = paths.end(); for (path = paths.begin(); path != path_end; ++path) { const size_t num_path_elements = path->size(); for (size_t e=0; e<num_path_elements; ++e) { - CXXBasePathElement elem = (*path)[e]; + clang::CXXBasePathElement elem = (*path)[e]; child_idx = GetIndexForRecordBase (parent_record_decl, elem.Base, omit_empty_base_classes); if (child_idx == UINT32_MAX) @@ -3622,10 +3805,10 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, else { child_indexes.push_back (child_idx); - parent_record_decl = cast<RecordDecl>(elem.Base->getType()->getAs<RecordType>()->getDecl()); + parent_record_decl = llvm::cast<clang::RecordDecl>(elem.Base->getType()->getAs<clang::RecordType>()->getDecl()); } } - for (NamedDecl *path_decl : path->Decls) + for (clang::NamedDecl *path_decl : path->Decls) { child_idx = GetIndexForRecordChild (parent_record_decl, path_decl, omit_empty_base_classes); if (child_idx == UINT32_MAX) @@ -3650,22 +3833,22 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, case clang::Type::ObjCInterface: if (GetCompleteType ()) { - StringRef name_sref(name); - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + llvm::StringRef name_sref(name); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { uint32_t child_idx = 0; - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { - const ObjCIvarDecl* ivar_decl = *ivar_pos; + const clang::ObjCIvarDecl* ivar_decl = *ivar_pos; if (ivar_decl->getName().equals (name_sref)) { @@ -3707,7 +3890,7 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, case clang::Type::ObjCObjectPointer: { - ClangASTType objc_object_clang_type (m_ast, cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()); + ClangASTType objc_object_clang_type (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()); return objc_object_clang_type.GetIndexOfChildMemberWithName (name, omit_empty_base_classes, child_indexes); @@ -3717,7 +3900,7 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, case clang::Type::ConstantArray: { - // const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr()); + // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr()); // const uint64_t element_count = array->getSize().getLimitedValue(); // // if (idx < element_count) @@ -3738,8 +3921,8 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, // case clang::Type::MemberPointerType: // { - // MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr()); - // QualType pointee_type = mem_ptr_type->getPointeeType(); + // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr()); + // clang::QualType pointee_type = mem_ptr_type->getPointeeType(); // // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr())) // { @@ -3753,8 +3936,8 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, case clang::Type::LValueReference: case clang::Type::RValueReference: { - const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr()); - QualType pointee_type(reference_type->getPointeeType()); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr()); + clang::QualType pointee_type(reference_type->getPointeeType()); ClangASTType pointee_clang_type (m_ast, pointee_type); if (pointee_clang_type.IsAggregateType ()) @@ -3780,17 +3963,17 @@ ClangASTType::GetIndexOfChildMemberWithName (const char *name, break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildMemberWithName (name, + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildMemberWithName (name, omit_empty_base_classes, child_indexes); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildMemberWithName (name, + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildMemberWithName (name, omit_empty_base_classes, child_indexes); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildMemberWithName (name, + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildMemberWithName (name, omit_empty_base_classes, child_indexes); @@ -3811,7 +3994,7 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl { if (IsValid() && name && name[0]) { - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); @@ -3820,23 +4003,23 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl case clang::Type::Record: if (GetCompleteType ()) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); uint32_t child_idx = 0; - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) { - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class) { // Skip empty base classes - CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); if (omit_empty_base_classes && ClangASTContext::RecordHasFields(base_class_decl) == false) continue; @@ -3849,8 +4032,8 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl } // Try and find a field that matches NAME - RecordDecl::field_iterator field, field_end; - StringRef name_sref(name); + clang::RecordDecl::field_iterator field, field_end; + llvm::StringRef name_sref(name); for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++child_idx) @@ -3866,22 +4049,22 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl case clang::Type::ObjCInterface: if (GetCompleteType()) { - StringRef name_sref(name); - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + llvm::StringRef name_sref(name); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { uint32_t child_idx = 0; - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); - ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { - const ObjCIvarDecl* ivar_decl = *ivar_pos; + const clang::ObjCIvarDecl* ivar_decl = *ivar_pos; if (ivar_decl->getName().equals (name_sref)) { @@ -3905,14 +4088,14 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl case clang::Type::ObjCObjectPointer: { - ClangASTType pointee_clang_type (m_ast, cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()); + ClangASTType pointee_clang_type (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()); return pointee_clang_type.GetIndexOfChildWithName (name, omit_empty_base_classes); } break; case clang::Type::ConstantArray: { - // const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr()); + // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr()); // const uint64_t element_count = array->getSize().getLimitedValue(); // // if (idx < element_count) @@ -3933,8 +4116,8 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl // case clang::Type::MemberPointerType: // { - // MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr()); - // QualType pointee_type = mem_ptr_type->getPointeeType(); + // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr()); + // clang::QualType pointee_type = mem_ptr_type->getPointeeType(); // // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr())) // { @@ -3948,7 +4131,7 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl case clang::Type::LValueReference: case clang::Type::RValueReference: { - const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr()); + const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr()); ClangASTType pointee_type (m_ast, reference_type->getPointeeType()); if (pointee_type.IsAggregateType ()) @@ -3960,7 +4143,7 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl case clang::Type::Pointer: { - const PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr()); + const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr()); ClangASTType pointee_type (m_ast, pointer_type->getPointeeType()); if (pointee_type.IsAggregateType ()) @@ -3989,13 +4172,13 @@ ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_cl break; case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildWithName (name, omit_empty_base_classes); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildWithName (name, omit_empty_base_classes); case clang::Type::Paren: - return ClangASTType (m_ast, cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildWithName (name, omit_empty_base_classes); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildWithName (name, omit_empty_base_classes); case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildWithName (name, omit_empty_base_classes); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildWithName (name, omit_empty_base_classes); default: break; @@ -4010,7 +4193,7 @@ ClangASTType::GetNumTemplateArguments () const { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -4018,10 +4201,10 @@ ClangASTType::GetNumTemplateArguments () const case clang::Type::Record: if (GetCompleteType ()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { - const ClassTemplateSpecializationDecl *template_decl = dyn_cast<ClassTemplateSpecializationDecl>(cxx_record_decl); + const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl); if (template_decl) return template_decl->getTemplateArgs().size(); } @@ -4029,13 +4212,13 @@ ClangASTType::GetNumTemplateArguments () const break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumTemplateArguments(); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumTemplateArguments(); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetNumTemplateArguments(); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumTemplateArguments(); case clang::Type::Paren: - return ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).GetNumTemplateArguments(); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumTemplateArguments(); default: break; @@ -4049,7 +4232,7 @@ ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &k { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -4057,13 +4240,13 @@ ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &k case clang::Type::Record: if (GetCompleteType ()) { - const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { - const ClassTemplateSpecializationDecl *template_decl = dyn_cast<ClassTemplateSpecializationDecl>(cxx_record_decl); + const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl); if (template_decl && arg_idx < template_decl->getTemplateArgs().size()) { - const TemplateArgument &template_arg = template_decl->getTemplateArgs()[arg_idx]; + const clang::TemplateArgument &template_arg = template_decl->getTemplateArgs()[arg_idx]; switch (template_arg.getKind()) { case clang::TemplateArgument::Null: @@ -4099,7 +4282,7 @@ ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &k return ClangASTType(); default: - assert (!"Unhandled TemplateArgument::ArgKind"); + assert (!"Unhandled clang::TemplateArgument::ArgKind"); break; } } @@ -4108,13 +4291,13 @@ ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &k break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTemplateArgument (arg_idx, kind); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTemplateArgument (arg_idx, kind); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetTemplateArgument (arg_idx, kind); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTemplateArgument (arg_idx, kind); case clang::Type::Paren: - return ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).GetTemplateArgument (arg_idx, kind); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTemplateArgument (arg_idx, kind); default: break; @@ -4125,15 +4308,15 @@ ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &k } static bool -IsOperator (const char *name, OverloadedOperatorKind &op_kind) +IsOperator (const char *name, clang::OverloadedOperatorKind &op_kind) { - if (name == NULL || name[0] == '\0') + if (name == nullptr || name[0] == '\0') return false; #define OPERATOR_PREFIX "operator" #define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1) - const char *post_op_name = NULL; + const char *post_op_name = nullptr; bool no_space = true; @@ -4153,7 +4336,7 @@ IsOperator (const char *name, OverloadedOperatorKind &op_kind) // This is an operator, set the overloaded operator kind to invalid // in case this is a conversion operator... - op_kind = NUM_OVERLOADED_OPERATORS; + op_kind = clang::NUM_OVERLOADED_OPERATORS; switch (post_op_name[0]) { @@ -4165,204 +4348,197 @@ IsOperator (const char *name, OverloadedOperatorKind &op_kind) if (no_space) return false; if (strcmp (post_op_name, "new") == 0) - op_kind = OO_New; + op_kind = clang::OO_New; else if (strcmp (post_op_name, "new[]") == 0) - op_kind = OO_Array_New; + op_kind = clang::OO_Array_New; break; case 'd': if (no_space) return false; if (strcmp (post_op_name, "delete") == 0) - op_kind = OO_Delete; + op_kind = clang::OO_Delete; else if (strcmp (post_op_name, "delete[]") == 0) - op_kind = OO_Array_Delete; + op_kind = clang::OO_Array_Delete; break; case '+': if (post_op_name[1] == '\0') - op_kind = OO_Plus; + op_kind = clang::OO_Plus; else if (post_op_name[2] == '\0') { if (post_op_name[1] == '=') - op_kind = OO_PlusEqual; + op_kind = clang::OO_PlusEqual; else if (post_op_name[1] == '+') - op_kind = OO_PlusPlus; + op_kind = clang::OO_PlusPlus; } break; case '-': if (post_op_name[1] == '\0') - op_kind = OO_Minus; + op_kind = clang::OO_Minus; else if (post_op_name[2] == '\0') { switch (post_op_name[1]) { - case '=': op_kind = OO_MinusEqual; break; - case '-': op_kind = OO_MinusMinus; break; - case '>': op_kind = OO_Arrow; break; + case '=': op_kind = clang::OO_MinusEqual; break; + case '-': op_kind = clang::OO_MinusMinus; break; + case '>': op_kind = clang::OO_Arrow; break; } } else if (post_op_name[3] == '\0') { if (post_op_name[2] == '*') - op_kind = OO_ArrowStar; break; + op_kind = clang::OO_ArrowStar; break; } break; case '*': if (post_op_name[1] == '\0') - op_kind = OO_Star; + op_kind = clang::OO_Star; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_StarEqual; + op_kind = clang::OO_StarEqual; break; case '/': if (post_op_name[1] == '\0') - op_kind = OO_Slash; + op_kind = clang::OO_Slash; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_SlashEqual; + op_kind = clang::OO_SlashEqual; break; case '%': if (post_op_name[1] == '\0') - op_kind = OO_Percent; + op_kind = clang::OO_Percent; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_PercentEqual; + op_kind = clang::OO_PercentEqual; break; case '^': if (post_op_name[1] == '\0') - op_kind = OO_Caret; + op_kind = clang::OO_Caret; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_CaretEqual; + op_kind = clang::OO_CaretEqual; break; case '&': if (post_op_name[1] == '\0') - op_kind = OO_Amp; + op_kind = clang::OO_Amp; else if (post_op_name[2] == '\0') { switch (post_op_name[1]) { - case '=': op_kind = OO_AmpEqual; break; - case '&': op_kind = OO_AmpAmp; break; + case '=': op_kind = clang::OO_AmpEqual; break; + case '&': op_kind = clang::OO_AmpAmp; break; } } break; case '|': if (post_op_name[1] == '\0') - op_kind = OO_Pipe; + op_kind = clang::OO_Pipe; else if (post_op_name[2] == '\0') { switch (post_op_name[1]) { - case '=': op_kind = OO_PipeEqual; break; - case '|': op_kind = OO_PipePipe; break; + case '=': op_kind = clang::OO_PipeEqual; break; + case '|': op_kind = clang::OO_PipePipe; break; } } break; case '~': if (post_op_name[1] == '\0') - op_kind = OO_Tilde; + op_kind = clang::OO_Tilde; break; case '!': if (post_op_name[1] == '\0') - op_kind = OO_Exclaim; + op_kind = clang::OO_Exclaim; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_ExclaimEqual; + op_kind = clang::OO_ExclaimEqual; break; case '=': if (post_op_name[1] == '\0') - op_kind = OO_Equal; + op_kind = clang::OO_Equal; else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_EqualEqual; + op_kind = clang::OO_EqualEqual; break; case '<': if (post_op_name[1] == '\0') - op_kind = OO_Less; + op_kind = clang::OO_Less; else if (post_op_name[2] == '\0') { switch (post_op_name[1]) { - case '<': op_kind = OO_LessLess; break; - case '=': op_kind = OO_LessEqual; break; + case '<': op_kind = clang::OO_LessLess; break; + case '=': op_kind = clang::OO_LessEqual; break; } } else if (post_op_name[3] == '\0') { if (post_op_name[2] == '=') - op_kind = OO_LessLessEqual; + op_kind = clang::OO_LessLessEqual; } break; case '>': if (post_op_name[1] == '\0') - op_kind = OO_Greater; + op_kind = clang::OO_Greater; else if (post_op_name[2] == '\0') { switch (post_op_name[1]) { - case '>': op_kind = OO_GreaterGreater; break; - case '=': op_kind = OO_GreaterEqual; break; + case '>': op_kind = clang::OO_GreaterGreater; break; + case '=': op_kind = clang::OO_GreaterEqual; break; } } else if (post_op_name[1] == '>' && post_op_name[2] == '=' && post_op_name[3] == '\0') { - op_kind = OO_GreaterGreaterEqual; + op_kind = clang::OO_GreaterGreaterEqual; } break; case ',': if (post_op_name[1] == '\0') - op_kind = OO_Comma; + op_kind = clang::OO_Comma; break; case '(': if (post_op_name[1] == ')' && post_op_name[2] == '\0') - op_kind = OO_Call; + op_kind = clang::OO_Call; break; case '[': if (post_op_name[1] == ']' && post_op_name[2] == '\0') - op_kind = OO_Subscript; + op_kind = clang::OO_Subscript; break; } return true; } -static inline bool -check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params) +clang::EnumDecl * +ClangASTType::GetAsEnumDecl () const { - // Special-case call since it can take any number of operands - if(op_kind == OO_Call) - return true; - - // The parameter count doens't include "this" - if (num_params == 0) - return unary; - if (num_params == 1) - return binary; - else - return false; + const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType()); + if (enum_type) + return enum_type->getDecl(); + return NULL; } clang::RecordDecl * ClangASTType::GetAsRecordDecl () const { - const RecordType *record_type = dyn_cast<RecordType>(GetCanonicalQualType()); + const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(GetCanonicalQualType()); if (record_type) return record_type->getDecl(); - return NULL; + return nullptr; } clang::CXXRecordDecl * @@ -4371,13 +4547,13 @@ ClangASTType::GetAsCXXRecordDecl () const return GetCanonicalQualType()->getAsCXXRecordDecl(); } -ObjCInterfaceDecl * +clang::ObjCInterfaceDecl * ClangASTType::GetAsObjCInterfaceDecl () const { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(GetCanonicalQualType()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(GetCanonicalQualType()); if (objc_class_type) return objc_class_type->getInterface(); - return NULL; + return nullptr; } clang::FieldDecl * @@ -4387,37 +4563,37 @@ ClangASTType::AddFieldToRecordType (const char *name, uint32_t bitfield_bit_size) { if (!IsValid() || !field_clang_type.IsValid()) - return NULL; + return nullptr; - FieldDecl *field = NULL; + clang::FieldDecl *field = nullptr; - clang::Expr *bit_width = NULL; + clang::Expr *bit_width = nullptr; if (bitfield_bit_size != 0) { - APInt bitfield_bit_size_apint(m_ast->getTypeSize(m_ast->IntTy), bitfield_bit_size); - bit_width = new (*m_ast)IntegerLiteral (*m_ast, bitfield_bit_size_apint, m_ast->IntTy, SourceLocation()); + llvm::APInt bitfield_bit_size_apint(m_ast->getTypeSize(m_ast->IntTy), bitfield_bit_size); + bit_width = new (*m_ast)clang::IntegerLiteral (*m_ast, bitfield_bit_size_apint, m_ast->IntTy, clang::SourceLocation()); } - RecordDecl *record_decl = GetAsRecordDecl (); + clang::RecordDecl *record_decl = GetAsRecordDecl (); if (record_decl) { - field = FieldDecl::Create (*m_ast, - record_decl, - SourceLocation(), - SourceLocation(), - name ? &m_ast->Idents.get(name) : NULL, // Identifier - field_clang_type.GetQualType(), // Field type - NULL, // TInfo * - bit_width, // BitWidth - false, // Mutable - ICIS_NoInit); // HasInit + field = clang::FieldDecl::Create (*m_ast, + record_decl, + clang::SourceLocation(), + clang::SourceLocation(), + name ? &m_ast->Idents.get(name) : nullptr, // Identifier + field_clang_type.GetQualType(), // Field type + nullptr, // TInfo * + bit_width, // BitWidth + false, // Mutable + clang::ICIS_NoInit); // HasInit if (!name) { // Determine whether this field corresponds to an anonymous // struct or union. - if (const TagType *TagT = field->getType()->getAs<TagType>()) { - if (RecordDecl *Rec = dyn_cast<RecordDecl>(TagT->getDecl())) + if (const clang::TagType *TagT = field->getType()->getAs<clang::TagType>()) { + if (clang::RecordDecl *Rec = llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl())) if (!Rec->getDeclName()) { Rec->setAnonymousStructOrUnion(true); field->setImplicit(); @@ -4439,7 +4615,7 @@ ClangASTType::AddFieldToRecordType (const char *name, } else { - ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); + clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); if (class_interface_decl) { @@ -4447,13 +4623,13 @@ ClangASTType::AddFieldToRecordType (const char *name, field_clang_type.GetCompleteType(); - field = ObjCIvarDecl::Create (*m_ast, + field = clang::ObjCIvarDecl::Create (*m_ast, class_interface_decl, - SourceLocation(), - SourceLocation(), - name ? &m_ast->Idents.get(name) : NULL, // Identifier + clang::SourceLocation(), + clang::SourceLocation(), + name ? &m_ast->Idents.get(name) : nullptr, // Identifier field_clang_type.GetQualType(), // Field type - NULL, // TypeSourceInfo * + nullptr, // TypeSourceInfo * ConvertAccessTypeToObjCIvarAccessControl (access), bit_width, is_synthesized); @@ -4474,49 +4650,49 @@ ClangASTType::AddFieldToRecordType (const char *name, void ClangASTType::BuildIndirectFields () { - RecordDecl *record_decl = GetAsRecordDecl(); + clang::RecordDecl *record_decl = GetAsRecordDecl(); if (!record_decl) return; - typedef llvm::SmallVector <IndirectFieldDecl *, 1> IndirectFieldVector; + typedef llvm::SmallVector <clang::IndirectFieldDecl *, 1> IndirectFieldVector; IndirectFieldVector indirect_fields; - RecordDecl::field_iterator field_pos; - RecordDecl::field_iterator field_end_pos = record_decl->field_end(); - RecordDecl::field_iterator last_field_pos = field_end_pos; + clang::RecordDecl::field_iterator field_pos; + clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end(); + clang::RecordDecl::field_iterator last_field_pos = field_end_pos; for (field_pos = record_decl->field_begin(); field_pos != field_end_pos; last_field_pos = field_pos++) { if (field_pos->isAnonymousStructOrUnion()) { - QualType field_qual_type = field_pos->getType(); + clang::QualType field_qual_type = field_pos->getType(); - const RecordType *field_record_type = field_qual_type->getAs<RecordType>(); + const clang::RecordType *field_record_type = field_qual_type->getAs<clang::RecordType>(); if (!field_record_type) continue; - RecordDecl *field_record_decl = field_record_type->getDecl(); + clang::RecordDecl *field_record_decl = field_record_type->getDecl(); if (!field_record_decl) continue; - for (RecordDecl::decl_iterator di = field_record_decl->decls_begin(), de = field_record_decl->decls_end(); + for (clang::RecordDecl::decl_iterator di = field_record_decl->decls_begin(), de = field_record_decl->decls_end(); di != de; ++di) { - if (FieldDecl *nested_field_decl = dyn_cast<FieldDecl>(*di)) + if (clang::FieldDecl *nested_field_decl = llvm::dyn_cast<clang::FieldDecl>(*di)) { - NamedDecl **chain = new (*m_ast) NamedDecl*[2]; + clang::NamedDecl **chain = new (*m_ast) clang::NamedDecl*[2]; chain[0] = *field_pos; chain[1] = nested_field_decl; - IndirectFieldDecl *indirect_field = IndirectFieldDecl::Create(*m_ast, - record_decl, - SourceLocation(), - nested_field_decl->getIdentifier(), - nested_field_decl->getType(), - chain, - 2); + clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*m_ast, + record_decl, + clang::SourceLocation(), + nested_field_decl->getIdentifier(), + nested_field_decl->getType(), + chain, + 2); indirect_field->setImplicit(); @@ -4525,14 +4701,14 @@ ClangASTType::BuildIndirectFields () indirect_fields.push_back(indirect_field); } - else if (IndirectFieldDecl *nested_indirect_field_decl = dyn_cast<IndirectFieldDecl>(*di)) + else if (clang::IndirectFieldDecl *nested_indirect_field_decl = llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) { int nested_chain_size = nested_indirect_field_decl->getChainingSize(); - NamedDecl **chain = new (*m_ast) NamedDecl*[nested_chain_size + 1]; + clang::NamedDecl **chain = new (*m_ast) clang::NamedDecl*[nested_chain_size + 1]; chain[0] = *field_pos; int chain_index = 1; - for (IndirectFieldDecl::chain_iterator nci = nested_indirect_field_decl->chain_begin(), + for (clang::IndirectFieldDecl::chain_iterator nci = nested_indirect_field_decl->chain_begin(), nce = nested_indirect_field_decl->chain_end(); nci < nce; ++nci) @@ -4541,13 +4717,13 @@ ClangASTType::BuildIndirectFields () chain_index++; } - IndirectFieldDecl *indirect_field = IndirectFieldDecl::Create(*m_ast, - record_decl, - SourceLocation(), - nested_indirect_field_decl->getIdentifier(), - nested_indirect_field_decl->getType(), - chain, - nested_chain_size + 1); + clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*m_ast, + record_decl, + clang::SourceLocation(), + nested_indirect_field_decl->getIdentifier(), + nested_indirect_field_decl->getType(), + chain, + nested_chain_size + 1); indirect_field->setImplicit(); @@ -4581,22 +4757,22 @@ ClangASTType::AddVariableToRecordType (const char *name, const ClangASTType &var_type, AccessType access) { - clang::VarDecl *var_decl = NULL; + clang::VarDecl *var_decl = nullptr; if (!IsValid() || !var_type.IsValid()) - return NULL; + return nullptr; - RecordDecl *record_decl = GetAsRecordDecl (); + clang::RecordDecl *record_decl = GetAsRecordDecl (); if (record_decl) { - var_decl = VarDecl::Create (*m_ast, // ASTContext & - record_decl, // DeclContext * - SourceLocation(), // SourceLocation StartLoc - SourceLocation(), // SourceLocation IdLoc - name ? &m_ast->Idents.get(name) : NULL, // IdentifierInfo * - var_type.GetQualType(), // Variable QualType - NULL, // TypeSourceInfo * - SC_Static); // StorageClass + var_decl = clang::VarDecl::Create (*m_ast, // ASTContext & + record_decl, // DeclContext * + clang::SourceLocation(), // clang::SourceLocation StartLoc + clang::SourceLocation(), // clang::SourceLocation IdLoc + name ? &m_ast->Idents.get(name) : nullptr, // clang::IdentifierInfo * + var_type.GetQualType(), // Variable clang::QualType + nullptr, // TypeSourceInfo * + clang::SC_Static); // StorageClass if (var_decl) { var_decl->setAccess(ClangASTContext::ConvertAccessTypeToAccessSpecifier (access)); @@ -4611,7 +4787,7 @@ ClangASTType::AddVariableToRecordType (const char *name, } -CXXMethodDecl * +clang::CXXMethodDecl * ClangASTType::AddMethodToCXXRecordType (const char *name, const ClangASTType &method_clang_type, lldb::AccessType access, @@ -4622,74 +4798,74 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, bool is_attr_used, bool is_artificial) { - if (!IsValid() || !method_clang_type.IsValid() || name == NULL || name[0] == '\0') - return NULL; + if (!IsValid() || !method_clang_type.IsValid() || name == nullptr || name[0] == '\0') + return nullptr; - QualType record_qual_type(GetCanonicalQualType()); + clang::QualType record_qual_type(GetCanonicalQualType()); - CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl == NULL) - return NULL; + if (cxx_record_decl == nullptr) + return nullptr; - QualType method_qual_type (method_clang_type.GetQualType()); + clang::QualType method_qual_type (method_clang_type.GetQualType()); - CXXMethodDecl *cxx_method_decl = NULL; + clang::CXXMethodDecl *cxx_method_decl = nullptr; - DeclarationName decl_name (&m_ast->Idents.get(name)); + clang::DeclarationName decl_name (&m_ast->Idents.get(name)); - const clang::FunctionType *function_type = dyn_cast<FunctionType>(method_qual_type.getTypePtr()); + const clang::FunctionType *function_type = llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr()); - if (function_type == NULL) - return NULL; + if (function_type == nullptr) + return nullptr; - const FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(function_type)); + const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(function_type)); if (!method_function_prototype) - return NULL; + return nullptr; unsigned int num_params = method_function_prototype->getNumParams(); - CXXDestructorDecl *cxx_dtor_decl(NULL); - CXXConstructorDecl *cxx_ctor_decl(NULL); + clang::CXXDestructorDecl *cxx_dtor_decl(nullptr); + clang::CXXConstructorDecl *cxx_ctor_decl(nullptr); if (is_artificial) - return NULL; // skip everything artificial + return nullptr; // skip everything artificial if (name[0] == '~') { - cxx_dtor_decl = CXXDestructorDecl::Create (*m_ast, - cxx_record_decl, - SourceLocation(), - DeclarationNameInfo (m_ast->DeclarationNames.getCXXDestructorName (m_ast->getCanonicalType (record_qual_type)), SourceLocation()), - method_qual_type, - NULL, - is_inline, - is_artificial); + cxx_dtor_decl = clang::CXXDestructorDecl::Create (*m_ast, + cxx_record_decl, + clang::SourceLocation(), + clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXDestructorName (m_ast->getCanonicalType (record_qual_type)), clang::SourceLocation()), + method_qual_type, + nullptr, + is_inline, + is_artificial); cxx_method_decl = cxx_dtor_decl; } else if (decl_name == cxx_record_decl->getDeclName()) { - cxx_ctor_decl = CXXConstructorDecl::Create (*m_ast, - cxx_record_decl, - SourceLocation(), - DeclarationNameInfo (m_ast->DeclarationNames.getCXXConstructorName (m_ast->getCanonicalType (record_qual_type)), SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - is_explicit, - is_inline, - is_artificial, - false /*is_constexpr*/); + cxx_ctor_decl = clang::CXXConstructorDecl::Create (*m_ast, + cxx_record_decl, + clang::SourceLocation(), + clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXConstructorName (m_ast->getCanonicalType (record_qual_type)), clang::SourceLocation()), + method_qual_type, + nullptr, // TypeSourceInfo * + is_explicit, + is_inline, + is_artificial, + false /*is_constexpr*/); cxx_method_decl = cxx_ctor_decl; } else { - clang::StorageClass SC = is_static ? SC_Static : SC_None; - OverloadedOperatorKind op_kind = NUM_OVERLOADED_OPERATORS; + clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None; + clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS; if (IsOperator (name, op_kind)) { - if (op_kind != NUM_OVERLOADED_OPERATORS) + if (op_kind != clang::NUM_OVERLOADED_OPERATORS) { // Check the number of operator parameters. Sometimes we have // seen bad DWARF that doesn't correctly describe operators and @@ -4697,50 +4873,50 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, // will assert and crash, so we need to make sure things are // acceptable. if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params)) - return NULL; - cxx_method_decl = CXXMethodDecl::Create (*m_ast, - cxx_record_decl, - SourceLocation(), - DeclarationNameInfo (m_ast->DeclarationNames.getCXXOperatorName (op_kind), SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - SC, - is_inline, - false /*is_constexpr*/, - SourceLocation()); + return nullptr; + cxx_method_decl = clang::CXXMethodDecl::Create (*m_ast, + cxx_record_decl, + clang::SourceLocation(), + clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXOperatorName (op_kind), clang::SourceLocation()), + method_qual_type, + nullptr, // TypeSourceInfo * + SC, + is_inline, + false /*is_constexpr*/, + clang::SourceLocation()); } else if (num_params == 0) { // Conversion operators don't take params... - cxx_method_decl = CXXConversionDecl::Create (*m_ast, - cxx_record_decl, - SourceLocation(), - DeclarationNameInfo (m_ast->DeclarationNames.getCXXConversionFunctionName (m_ast->getCanonicalType (function_type->getReturnType())), SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - is_inline, - is_explicit, - false /*is_constexpr*/, - SourceLocation()); + cxx_method_decl = clang::CXXConversionDecl::Create (*m_ast, + cxx_record_decl, + clang::SourceLocation(), + clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXConversionFunctionName (m_ast->getCanonicalType (function_type->getReturnType())), clang::SourceLocation()), + method_qual_type, + nullptr, // TypeSourceInfo * + is_inline, + is_explicit, + false /*is_constexpr*/, + clang::SourceLocation()); } } - if (cxx_method_decl == NULL) + if (cxx_method_decl == nullptr) { - cxx_method_decl = CXXMethodDecl::Create (*m_ast, - cxx_record_decl, - SourceLocation(), - DeclarationNameInfo (decl_name, SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - SC, - is_inline, - false /*is_constexpr*/, - SourceLocation()); + cxx_method_decl = clang::CXXMethodDecl::Create (*m_ast, + cxx_record_decl, + clang::SourceLocation(), + clang::DeclarationNameInfo (decl_name, clang::SourceLocation()), + method_qual_type, + nullptr, // TypeSourceInfo * + SC, + is_inline, + false /*is_constexpr*/, + clang::SourceLocation()); } } - AccessSpecifier access_specifier = ClangASTContext::ConvertAccessTypeToAccessSpecifier (access); + clang::AccessSpecifier access_specifier = ClangASTContext::ConvertAccessTypeToAccessSpecifier (access); cxx_method_decl->setAccess (access_specifier); cxx_method_decl->setVirtualAsWritten (is_virtual); @@ -4750,24 +4926,24 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, // Populate the method decl with parameter decls - llvm::SmallVector<ParmVarDecl *, 12> params; + llvm::SmallVector<clang::ParmVarDecl *, 12> params; for (unsigned param_index = 0; param_index < num_params; ++param_index) { - params.push_back (ParmVarDecl::Create (*m_ast, - cxx_method_decl, - SourceLocation(), - SourceLocation(), - NULL, // anonymous - method_function_prototype->getParamType(param_index), - NULL, - SC_None, - NULL)); + params.push_back (clang::ParmVarDecl::Create (*m_ast, + cxx_method_decl, + clang::SourceLocation(), + clang::SourceLocation(), + nullptr, // anonymous + method_function_prototype->getParamType(param_index), + nullptr, + clang::SC_None, + nullptr)); } - cxx_method_decl->setParams (ArrayRef<ParmVarDecl*>(params)); + cxx_method_decl->setParams (llvm::ArrayRef<clang::ParmVarDecl*>(params)); cxx_record_decl->addDecl (cxx_method_decl); @@ -4823,36 +4999,36 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, #pragma mark C++ Base Classes -CXXBaseSpecifier * +clang::CXXBaseSpecifier * ClangASTType::CreateBaseClassSpecifier (AccessType access, bool is_virtual, bool base_of_class) { if (IsValid()) - return new CXXBaseSpecifier (SourceRange(), - is_virtual, - base_of_class, - ClangASTContext::ConvertAccessTypeToAccessSpecifier (access), - m_ast->getTrivialTypeSourceInfo (GetQualType()), - SourceLocation()); - return NULL; + return new clang::CXXBaseSpecifier (clang::SourceRange(), + is_virtual, + base_of_class, + ClangASTContext::ConvertAccessTypeToAccessSpecifier (access), + m_ast->getTrivialTypeSourceInfo (GetQualType()), + clang::SourceLocation()); + return nullptr; } void -ClangASTType::DeleteBaseClassSpecifiers (CXXBaseSpecifier **base_classes, unsigned num_base_classes) +ClangASTType::DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, unsigned num_base_classes) { for (unsigned i=0; i<num_base_classes; ++i) { delete base_classes[i]; - base_classes[i] = NULL; + base_classes[i] = nullptr; } } bool -ClangASTType::SetBaseClassesForClassType (CXXBaseSpecifier const * const *base_classes, +ClangASTType::SetBaseClassesForClassType (clang::CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes) { if (IsValid()) { - CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(); if (cxx_record_decl) { cxx_record_decl->setBases(base_classes, num_base_classes); @@ -4867,8 +5043,8 @@ ClangASTType::SetObjCSuperClass (const ClangASTType &superclass_clang_type) { if (IsValid() && superclass_clang_type.IsValid()) { - ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); - ObjCInterfaceDecl *super_interface_decl = superclass_clang_type.GetAsObjCInterfaceDecl (); + clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); + clang::ObjCInterfaceDecl *super_interface_decl = superclass_clang_type.GetAsObjCInterfaceDecl (); if (class_interface_decl && super_interface_decl) { class_interface_decl->setSuperClass(super_interface_decl); @@ -4881,16 +5057,16 @@ ClangASTType::SetObjCSuperClass (const ClangASTType &superclass_clang_type) bool ClangASTType::AddObjCClassProperty (const char *property_name, const ClangASTType &property_clang_type, - ObjCIvarDecl *ivar_decl, + clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata *metadata) { - if (!IsValid() || !property_clang_type.IsValid() || property_name == NULL || property_name[0] == '\0') + if (!IsValid() || !property_clang_type.IsValid() || property_name == nullptr || property_name[0] == '\0') return false; - ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); + clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); if (class_interface_decl) { @@ -4909,13 +5085,13 @@ ClangASTType::AddObjCClassProperty (const char *property_name, else prop_type_source = m_ast->getTrivialTypeSourceInfo (property_clang_type.GetQualType()); - ObjCPropertyDecl *property_decl = ObjCPropertyDecl::Create (*m_ast, - class_interface_decl, - SourceLocation(), // Source Location - &m_ast->Idents.get(property_name), - SourceLocation(), //Source Location for AT - SourceLocation(), //Source location for ( - prop_type_source); + clang::ObjCPropertyDecl *property_decl = clang::ObjCPropertyDecl::Create (*m_ast, + class_interface_decl, + clang::SourceLocation(), // Source Location + &m_ast->Idents.get(property_name), + clang::SourceLocation(), //Source Location for AT + clang::SourceLocation(), //Source location for ( + prop_type_source); if (property_decl) { @@ -4924,9 +5100,9 @@ ClangASTType::AddObjCClassProperty (const char *property_name, class_interface_decl->addDecl (property_decl); - Selector setter_sel, getter_sel; + clang::Selector setter_sel, getter_sel; - if (property_setter_name != NULL) + if (property_setter_name != nullptr) { std::string property_setter_no_colon(property_setter_name, strlen(property_setter_name) - 1); clang::IdentifierInfo *setter_ident = &m_ast->Idents.get(property_setter_no_colon.c_str()); @@ -4943,7 +5119,7 @@ ClangASTType::AddObjCClassProperty (const char *property_name, property_decl->setSetterName(setter_sel); property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_setter); - if (property_getter_name != NULL) + if (property_getter_name != nullptr) { clang::IdentifierInfo *getter_ident = &m_ast->Idents.get(property_getter_name); getter_sel = m_ast->Selectors.getSelector(0, &getter_ident); @@ -4979,75 +5155,75 @@ ClangASTType::AddObjCClassProperty (const char *property_name, const bool isSynthesized = false; const bool isImplicitlyDeclared = true; const bool isDefined = false; - const ObjCMethodDecl::ImplementationControl impControl = ObjCMethodDecl::None; + const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None; const bool HasRelatedResultType = false; - ObjCMethodDecl *getter = ObjCMethodDecl::Create (*m_ast, - SourceLocation(), - SourceLocation(), - getter_sel, - property_clang_type_to_access.GetQualType(), - NULL, - class_interface_decl, - isInstance, - isVariadic, - isSynthesized, - isImplicitlyDeclared, - isDefined, - impControl, - HasRelatedResultType); + clang::ObjCMethodDecl *getter = clang::ObjCMethodDecl::Create (*m_ast, + clang::SourceLocation(), + clang::SourceLocation(), + getter_sel, + property_clang_type_to_access.GetQualType(), + nullptr, + class_interface_decl, + isInstance, + isVariadic, + isSynthesized, + isImplicitlyDeclared, + isDefined, + impControl, + HasRelatedResultType); if (getter && metadata) ClangASTContext::SetMetadata(m_ast, getter, *metadata); - getter->setMethodParams(*m_ast, ArrayRef<ParmVarDecl*>(), ArrayRef<SourceLocation>()); + getter->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(), llvm::ArrayRef<clang::SourceLocation>()); class_interface_decl->addDecl(getter); } if (!setter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(setter_sel)) { - QualType result_type = m_ast->VoidTy; + clang::QualType result_type = m_ast->VoidTy; const bool isInstance = true; const bool isVariadic = false; const bool isSynthesized = false; const bool isImplicitlyDeclared = true; const bool isDefined = false; - const ObjCMethodDecl::ImplementationControl impControl = ObjCMethodDecl::None; + const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None; const bool HasRelatedResultType = false; - ObjCMethodDecl *setter = ObjCMethodDecl::Create (*m_ast, - SourceLocation(), - SourceLocation(), - setter_sel, - result_type, - NULL, - class_interface_decl, - isInstance, - isVariadic, - isSynthesized, - isImplicitlyDeclared, - isDefined, - impControl, - HasRelatedResultType); + clang::ObjCMethodDecl *setter = clang::ObjCMethodDecl::Create (*m_ast, + clang::SourceLocation(), + clang::SourceLocation(), + setter_sel, + result_type, + nullptr, + class_interface_decl, + isInstance, + isVariadic, + isSynthesized, + isImplicitlyDeclared, + isDefined, + impControl, + HasRelatedResultType); if (setter && metadata) ClangASTContext::SetMetadata(m_ast, setter, *metadata); - llvm::SmallVector<ParmVarDecl *, 1> params; + llvm::SmallVector<clang::ParmVarDecl *, 1> params; - params.push_back (ParmVarDecl::Create (*m_ast, - setter, - SourceLocation(), - SourceLocation(), - NULL, // anonymous - property_clang_type_to_access.GetQualType(), - NULL, - SC_Auto, - NULL)); + params.push_back (clang::ParmVarDecl::Create (*m_ast, + setter, + clang::SourceLocation(), + clang::SourceLocation(), + nullptr, // anonymous + property_clang_type_to_access.GetQualType(), + nullptr, + clang::SC_Auto, + nullptr)); - setter->setMethodParams(*m_ast, ArrayRef<ParmVarDecl*>(params), ArrayRef<SourceLocation>()); + setter->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>()); class_interface_decl->addDecl(setter); } @@ -5062,33 +5238,33 @@ ClangASTType::AddObjCClassProperty (const char *property_name, bool ClangASTType::IsObjCClassTypeAndHasIVars (bool check_superclass) const { - ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); + clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (); if (class_interface_decl) return ObjCDeclHasIVars (class_interface_decl, check_superclass); return false; } -ObjCMethodDecl * +clang::ObjCMethodDecl * ClangASTType::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) { if (!IsValid() || !method_clang_type.IsValid()) - return NULL; + return nullptr; - ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(); + clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(); - if (class_interface_decl == NULL) - return NULL; + if (class_interface_decl == nullptr) + return nullptr; const char *selector_start = ::strchr (name, ' '); - if (selector_start == NULL) - return NULL; + if (selector_start == nullptr) + return nullptr; selector_start++; - llvm::SmallVector<IdentifierInfo *, 12> selector_idents; + llvm::SmallVector<clang::IdentifierInfo *, 12> selector_idents; size_t len = 0; const char *start; @@ -5103,79 +5279,79 @@ ClangASTType::AddMethodToObjCObjectType (const char *name, // the full symbol n bool has_arg = (start[len] == ':'); if (has_arg) ++num_selectors_with_args; - selector_idents.push_back (&m_ast->Idents.get (StringRef (start, len))); + selector_idents.push_back (&m_ast->Idents.get (llvm::StringRef (start, len))); if (has_arg) len += 1; } if (selector_idents.size() == 0) - return 0; + return nullptr; clang::Selector method_selector = m_ast->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0, selector_idents.data()); - QualType method_qual_type (method_clang_type.GetQualType()); + clang::QualType method_qual_type (method_clang_type.GetQualType()); // Populate the method decl with parameter decls const clang::Type *method_type(method_qual_type.getTypePtr()); - if (method_type == NULL) - return NULL; + if (method_type == nullptr) + return nullptr; - const FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(method_type)); + const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(method_type)); if (!method_function_prototype) - return NULL; + return nullptr; bool is_variadic = false; bool is_synthesized = false; bool is_defined = false; - ObjCMethodDecl::ImplementationControl imp_control = ObjCMethodDecl::None; + clang::ObjCMethodDecl::ImplementationControl imp_control = clang::ObjCMethodDecl::None; const unsigned num_args = method_function_prototype->getNumParams(); if (num_args != num_selectors_with_args) - return NULL; // some debug information is corrupt. We are not going to deal with it. + return nullptr; // some debug information is corrupt. We are not going to deal with it. - ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*m_ast, - SourceLocation(), // beginLoc, - SourceLocation(), // endLoc, - method_selector, - method_function_prototype->getReturnType(), - NULL, // TypeSourceInfo *ResultTInfo, - GetDeclContextForType (), - name[0] == '-', - is_variadic, - is_synthesized, - true, // is_implicitly_declared; we force this to true because we don't have source locations - is_defined, - imp_control, - false /*has_related_result_type*/); + clang::ObjCMethodDecl *objc_method_decl = clang::ObjCMethodDecl::Create (*m_ast, + clang::SourceLocation(), // beginLoc, + clang::SourceLocation(), // endLoc, + method_selector, + method_function_prototype->getReturnType(), + nullptr, // TypeSourceInfo *ResultTInfo, + GetDeclContextForType (), + name[0] == '-', + is_variadic, + is_synthesized, + true, // is_implicitly_declared; we force this to true because we don't have source locations + is_defined, + imp_control, + false /*has_related_result_type*/); - if (objc_method_decl == NULL) - return NULL; + if (objc_method_decl == nullptr) + return nullptr; if (num_args > 0) { - llvm::SmallVector<ParmVarDecl *, 12> params; + llvm::SmallVector<clang::ParmVarDecl *, 12> params; for (unsigned param_index = 0; param_index < num_args; ++param_index) { - params.push_back (ParmVarDecl::Create (*m_ast, - objc_method_decl, - SourceLocation(), - SourceLocation(), - NULL, // anonymous - method_function_prototype->getParamType(param_index), - NULL, - SC_Auto, - NULL)); + params.push_back (clang::ParmVarDecl::Create (*m_ast, + objc_method_decl, + clang::SourceLocation(), + clang::SourceLocation(), + nullptr, // anonymous + method_function_prototype->getParamType(param_index), + nullptr, + clang::SC_Auto, + nullptr)); } - objc_method_decl->setMethodParams(*m_ast, ArrayRef<ParmVarDecl*>(params), ArrayRef<SourceLocation>()); + objc_method_decl->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>()); } class_interface_decl->addDecl (objc_method_decl); @@ -5192,9 +5368,9 @@ clang::DeclContext * ClangASTType::GetDeclContextForType () const { if (!IsValid()) - return NULL; + return nullptr; - QualType qual_type(GetCanonicalQualType()); + clang::QualType qual_type(GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -5216,13 +5392,13 @@ ClangASTType::GetDeclContextForType () const case clang::Type::MemberPointer: break; case clang::Type::Complex: break; case clang::Type::ObjCObject: break; - case clang::Type::ObjCInterface: return cast<ObjCObjectType>(qual_type.getTypePtr())->getInterface(); - case clang::Type::ObjCObjectPointer: return ClangASTType (m_ast, cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()).GetDeclContextForType(); - case clang::Type::Record: return cast<RecordType>(qual_type)->getDecl(); - case clang::Type::Enum: return cast<EnumType>(qual_type)->getDecl(); - case clang::Type::Typedef: return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDeclContextForType(); - case clang::Type::Elaborated: return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).GetDeclContextForType(); - case clang::Type::Paren: return ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).GetDeclContextForType(); + case clang::Type::ObjCInterface: return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())->getInterface(); + case clang::Type::ObjCObjectPointer: return ClangASTType (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()).GetDeclContextForType(); + case clang::Type::Record: return llvm::cast<clang::RecordType>(qual_type)->getDecl(); + case clang::Type::Enum: return llvm::cast<clang::EnumType>(qual_type)->getDecl(); + case clang::Type::Typedef: return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDeclContextForType(); + case clang::Type::Elaborated: return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetDeclContextForType(); + case clang::Type::Paren: return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetDeclContextForType(); case clang::Type::TypeOfExpr: break; case clang::Type::TypeOf: break; case clang::Type::Decltype: break; @@ -5239,12 +5415,13 @@ ClangASTType::GetDeclContextForType () const case clang::Type::InjectedClassName: break; case clang::Type::DependentName: break; case clang::Type::Atomic: break; + case clang::Type::Adjusted: break; // pointer type decayed from an array or function type. case clang::Type::Decayed: break; } // No DeclContext in this type... - return NULL; + return nullptr; } bool @@ -5254,18 +5431,18 @@ ClangASTType::SetDefaultAccessForRecordFields (int default_accessibility, { if (IsValid()) { - RecordDecl *record_decl = GetAsRecordDecl(); + clang::RecordDecl *record_decl = GetAsRecordDecl(); if (record_decl) { uint32_t field_idx; - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0; field != field_end; ++field, ++field_idx) { // If no accessibility was assigned, assign the correct one if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none) - field->setAccess ((AccessSpecifier)default_accessibility); + field->setAccess ((clang::AccessSpecifier)default_accessibility); } return true; } @@ -5280,14 +5457,14 @@ ClangASTType::SetHasExternalStorage (bool has_extern) if (!IsValid()) return false; - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: { - CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { cxx_record_decl->setHasExternalLexicalStorage (has_extern); @@ -5299,7 +5476,7 @@ ClangASTType::SetHasExternalStorage (bool has_extern) case clang::Type::Enum: { - EnumDecl *enum_decl = cast<EnumType>(qual_type)->getDecl(); + clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl(); if (enum_decl) { enum_decl->setHasExternalLexicalStorage (has_extern); @@ -5312,11 +5489,11 @@ ClangASTType::SetHasExternalStorage (bool has_extern) case clang::Type::ObjCObject: case clang::Type::ObjCInterface: { - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { @@ -5329,13 +5506,13 @@ ClangASTType::SetHasExternalStorage (bool has_extern) break; case clang::Type::Typedef: - return ClangASTType (m_ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType()).SetHasExternalStorage (has_extern); + return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).SetHasExternalStorage (has_extern); case clang::Type::Elaborated: - return ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).SetHasExternalStorage (has_extern); + return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).SetHasExternalStorage (has_extern); case clang::Type::Paren: - return ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).SetHasExternalStorage (has_extern); + return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).SetHasExternalStorage (has_extern); default: break; @@ -5348,17 +5525,17 @@ ClangASTType::SetTagTypeKind (int kind) const { if (IsValid()) { - QualType tag_qual_type(GetQualType()); + clang::QualType tag_qual_type(GetQualType()); const clang::Type *clang_type = tag_qual_type.getTypePtr(); if (clang_type) { - const TagType *tag_type = dyn_cast<TagType>(clang_type); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(clang_type); if (tag_type) { - TagDecl *tag_decl = dyn_cast<TagDecl>(tag_type->getDecl()); + clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(tag_type->getDecl()); if (tag_decl) { - tag_decl->setTagKind ((TagDecl::TagKind)kind); + tag_decl->setTagKind ((clang::TagDecl::TagKind)kind); return true; } } @@ -5375,14 +5552,14 @@ ClangASTType::StartTagDeclarationDefinition () { if (IsValid()) { - QualType qual_type (GetQualType()); + clang::QualType qual_type (GetQualType()); const clang::Type *t = qual_type.getTypePtr(); if (t) { - const TagType *tag_type = dyn_cast<TagType>(t); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(t); if (tag_type) { - TagDecl *tag_decl = tag_type->getDecl(); + clang::TagDecl *tag_decl = tag_type->getDecl(); if (tag_decl) { tag_decl->startDefinition(); @@ -5390,10 +5567,10 @@ ClangASTType::StartTagDeclarationDefinition () } } - const ObjCObjectType *object_type = dyn_cast<ObjCObjectType>(t); + const clang::ObjCObjectType *object_type = llvm::dyn_cast<clang::ObjCObjectType>(t); if (object_type) { - ObjCInterfaceDecl *interface_decl = object_type->getInterface(); + clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface(); if (interface_decl) { interface_decl->startDefinition(); @@ -5410,9 +5587,9 @@ ClangASTType::CompleteTagDeclarationDefinition () { if (IsValid()) { - QualType qual_type (GetQualType()); + clang::QualType qual_type (GetQualType()); - CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (cxx_record_decl) { @@ -5421,11 +5598,11 @@ ClangASTType::CompleteTagDeclarationDefinition () return true; } - const EnumType *enum_type = dyn_cast<EnumType>(qual_type.getTypePtr()); + const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(qual_type.getTypePtr()); if (enum_type) { - EnumDecl *enum_decl = enum_type->getDecl(); + clang::EnumDecl *enum_decl = enum_type->getDecl(); if (enum_decl) { @@ -5434,7 +5611,7 @@ ClangASTType::CompleteTagDeclarationDefinition () unsigned NumPositiveBits = 1; unsigned NumNegativeBits = 0; - QualType promotion_qual_type; + clang::QualType promotion_qual_type; // If the enum integer type is less than an integer in bit width, // then we must promote it to an integer size. if (m_ast->getTypeSize(enum_decl->getIntegerType()) < m_ast->getTypeSize(m_ast->IntTy)) @@ -5470,27 +5647,27 @@ ClangASTType::AddEnumerationValueToEnumerationType (const ClangASTType &enumerat { if (IsValid() && enumerator_clang_type.IsValid() && name && name[0]) { - QualType enum_qual_type (GetCanonicalQualType()); + clang::QualType enum_qual_type (GetCanonicalQualType()); bool is_signed = false; enumerator_clang_type.IsIntegerType (is_signed); const clang::Type *clang_type = enum_qual_type.getTypePtr(); if (clang_type) { - const EnumType *enum_type = dyn_cast<EnumType>(clang_type); + const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(clang_type); if (enum_type) { llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed); enum_llvm_apsint = enum_value; - EnumConstantDecl *enumerator_decl = - EnumConstantDecl::Create (*m_ast, - enum_type->getDecl(), - SourceLocation(), - name ? &m_ast->Idents.get(name) : NULL, // Identifier - enumerator_clang_type.GetQualType(), - NULL, - enum_llvm_apsint); + clang::EnumConstantDecl *enumerator_decl = + clang::EnumConstantDecl::Create (*m_ast, + enum_type->getDecl(), + clang::SourceLocation(), + name ? &m_ast->Idents.get(name) : nullptr, // Identifier + enumerator_clang_type.GetQualType(), + nullptr, + enum_llvm_apsint); if (enumerator_decl) { @@ -5512,14 +5689,14 @@ ClangASTType::AddEnumerationValueToEnumerationType (const ClangASTType &enumerat ClangASTType ClangASTType::GetEnumerationIntegerType () const { - QualType enum_qual_type (GetCanonicalQualType()); + clang::QualType enum_qual_type (GetCanonicalQualType()); const clang::Type *clang_type = enum_qual_type.getTypePtr(); if (clang_type) { - const EnumType *enum_type = dyn_cast<EnumType>(clang_type); + const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(clang_type); if (enum_type) { - EnumDecl *enum_decl = enum_type->getDecl(); + clang::EnumDecl *enum_decl = enum_type->getDecl(); if (enum_decl) return ClangASTType (m_ast, enum_decl->getIntegerType()); } @@ -5544,7 +5721,7 @@ ClangASTType::ConvertStringToFloatValue (const char *s, uint8_t *dst, size_t dst { if (IsValid()) { - QualType qual_type (GetCanonicalQualType()); + clang::QualType qual_type (GetCanonicalQualType()); uint32_t count = 0; bool is_complex = false; if (IsFloatingPointType (count, is_complex)) @@ -5553,8 +5730,8 @@ ClangASTType::ConvertStringToFloatValue (const char *s, uint8_t *dst, size_t dst if (count != 1) return false; - StringRef s_sref(s); - APFloat ap_float(m_ast->getFloatTypeSemantics(qual_type), s_sref); + llvm::StringRef s_sref(s); + llvm::APFloat ap_float(m_ast->getFloatTypeSemantics(qual_type), s_sref); const uint64_t bit_size = m_ast->getTypeSize (qual_type); const uint64_t byte_size = bit_size / 8; @@ -5602,30 +5779,30 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, if (!IsValid()) return; - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); switch (qual_type->getTypeClass()) { case clang::Type::Record: if (GetCompleteType ()) { - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); uint32_t field_bit_offset = 0; uint32_t field_byte_offset = 0; - const ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); + const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl); uint32_t child_idx = 0; - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) { // We might have base classes to print out first - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); base_class != base_class_end; ++base_class) { - const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl()); + const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl()); // Skip empty base classes if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false) @@ -5642,13 +5819,13 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, else s->PutChar(','); - QualType base_class_qual_type = base_class->getType(); + clang::QualType base_class_qual_type = base_class->getType(); std::string base_class_type_name(base_class_qual_type.getAsString()); // Indent and print the base class type name s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str()); - std::pair<uint64_t, unsigned> base_class_type_info = m_ast->getTypeInfo(base_class_qual_type); + clang::TypeInfo base_class_type_info = m_ast->getTypeInfo(base_class_qual_type); // Dump the value of the member ClangASTType base_clang_type(m_ast, base_class_qual_type); @@ -5657,7 +5834,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, base_clang_type.GetFormat(), // The format with which to display the member data, // Data buffer containing all bytes for this type data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from - base_class_type_info.first / 8, // Size of this type in bytes + base_class_type_info.Width / 8, // Size of this type in bytes 0, // Bitfield bit size 0, // Bitfield bit offset show_types, // Boolean indicating if we should show the variable types @@ -5669,7 +5846,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, } } uint32_t field_idx = 0; - RecordDecl::field_iterator field, field_end; + clang::RecordDecl::field_iterator field, field_end; for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx) { // Print the starting squiggly bracket (if this is the @@ -5683,11 +5860,11 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, // Indent s->Printf("\n%*s", depth + DEPTH_INCREMENT, ""); - QualType field_type = field->getType(); + clang::QualType field_type = field->getType(); // Print the member type if requested // Figure out the type byte size (field_type_info.first) and // alignment (field_type_info.second) from the AST context. - std::pair<uint64_t, unsigned> field_type_info = m_ast->getTypeInfo(field_type); + clang::TypeInfo field_type_info = m_ast->getTypeInfo(field_type); assert(field_idx < record_layout.getFieldCount()); // Figure out the field offset within the current struct/union/class type field_bit_offset = record_layout.getFieldOffset (field_idx); @@ -5716,7 +5893,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, field_clang_type.GetFormat(), // The format with which to display the member data, // Data buffer containing all bytes for this type data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from - field_type_info.first / 8, // Size of this type in bytes + field_type_info.Width / 8, // Size of this type in bytes field_bitfield_bit_size, // Bitfield bit size field_bitfield_bit_offset, // Bitfield bit offset show_types, // Boolean indicating if we should show the variable types @@ -5734,10 +5911,10 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, case clang::Type::Enum: if (GetCompleteType ()) { - const EnumType *enum_type = cast<EnumType>(qual_type.getTypePtr()); - const EnumDecl *enum_decl = enum_type->getDecl(); + const clang::EnumType *enum_type = llvm::cast<clang::EnumType>(qual_type.getTypePtr()); + const clang::EnumDecl *enum_decl = enum_type->getDecl(); assert(enum_decl); - EnumDecl::enumerator_iterator enum_pos, enum_end_pos; + clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; lldb::offset_t offset = data_byte_offset; const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset); for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) @@ -5756,9 +5933,9 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, case clang::Type::ConstantArray: { - const ConstantArrayType *array = cast<ConstantArrayType>(qual_type.getTypePtr()); + const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr()); bool is_array_of_characters = false; - QualType element_qual_type = array->getElementType(); + clang::QualType element_qual_type = array->getElementType(); const clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr(); if (canonical_type) @@ -5766,11 +5943,11 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, const uint64_t element_count = array->getSize().getLimitedValue(); - std::pair<uint64_t, unsigned> field_type_info = m_ast->getTypeInfo(element_qual_type); + clang::TypeInfo field_type_info = m_ast->getTypeInfo(element_qual_type); uint32_t element_idx = 0; uint32_t element_offset = 0; - uint64_t element_byte_size = field_type_info.first / 8; + uint64_t element_byte_size = field_type_info.Width / 8; uint32_t element_stride = element_byte_size; if (is_array_of_characters) @@ -5825,12 +6002,12 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, case clang::Type::Typedef: { - QualType typedef_qual_type = cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType(); + clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(); ClangASTType typedef_clang_type (m_ast, typedef_qual_type); lldb::Format typedef_format = typedef_clang_type.GetFormat(); - std::pair<uint64_t, unsigned> typedef_type_info = m_ast->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.first / 8; + clang::TypeInfo typedef_type_info = m_ast->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.Width / 8; return typedef_clang_type.DumpValue (exe_ctx, s, // Stream to dump to @@ -5849,11 +6026,11 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, case clang::Type::Elaborated: { - QualType elaborated_qual_type = cast<ElaboratedType>(qual_type)->getNamedType(); + clang::QualType elaborated_qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(); ClangASTType elaborated_clang_type (m_ast, elaborated_qual_type); lldb::Format elaborated_format = elaborated_clang_type.GetFormat(); - std::pair<uint64_t, unsigned> elaborated_type_info = m_ast->getTypeInfo(elaborated_qual_type); - uint64_t elaborated_byte_size = elaborated_type_info.first / 8; + clang::TypeInfo elaborated_type_info = m_ast->getTypeInfo(elaborated_qual_type); + uint64_t elaborated_byte_size = elaborated_type_info.Width / 8; return elaborated_clang_type.DumpValue (exe_ctx, s, // Stream to dump to @@ -5872,12 +6049,12 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx, case clang::Type::Paren: { - QualType desugar_qual_type = cast<ParenType>(qual_type)->desugar(); + clang::QualType desugar_qual_type = llvm::cast<clang::ParenType>(qual_type)->desugar(); ClangASTType desugar_clang_type (m_ast, desugar_qual_type); lldb::Format desugar_format = desugar_clang_type.GetFormat(); - std::pair<uint64_t, unsigned> desugar_type_info = m_ast->getTypeInfo(desugar_qual_type); - uint64_t desugar_byte_size = desugar_type_info.first / 8; + clang::TypeInfo desugar_type_info = m_ast->getTypeInfo(desugar_qual_type); + uint64_t desugar_byte_size = desugar_type_info.Width / 8; return desugar_clang_type.DumpValue (exe_ctx, s, // Stream to dump to @@ -5933,19 +6110,19 @@ ClangASTType::DumpTypeValue (Stream *s, } else { - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Typedef: { - QualType typedef_qual_type = cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType(); + clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(); ClangASTType typedef_clang_type (m_ast, typedef_qual_type); if (format == eFormatDefault) format = typedef_clang_type.GetFormat(); - std::pair<uint64_t, unsigned> typedef_type_info = m_ast->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.first / 8; + clang::TypeInfo typedef_type_info = m_ast->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.Width / 8; return typedef_clang_type.DumpTypeValue (s, format, // The format with which to display the element @@ -5963,10 +6140,10 @@ ClangASTType::DumpTypeValue (Stream *s, // its enumeration string value, else just display it as requested. if ((format == eFormatEnum || format == eFormatDefault) && GetCompleteType ()) { - const EnumType *enum_type = cast<EnumType>(qual_type.getTypePtr()); - const EnumDecl *enum_decl = enum_type->getDecl(); + const clang::EnumType *enum_type = llvm::cast<clang::EnumType>(qual_type.getTypePtr()); + const clang::EnumDecl *enum_decl = enum_type->getDecl(); assert(enum_decl); - EnumDecl::enumerator_iterator enum_pos, enum_end_pos; + clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; const bool is_signed = qual_type->isSignedIntegerOrEnumerationType(); lldb::offset_t offset = byte_offset; if (is_signed) @@ -6093,7 +6270,7 @@ ClangASTType::DumpSummary (ExecutionContext *exe_ctx, if (process) { lldb::offset_t offset = data_byte_offset; - lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size); + lldb::addr_t pointer_address = data.GetMaxU64(&offset, data_byte_size); std::vector<uint8_t> buf; if (length > 0) buf.resize (length); @@ -6105,7 +6282,7 @@ ClangASTType::DumpSummary (ExecutionContext *exe_ctx, size_t bytes_read; size_t total_cstr_len = 0; Error error; - while ((bytes_read = process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) + while ((bytes_read = process->ReadMemory (pointer_address, &buf.front(), buf.size(), error)) > 0) { const size_t len = strlen((const char *)&buf.front()); if (len == 0) @@ -6116,7 +6293,7 @@ ClangASTType::DumpSummary (ExecutionContext *exe_ctx, total_cstr_len += len; if (len < buf.size()) break; - pointer_addresss += total_cstr_len; + pointer_address += total_cstr_len; } if (total_cstr_len > 0) s->PutChar ('"'); @@ -6142,10 +6319,10 @@ ClangASTType::DumpTypeDescription (Stream *s) const { if (IsValid()) { - QualType qual_type(GetQualType()); + clang::QualType qual_type(GetQualType()); - SmallVector<char, 1024> buf; - raw_svector_ostream llvm_ostrm (buf); + llvm::SmallVector<char, 1024> buf; + llvm::raw_svector_ostream llvm_ostrm (buf); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) @@ -6155,14 +6332,14 @@ ClangASTType::DumpTypeDescription (Stream *s) const { GetCompleteType (); - const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { - ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) { - PrintingPolicy policy = m_ast->getPrintingPolicy(); + clang::PrintingPolicy policy = m_ast->getPrintingPolicy(); class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel()); } } @@ -6171,10 +6348,10 @@ ClangASTType::DumpTypeDescription (Stream *s) const case clang::Type::Typedef: { - const TypedefType *typedef_type = qual_type->getAs<TypedefType>(); + const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>(); if (typedef_type) { - const TypedefNameDecl *typedef_decl = typedef_type->getDecl(); + const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString()); if (!clang_typedef_name.empty()) { @@ -6186,20 +6363,20 @@ ClangASTType::DumpTypeDescription (Stream *s) const break; case clang::Type::Elaborated: - ClangASTType (m_ast, cast<ElaboratedType>(qual_type)->getNamedType()).DumpTypeDescription(s); + ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).DumpTypeDescription(s); return; case clang::Type::Paren: - ClangASTType (m_ast, cast<ParenType>(qual_type)->desugar()).DumpTypeDescription(s); + ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).DumpTypeDescription(s); return; case clang::Type::Record: { GetCompleteType (); - const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr()); - const RecordDecl *record_decl = record_type->getDecl(); - const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl); + const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) cxx_record_decl->print(llvm_ostrm, m_ast->getPrintingPolicy(), s->GetIndentLevel()); @@ -6210,10 +6387,10 @@ ClangASTType::DumpTypeDescription (Stream *s) const default: { - const TagType *tag_type = dyn_cast<TagType>(qual_type.getTypePtr()); + const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()); if (tag_type) { - TagDecl *tag_decl = tag_type->getDecl(); + clang::TagDecl *tag_decl = tag_type->getDecl(); if (tag_decl) tag_decl->print(llvm_ostrm, 0); } @@ -6471,19 +6648,19 @@ ClangASTType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx, } uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size); - if (dst != NULL) + if (dst != nullptr) { if (address_type == eAddressTypeHost) { if (addr == 0) return false; // The address is an address in this process, so just copy it - memcpy (dst, (uint8_t*)NULL + addr, byte_size); + memcpy (dst, (uint8_t*)nullptr + addr, byte_size); return true; } else { - Process *process = NULL; + Process *process = nullptr; if (exe_ctx) process = exe_ctx->GetProcessPtr(); if (process) @@ -6525,7 +6702,7 @@ ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx, } else { - Process *process = NULL; + Process *process = nullptr; if (exe_ctx) process = exe_ctx->GetProcessPtr(); if (process) @@ -6539,11 +6716,11 @@ ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx, } -//CXXRecordDecl * +//clang::CXXRecordDecl * //ClangASTType::GetAsCXXRecordDecl (lldb::clang_type_t opaque_clang_qual_type) //{ // if (opaque_clang_qual_type) -// return QualType::getFromOpaquePtr(opaque_clang_qual_type)->getAsCXXRecordDecl(); +// return clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)->getAsCXXRecordDecl(); // return NULL; //} @@ -6561,3 +6738,4 @@ lldb_private::operator != (const lldb_private::ClangASTType &lhs, const lldb_pri } + diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp index b2328d6..bdc3265 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Clang headers like to use NDEBUG inside of them to enable/disable debug -// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing +// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing // or another. This is bad because it means that if clang was built in release // mode, it assumes that you are building in release mode which is not always // the case. You can end up with functions that are defined as empty in header diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp index 697dc7e..650d252 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -36,7 +36,7 @@ ClangExternalASTSourceCommon::GetMetadata (const void *object) if (HasMetadata (object)) return &m_metadata[object]; else - return NULL; + return nullptr; } void diff --git a/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp b/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp index 62ae1cc..f99ca53 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp @@ -99,11 +99,11 @@ CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const void CompileUnit::Dump(Stream *s, bool show_context) const { - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<const void*>(this)); s->Indent(); - *s << "CompileUnit" << (const UserID&)*this - << ", language = \"" << (const Language&)*this - << "\", file = '" << (const FileSpec&)*this << "'\n"; + *s << "CompileUnit" << static_cast<const UserID&>(*this) + << ", language = \"" << reinterpret_cast<const Language&>(*this) + << "\", file = '" << static_cast<const FileSpec&>(*this) << "'\n"; // m_types.Dump(s); @@ -237,7 +237,7 @@ CompileUnit::GetLanguage() LineTable* CompileUnit::GetLineTable() { - if (m_line_table_ap.get() == NULL) + if (m_line_table_ap.get() == nullptr) { if (m_flags.IsClear(flagsParsedLineTable)) { @@ -257,7 +257,7 @@ CompileUnit::GetLineTable() void CompileUnit::SetLineTable(LineTable* line_table) { - if (line_table == NULL) + if (line_table == nullptr) m_flags.Clear(flagsParsedLineTable); else m_flags.Set(flagsParsedLineTable); @@ -267,7 +267,7 @@ CompileUnit::SetLineTable(LineTable* line_table) VariableListSP CompileUnit::GetVariableList(bool can_create) { - if (m_variables.get() == NULL && can_create) + if (m_variables.get() == nullptr && can_create) { SymbolContext sc; CalculateSymbolContext(&sc); @@ -353,7 +353,7 @@ CompileUnit::ResolveSymbolContext { LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table != NULL) + if (line_table != nullptr) { uint32_t found_line; uint32_t line_idx; diff --git a/contrib/llvm/tools/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/contrib/llvm/tools/lldb/source/Symbol/DWARFCallFrameInfo.cpp index d3d9628..a9da631 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -55,7 +55,7 @@ DWARFCallFrameInfo::GetUnwindPlan (Address addr, UnwindPlan& unwind_plan) // Make sure that the Address we're searching for is the same object file // as this DWARFCallFrameInfo, we only store File offsets in m_fde_index. ModuleSP module_sp = addr.GetModule(); - if (module_sp.get() == NULL || module_sp->GetObjectFile() == NULL || module_sp->GetObjectFile() != &m_objfile) + if (module_sp.get() == nullptr || module_sp->GetObjectFile() == nullptr || module_sp->GetObjectFile() != &m_objfile) return false; if (GetFDEEntryByFileAddress (addr.GetFileAddress(), fde_entry) == false) @@ -70,10 +70,10 @@ DWARFCallFrameInfo::GetAddressRange (Address addr, AddressRange &range) // Make sure that the Address we're searching for is the same object file // as this DWARFCallFrameInfo, we only store File offsets in m_fde_index. ModuleSP module_sp = addr.GetModule(); - if (module_sp.get() == NULL || module_sp->GetObjectFile() == NULL || module_sp->GetObjectFile() != &m_objfile) + if (module_sp.get() == nullptr || module_sp->GetObjectFile() == nullptr || module_sp->GetObjectFile() != &m_objfile) return false; - if (m_section_sp.get() == NULL || m_section_sp->IsEncrypted()) + if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted()) return false; GetFDEIndex(); FDEEntryMap::Entry *fde_entry = m_fde_index.FindEntryThatContains (addr.GetFileAddress()); @@ -87,7 +87,7 @@ DWARFCallFrameInfo::GetAddressRange (Address addr, AddressRange &range) bool DWARFCallFrameInfo::GetFDEEntryByFileAddress (addr_t file_addr, FDEEntryMap::Entry &fde_entry) { - if (m_section_sp.get() == NULL || m_section_sp->IsEncrypted()) + if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted()) return false; GetFDEIndex(); @@ -97,7 +97,7 @@ DWARFCallFrameInfo::GetFDEEntryByFileAddress (addr_t file_addr, FDEEntryMap::Ent FDEEntryMap::Entry *fde = m_fde_index.FindEntryThatContains (file_addr); - if (fde == NULL) + if (fde == nullptr) return false; fde_entry = *fde; @@ -131,12 +131,12 @@ DWARFCallFrameInfo::GetCIE(dw_offset_t cie_offset) if (pos != m_cie_map.end()) { // Parse and cache the CIE - if (pos->second.get() == NULL) + if (pos->second.get() == nullptr) pos->second = ParseCIE (cie_offset); return pos->second.get(); } - return NULL; + return nullptr; } DWARFCallFrameInfo::CIESP @@ -146,9 +146,17 @@ DWARFCallFrameInfo::ParseCIE (const dw_offset_t cie_offset) lldb::offset_t offset = cie_offset; if (m_cfi_data_initialized == false) GetCFIData(); - const uint32_t length = m_cfi_data.GetU32(&offset); - const dw_offset_t cie_id = m_cfi_data.GetU32(&offset); - const dw_offset_t end_offset = cie_offset + length + 4; + uint32_t length = m_cfi_data.GetU32(&offset); + dw_offset_t cie_id, end_offset; + bool is_64bit = (length == UINT32_MAX); + if (is_64bit) { + length = m_cfi_data.GetU64(&offset); + cie_id = m_cfi_data.GetU64(&offset); + end_offset = cie_offset + length + 12; + } else { + cie_id = m_cfi_data.GetU32(&offset); + end_offset = cie_offset + length + 4; + } if (length > 0 && ((!m_is_eh_frame && cie_id == UINT32_MAX) || (m_is_eh_frame && cie_id == 0ul))) { size_t i; @@ -318,7 +326,7 @@ DWARFCallFrameInfo::GetCFIData() void DWARFCallFrameInfo::GetFDEIndex () { - if (m_section_sp.get() == NULL || m_section_sp->IsEncrypted()) + if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted()) return; if (m_fde_index_initialized) @@ -337,9 +345,19 @@ DWARFCallFrameInfo::GetFDEIndex () while (m_cfi_data.ValidOffsetForDataOfSize (offset, 8)) { const dw_offset_t current_entry = offset; + dw_offset_t cie_id, next_entry, cie_offset; uint32_t len = m_cfi_data.GetU32 (&offset); - dw_offset_t next_entry = current_entry + len + 4; - dw_offset_t cie_id = m_cfi_data.GetU32 (&offset); + bool is_64bit = (len == UINT32_MAX); + if (is_64bit) { + len = m_cfi_data.GetU64 (&offset); + cie_id = m_cfi_data.GetU64 (&offset); + next_entry = current_entry + len + 12; + cie_offset = current_entry + 12 - cie_id; + } else { + cie_id = m_cfi_data.GetU32 (&offset); + next_entry = current_entry + len + 4; + cie_offset = current_entry + 4 - cie_id; + } if (cie_id == 0 || cie_id == UINT32_MAX || len == 0) { @@ -348,7 +366,6 @@ DWARFCallFrameInfo::GetFDEIndex () continue; } - const dw_offset_t cie_offset = current_entry + 4 - cie_id; const CIE *cie = GetCIE (cie_offset); if (cie) { @@ -381,14 +398,21 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr lldb::offset_t offset = dwarf_offset; lldb::offset_t current_entry = offset; - if (m_section_sp.get() == NULL || m_section_sp->IsEncrypted()) + if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted()) return false; if (m_cfi_data_initialized == false) GetCFIData(); uint32_t length = m_cfi_data.GetU32 (&offset); - dw_offset_t cie_offset = m_cfi_data.GetU32 (&offset); + dw_offset_t cie_offset; + bool is_64bit = (length == UINT32_MAX); + if (is_64bit) { + length = m_cfi_data.GetU64 (&offset); + cie_offset = m_cfi_data.GetU64 (&offset); + } else { + cie_offset = m_cfi_data.GetU32 (&offset); + } assert (cie_offset != 0 && cie_offset != UINT32_MAX); @@ -398,7 +422,7 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr if (m_is_eh_frame) { unwind_plan.SetSourceName ("eh_frame CFI"); - cie_offset = current_entry + 4 - cie_offset; + cie_offset = current_entry + (is_64bit ? 12 : 4) - cie_offset; unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); } else @@ -413,9 +437,9 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr unwind_plan.SetSourcedFromCompiler (eLazyBoolYes); const CIE *cie = GetCIE (cie_offset); - assert (cie != NULL); + assert (cie != nullptr); - const dw_offset_t end_offset = current_entry + length + 4; + const dw_offset_t end_offset = current_entry + length + (is_64bit ? 12 : 4); const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress(); const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; diff --git a/contrib/llvm/tools/lldb/source/Symbol/FuncUnwinders.cpp b/contrib/llvm/tools/lldb/source/Symbol/FuncUnwinders.cpp index 134dbf5..95fc817 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/FuncUnwinders.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/FuncUnwinders.cpp @@ -28,13 +28,11 @@ using namespace lldb_private; FuncUnwinders::FuncUnwinders ( UnwindTable& unwind_table, - const lldb::UnwindAssemblySP& assembly_profiler, AddressRange range ) : m_unwind_table(unwind_table), - m_assembly_profiler(assembly_profiler), m_range(range), - m_mutex (Mutex::eMutexTypeNormal), + m_mutex (Mutex::eMutexTypeRecursive), m_unwind_plan_call_site_sp (), m_unwind_plan_non_call_site_sp (), m_unwind_plan_fast_sp (), @@ -68,7 +66,7 @@ FuncUnwinders::GetUnwindPlanAtCallSite (int current_offset) // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_call_site == false && m_unwind_plan_call_site_sp.get() == NULL) + if (m_tried_unwind_at_call_site == false && m_unwind_plan_call_site_sp.get() == nullptr) { m_tried_unwind_at_call_site = true; // We have cases (e.g. with _sigtramp on Mac OS X) where the hand-written eh_frame unwind info for a @@ -96,7 +94,7 @@ FuncUnwinders::GetUnwindPlanAtCallSite (int current_offset) } UnwindPlanSP -FuncUnwinders::GetUnwindPlanAtNonCallSite (Thread& thread) +FuncUnwinders::GetUnwindPlanAtNonCallSite (Target& target, Thread& thread, int current_offset) { // Lock the mutex to ensure we can always give out the most appropriate // information. We want to make sure if someone requests an unwind @@ -111,13 +109,29 @@ FuncUnwinders::GetUnwindPlanAtNonCallSite (Thread& thread) // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == NULL) + if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == nullptr) { - m_tried_unwind_at_non_call_site = true; - if (m_assembly_profiler) + UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler()); + if (assembly_profiler_sp) { + if (target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_32_i386 + || target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64 + || target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64h) + { + // For 0th frame on i386 & x86_64, we fetch eh_frame and try using assembly profiler + // to augment it into asynchronous unwind table. + GetUnwindPlanAtCallSite(current_offset); + if (m_unwind_plan_call_site_sp) { + UnwindPlan* plan = new UnwindPlan (*m_unwind_plan_call_site_sp); + if (assembly_profiler_sp->AugmentUnwindPlanFromCallSite (m_range, thread, *plan)) { + m_unwind_plan_non_call_site_sp.reset (plan); + return m_unwind_plan_non_call_site_sp; + } + } + } + m_unwind_plan_non_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); - if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp)) + if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp)) m_unwind_plan_non_call_site_sp.reset(); } } @@ -140,13 +154,14 @@ FuncUnwinders::GetUnwindPlanFastUnwind (Thread& thread) // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == NULL) + if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == nullptr) { m_tried_unwind_fast = true; - if (m_assembly_profiler) + UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler()); + if (assembly_profiler_sp) { m_unwind_plan_fast_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); - if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp)) + if (!assembly_profiler_sp->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp)) m_unwind_plan_fast_sp.reset(); } } @@ -169,7 +184,7 @@ FuncUnwinders::GetUnwindPlanArchitectureDefault (Thread& thread) // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_arch_default == false && m_unwind_plan_arch_default_sp.get() == NULL) + if (m_tried_unwind_arch_default == false && m_unwind_plan_arch_default_sp.get() == nullptr) { m_tried_unwind_arch_default = true; Address current_pc; @@ -205,7 +220,7 @@ FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry (Thread& thread) // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_arch_default_at_func_entry == false && m_unwind_plan_arch_default_at_func_entry_sp.get() == NULL) + if (m_tried_unwind_arch_default_at_func_entry == false && m_unwind_plan_arch_default_at_func_entry_sp.get() == nullptr) { m_tried_unwind_arch_default_at_func_entry = true; Address current_pc; @@ -232,8 +247,10 @@ FuncUnwinders::GetFirstNonPrologueInsn (Target& target) if (m_first_non_prologue_insn.IsValid()) return m_first_non_prologue_insn; ExecutionContext exe_ctx (target.shared_from_this(), false); - if (m_assembly_profiler) - m_assembly_profiler->FirstNonPrologueInsn (m_range, exe_ctx, m_first_non_prologue_insn); + UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler()); + if (assembly_profiler_sp) + if (assembly_profiler_sp) + assembly_profiler_sp->FirstNonPrologueInsn (m_range, exe_ctx, m_first_non_prologue_insn); return m_first_non_prologue_insn; } @@ -252,3 +269,15 @@ FuncUnwinders::InvalidateNonCallSiteUnwindPlan (lldb_private::Thread& thread) m_unwind_plan_call_site_sp = arch_default; } } + +lldb::UnwindAssemblySP +FuncUnwinders::GetUnwindAssemblyProfiler () +{ + UnwindAssemblySP assembly_profiler_sp; + ArchSpec arch; + if (m_unwind_table.GetArchitecture (arch)) + { + assembly_profiler_sp = UnwindAssembly::FindPlugin (arch); + } + return assembly_profiler_sp; +} diff --git a/contrib/llvm/tools/lldb/source/Symbol/Function.cpp b/contrib/llvm/tools/lldb/source/Symbol/Function.cpp index e6d6c00..0b7430a 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Function.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Function.cpp @@ -215,7 +215,7 @@ Function::Function m_prologue_byte_size (0) { m_block.SetParentScope(this); - assert(comp_unit != NULL); + assert(comp_unit != nullptr); } Function::Function @@ -239,7 +239,7 @@ Function::Function m_prologue_byte_size (0) { m_block.SetParentScope(this); - assert(comp_unit != NULL); + assert(comp_unit != nullptr); } @@ -253,10 +253,10 @@ Function::GetStartLineSourceInfo (FileSpec &source_file, uint32_t &line_no) line_no = 0; source_file.Clear(); - if (m_comp_unit == NULL) + if (m_comp_unit == nullptr) return; - if (m_type != NULL && m_type->GetDeclaration().GetLine() != 0) + if (m_type != nullptr && m_type->GetDeclaration().GetLine() != 0) { source_file = m_type->GetDeclaration().GetFile(); line_no = m_type->GetDeclaration().GetLine(); @@ -264,11 +264,11 @@ Function::GetStartLineSourceInfo (FileSpec &source_file, uint32_t &line_no) else { LineTable *line_table = m_comp_unit->GetLineTable(); - if (line_table == NULL) + if (line_table == nullptr) return; LineEntry line_entry; - if (line_table->FindLineEntryByAddress (GetAddressRange().GetBaseAddress(), line_entry, NULL)) + if (line_table->FindLineEntryByAddress (GetAddressRange().GetBaseAddress(), line_entry, nullptr)) { line_no = line_entry.line; source_file = line_entry.file; @@ -288,11 +288,11 @@ Function::GetEndLineSourceInfo (FileSpec &source_file, uint32_t &line_no) scratch_addr.SetOffset (scratch_addr.GetOffset() + GetAddressRange().GetByteSize() - 1); LineTable *line_table = m_comp_unit->GetLineTable(); - if (line_table == NULL) + if (line_table == nullptr) return; LineEntry line_entry; - if (line_table->FindLineEntryByAddress (scratch_addr, line_entry, NULL)) + if (line_table->FindLineEntryByAddress (scratch_addr, line_entry, nullptr)) { line_no = line_entry.line; source_file = line_entry.file; @@ -354,20 +354,16 @@ Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target void Function::Dump(Stream *s, bool show_context) const { - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<const void*>(this)); s->Indent(); - *s << "Function" << (const UserID&)*this; + *s << "Function" << static_cast<const UserID&>(*this); m_mangled.Dump(s); if (m_type) - { - s->Printf(", type = %p", m_type); - } + s->Printf(", type = %p", static_cast<void*>(m_type)); else if (m_type_uid != LLDB_INVALID_UID) - { s->Printf(", type_uid = 0x%8.8" PRIx64, m_type_uid); - } s->EOL(); // Dump the root object @@ -415,7 +411,7 @@ Function::GetInstructions (const ExecutionContext &exe_ctx, { const bool prefer_file_cache = false; return Disassembler::DisassembleRange (module_sp->GetArchitecture(), - NULL, + nullptr, flavor, exe_ctx, GetAddressRange(), @@ -471,17 +467,17 @@ Function::GetClangDeclContext() CalculateSymbolContext (&sc); if (!sc.module_sp) - return NULL; + return nullptr; SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); if (!sym_vendor) - return NULL; + return nullptr; SymbolFile *sym_file = sym_vendor->GetSymbolFile(); if (!sym_file) - return NULL; + return nullptr; return sym_file->GetClangDeclContextForTypeUID (sc, m_uid); } @@ -489,24 +485,24 @@ Function::GetClangDeclContext() Type* Function::GetType() { - if (m_type == NULL) + if (m_type == nullptr) { SymbolContext sc; CalculateSymbolContext (&sc); if (!sc.module_sp) - return NULL; + return nullptr; SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); - if (sym_vendor == NULL) - return NULL; + if (sym_vendor == nullptr) + return nullptr; SymbolFile *sym_file = sym_vendor->GetSymbolFile(); - if (sym_file == NULL) - return NULL; + if (sym_file == nullptr) + return nullptr; m_type = sym_file->ResolveTypeUID(m_type_uid); } diff --git a/contrib/llvm/tools/lldb/source/Symbol/LineTable.cpp b/contrib/llvm/tools/lldb/source/Symbol/LineTable.cpp index a4aa35d..4b4e33b 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/LineTable.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/LineTable.cpp @@ -93,16 +93,26 @@ LineTable::AppendLineEntryToSequence bool is_terminal_entry ) { - assert(sequence != NULL); + assert(sequence != nullptr); LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence); Entry entry(file_addr, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry); - seq->m_entries.push_back (entry); + entry_collection &entries = seq->m_entries; + // Replace the last entry if the address is the same, otherwise append it. If we have multiple + // line entries at the same address, this indicates illegal DWARF so this "fixes" the line table + // to be correct. If not fixed this can cause a line entry's address that when resolved back to + // a symbol context, could resolve to a different line entry. We really want a 1 to 1 mapping + // here to avoid these kinds of inconsistencies. We will need tor revisit this if the DWARF line + // tables are updated to allow multiple entries at the same address legally. + if (!entries.empty() && entries.back().file_addr == file_addr) + entries.back() = entry; + else + entries.push_back (entry); } void LineTable::InsertSequence (LineSequence* sequence) { - assert(sequence != NULL); + assert(sequence != nullptr); LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence); if (seq->m_entries.empty()) return; @@ -183,7 +193,7 @@ LineTable::GetLineEntryAtIndex(uint32_t idx, LineEntry& line_entry) bool LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry, uint32_t *index_ptr) { - if (index_ptr != NULL ) + if (index_ptr != nullptr ) *index_ptr = UINT32_MAX; bool success = false; @@ -247,7 +257,7 @@ LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry { uint32_t match_idx = std::distance (begin_pos, pos); success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry); - if (index_ptr != NULL && success) + if (index_ptr != nullptr && success) *index_ptr = match_idx; } } @@ -493,8 +503,8 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) LineSequenceImpl sequence; const size_t count = m_entries.size(); LineEntry line_entry; - const FileRangeMap::Entry *file_range_entry = NULL; - const FileRangeMap::Entry *prev_file_range_entry = NULL; + const FileRangeMap::Entry *file_range_entry = nullptr; + const FileRangeMap::Entry *prev_file_range_entry = nullptr; lldb::addr_t prev_file_addr = LLDB_INVALID_ADDRESS; bool prev_entry_was_linked = false; bool range_changed = false; @@ -504,7 +514,7 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) const bool end_sequence = entry.is_terminal_entry; const lldb::addr_t lookup_file_addr = entry.file_addr - (end_sequence ? 1 : 0); - if (file_range_entry == NULL || !file_range_entry->Contains(lookup_file_addr)) + if (file_range_entry == nullptr || !file_range_entry->Contains(lookup_file_addr)) { prev_file_range_entry = file_range_entry; file_range_entry = file_range_map.FindEntryThatContains(lookup_file_addr); @@ -573,13 +583,13 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) } else { - prev_entry_was_linked = file_range_entry != NULL; + prev_entry_was_linked = file_range_entry != nullptr; } prev_file_addr = entry.file_addr; range_changed = false; } if (line_table_ap->m_entries.empty()) - return NULL; + return nullptr; return line_table_ap.release(); } diff --git a/contrib/llvm/tools/lldb/source/Symbol/ObjectFile.cpp b/contrib/llvm/tools/lldb/source/Symbol/ObjectFile.cpp index ec69c9d..11b5400 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ObjectFile.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ObjectFile.cpp @@ -42,7 +42,9 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, Timer scoped_timer (__PRETTY_FUNCTION__, "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")", module_sp->GetFileSpec().GetPath().c_str(), - file, (uint64_t) file_offset, (uint64_t) file_size); + static_cast<const void*>(file), + static_cast<uint64_t>(file_offset), + static_cast<uint64_t>(file_size)); if (file) { FileSpec archive_file; @@ -57,13 +59,13 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, // first if (file_exists && module_sp->GetObjectName()) { - for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx) { std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size)); - + if (object_container_ap.get()) object_file_sp = object_container_ap->GetObjectFile(file); - + if (object_file_sp.get()) return object_file_sp; } @@ -99,13 +101,13 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, // from the container plugins since we had a name. Also, don't read // ANY data in case there is data cached in the container plug-ins // (like BSD archives caching the contained objects within an file). - for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx) { std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size)); - + if (object_container_ap.get()) object_file_sp = object_container_ap->GetObjectFile(file); - + if (object_file_sp.get()) return object_file_sp; } @@ -121,7 +123,7 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, // Check if this is a normal object file by iterating through // all object file plugin instances. ObjectFileCreateInstance create_object_file_callback; - for (uint32_t idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (uint32_t idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != nullptr; ++idx) { object_file_sp.reset (create_object_file_callback(module_sp, data_sp, data_offset, file, file_offset, file_size)); if (object_file_sp.get()) @@ -131,7 +133,7 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, // Check if this is a object container by iterating through // all object container plugin instances and then trying to get // an object file from the container. - for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx) { std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size)); @@ -157,26 +159,26 @@ ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, DataBufferSP &data_sp) { ObjectFileSP object_file_sp; - + if (module_sp) { Timer scoped_timer (__PRETTY_FUNCTION__, "ObjectFile::FindPlugin (module = %s, process = %p, header_addr = 0x%" PRIx64 ")", module_sp->GetFileSpec().GetPath().c_str(), - process_sp.get(), header_addr); + static_cast<void*>(process_sp.get()), header_addr); uint32_t idx; - + // Check if this is a normal object file by iterating through // all object file plugin instances. ObjectFileCreateMemoryInstance create_callback; - for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != NULL; ++idx) + for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != nullptr; ++idx) { object_file_sp.reset (create_callback(module_sp, data_sp, process_sp, header_addr)); if (object_file_sp.get()) return object_file_sp; } - } + // We didn't find it, so clear our shared pointer in case it // contains anything and return an empty shared pointer object_file_sp.reset(); @@ -220,14 +222,14 @@ ObjectFile::GetModuleSpecifications (const lldb_private::FileSpec& file, ObjectFileGetModuleSpecifications callback; uint32_t i; // Try the ObjectFile plug-ins - for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i) + for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != nullptr; ++i) { if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0) return specs.GetSize() - initial_count; } // Try the ObjectContainer plug-ins - for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i) + for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != nullptr; ++i) { if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0) return specs.GetSize() - initial_count; @@ -239,7 +241,7 @@ ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, - lldb::DataBufferSP& data_sp, + const lldb::DataBufferSP& data_sp, lldb::offset_t data_offset ) : ModuleChild (module_sp), @@ -261,27 +263,12 @@ ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp, m_data.SetData (data_sp, data_offset, length); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - { - if (m_file) - { - log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64, - this, - module_sp.get(), - module_sp->GetSpecificationDescription().c_str(), - m_file.GetPath().c_str(), - m_file_offset, - m_length); - } - else - { - log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = <NULL>, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64, - this, - module_sp.get(), - module_sp->GetSpecificationDescription().c_str(), - m_file_offset, - m_length); - } - } + log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64, + static_cast<void*>(this), + static_cast<void*>(module_sp.get()), + module_sp->GetSpecificationDescription().c_str(), + m_file ? m_file.GetPath().c_str() : "<NULL>", + m_file_offset, m_length); } @@ -306,14 +293,11 @@ ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp, m_data.SetData (header_data_sp, 0, header_data_sp->GetByteSize()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - { log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, header_addr = 0x%" PRIx64, - this, - module_sp.get(), + static_cast<void*>(this), + static_cast<void*>(module_sp.get()), module_sp->GetSpecificationDescription().c_str(), - process_sp.get(), - m_memory_addr); - } + static_cast<void*>(process_sp.get()), m_memory_addr); } @@ -321,7 +305,8 @@ ObjectFile::~ObjectFile() { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p ObjectFile::~ObjectFile ()\n", this); + log->Printf ("%p ObjectFile::~ObjectFile ()\n", + static_cast<void*>(this)); } bool @@ -350,9 +335,12 @@ ObjectFile::GetAddressClass (addr_t file_addr) const SectionType section_type = section_sp->GetType(); switch (section_type) { - case eSectionTypeInvalid: return eAddressClassUnknown; - case eSectionTypeCode: return eAddressClassCode; - case eSectionTypeContainer: return eAddressClassUnknown; + case eSectionTypeInvalid: + return eAddressClassUnknown; + case eSectionTypeCode: + return eAddressClassCode; + case eSectionTypeContainer: + return eAddressClassUnknown; case eSectionTypeData: case eSectionTypeDataCString: case eSectionTypeDataCStringPointers: @@ -382,16 +370,18 @@ ObjectFile::GetAddressClass (addr_t file_addr) case eSectionTypeDWARFAppleNamespaces: case eSectionTypeDWARFAppleObjC: return eAddressClassDebug; - case eSectionTypeEHFrame: return eAddressClassRuntime; + case eSectionTypeEHFrame: + return eAddressClassRuntime; case eSectionTypeELFSymbolTable: case eSectionTypeELFDynamicSymbols: case eSectionTypeELFRelocationEntries: case eSectionTypeELFDynamicLinkInfo: - case eSectionTypeOther: return eAddressClassUnknown; + case eSectionTypeOther: + return eAddressClassUnknown; } } } - + const SymbolType symbol_type = symbol->GetType(); switch (symbol_type) { @@ -449,7 +439,7 @@ ObjectFile::ReadMemory (const ProcessSP &process_sp, lldb::addr_t addr, size_t b } size_t -ObjectFile::GetData (off_t offset, size_t length, DataExtractor &data) const +ObjectFile::GetData (lldb::offset_t offset, size_t length, DataExtractor &data) const { // The entire file has already been mmap'ed into m_data, so just copy from there // as the back mmap buffer will be shared with shared pointers. @@ -457,7 +447,7 @@ ObjectFile::GetData (off_t offset, size_t length, DataExtractor &data) const } size_t -ObjectFile::CopyData (off_t offset, size_t length, void *dst) const +ObjectFile::CopyData (lldb::offset_t offset, size_t length, void *dst) const { // The entire file has already been mmap'ed into m_data, so just copy from there // Note that the data remains in target byte order. @@ -466,7 +456,7 @@ ObjectFile::CopyData (off_t offset, size_t length, void *dst) const size_t -ObjectFile::ReadSectionData (const Section *section, off_t section_offset, void *dst, size_t dst_len) const +ObjectFile::ReadSectionData (const Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) const { // If some other objectfile owns this data, pass this to them. if (section->GetObjectFile() != this) @@ -485,11 +475,11 @@ ObjectFile::ReadSectionData (const Section *section, off_t section_offset, void } else { - const uint64_t section_file_size = section->GetFileSize(); + const lldb::offset_t section_file_size = section->GetFileSize(); if (section_offset < section_file_size) { - const uint64_t section_bytes_left = section_file_size - section_offset; - uint64_t section_dst_len = dst_len; + const size_t section_bytes_left = section_file_size - section_offset; + size_t section_dst_len = dst_len; if (section_dst_len > section_bytes_left) section_dst_len = section_bytes_left; return CopyData (section->GetFileOffset() + section_offset, section_dst_len, dst); @@ -601,11 +591,9 @@ ObjectFile::ClearSymtab () lldb_private::Mutex::Locker locker(module_sp->GetMutex()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - { log->Printf ("%p ObjectFile::ClearSymtab () symtab = %p", - this, - m_symtab_ap.get()); - } + static_cast<void*>(this), + static_cast<void*>(m_symtab_ap.get())); m_symtab_ap.reset(); } } @@ -613,11 +601,14 @@ ObjectFile::ClearSymtab () SectionList * ObjectFile::GetSectionList() { - if (m_sections_ap.get() == NULL) + if (m_sections_ap.get() == nullptr) { ModuleSP module_sp(GetModule()); if (module_sp) + { + lldb_private::Mutex::Locker locker(module_sp->GetMutex()); CreateSections(*module_sp->GetUnifiedSectionList()); + } } return m_sections_ap.get(); } diff --git a/contrib/llvm/tools/lldb/source/Symbol/Symbol.cpp b/contrib/llvm/tools/lldb/source/Symbol/Symbol.cpp index 6311a32..8805199 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Symbol.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Symbol.cpp @@ -174,7 +174,7 @@ Symbol::Clear() bool Symbol::ValueIsAddress() const { - return m_addr_range.GetBaseAddress().GetSection().get() != NULL; + return m_addr_range.GetBaseAddress().GetSection().get() != nullptr; } ConstString @@ -312,7 +312,7 @@ Symbol::Dump(Stream *s, Target *target, uint32_t index) const if (ValueIsAddress()) { - if (!m_addr_range.GetBaseAddress().Dump(s, NULL, Address::DumpStyleFileAddress)) + if (!m_addr_range.GetBaseAddress().Dump(s, nullptr, Address::DumpStyleFileAddress)) s->Printf("%*s", 18, ""); s->PutChar(' '); @@ -536,49 +536,129 @@ Symbol::GetByteSize () const return m_addr_range.GetByteSize(); } + Symbol * -Symbol::ResolveReExportedSymbol (Target &target) +Symbol::ResolveReExportedSymbolInModuleSpec (Target &target, + ConstString &reexport_name, + ModuleSpec &module_spec, + ModuleList &seen_modules) const { - ConstString reexport_name (GetReExportedSymbolName()); - if (reexport_name) + ModuleSP module_sp; + if (module_spec.GetFileSpec()) { - ModuleSpec module_spec; - ModuleSP module_sp; - module_spec.GetFileSpec() = GetReExportedSymbolSharedLibrary(); - if (module_spec.GetFileSpec()) + // Try searching for the module file spec first using the full path + module_sp = target.GetImages().FindFirstModule(module_spec); + if (!module_sp) { - // Try searching for the module file spec first using the full path + // Next try and find the module by basename in case environment + // variables or other runtime trickery causes shared libraries + // to be loaded from alternate paths + module_spec.GetFileSpec().GetDirectory().Clear(); module_sp = target.GetImages().FindFirstModule(module_spec); - if (!module_sp) - { - // Next try and find the module by basename in case environment - // variables or other runtime trickery causes shared libraries - // to be loaded from alternate paths - module_spec.GetFileSpec().GetDirectory().Clear(); - module_sp = target.GetImages().FindFirstModule(module_spec); - } } + } + + if (module_sp) + { + // There should not be cycles in the reexport list, but we don't want to crash if there are so make sure + // we haven't seen this before: + if (!seen_modules.AppendIfNeeded(module_sp)) + return nullptr; - if (module_sp) + lldb_private::SymbolContextList sc_list; + module_sp->FindSymbolsWithNameAndType(reexport_name, eSymbolTypeAny, sc_list); + const size_t num_scs = sc_list.GetSize(); + if (num_scs > 0) { - lldb_private::SymbolContextList sc_list; - module_sp->FindSymbolsWithNameAndType(reexport_name, eSymbolTypeAny, sc_list); - const size_t num_scs = sc_list.GetSize(); - if (num_scs > 0) + for (size_t i=0; i<num_scs; ++i) { - for (size_t i=0; i<num_scs; ++i) + lldb_private::SymbolContext sc; + if (sc_list.GetContextAtIndex(i, sc)) { - lldb_private::SymbolContext sc; - if (sc_list.GetContextAtIndex(i, sc)) - { - if (sc.symbol->IsExternal()) - return sc.symbol; - } + if (sc.symbol->IsExternal()) + return sc.symbol; } } } + // If we didn't find the symbol in this module, it may be because this module re-exports some + // whole other library. We have to search those as well: + seen_modules.Append(module_sp); + + FileSpecList reexported_libraries = module_sp->GetObjectFile()->GetReExportedLibraries(); + size_t num_reexported_libraries = reexported_libraries.GetSize(); + for (size_t idx = 0; idx < num_reexported_libraries; idx++) + { + ModuleSpec reexported_module_spec; + reexported_module_spec.GetFileSpec() = reexported_libraries.GetFileSpecAtIndex(idx); + Symbol *result_symbol = ResolveReExportedSymbolInModuleSpec(target, + reexport_name, + reexported_module_spec, + seen_modules); + if (result_symbol) + return result_symbol; + } + } + return nullptr; +} + +Symbol * +Symbol::ResolveReExportedSymbol (Target &target) const +{ + ConstString reexport_name (GetReExportedSymbolName()); + if (reexport_name) + { + ModuleSpec module_spec; + ModuleList seen_modules; + module_spec.GetFileSpec() = GetReExportedSymbolSharedLibrary(); + if (module_spec.GetFileSpec()) + { + return ResolveReExportedSymbolInModuleSpec(target, reexport_name, module_spec, seen_modules); + } + } + return nullptr; +} + +lldb::addr_t +Symbol::ResolveCallableAddress(Target &target) const +{ + if (GetType() == lldb::eSymbolTypeUndefined) + return LLDB_INVALID_ADDRESS; + + Address func_so_addr; + + bool is_indirect; + if (GetType() == eSymbolTypeReExported) + { + Symbol *reexported_symbol = ResolveReExportedSymbol(target); + if (reexported_symbol) + { + func_so_addr = reexported_symbol->GetAddress(); + is_indirect = reexported_symbol->IsIndirect(); + } } - return NULL; + else + { + func_so_addr = GetAddress(); + is_indirect = IsIndirect(); + } + + if (func_so_addr.IsValid()) + { + if (!target.GetProcessSP() && is_indirect) + { + // can't resolve indirect symbols without calling a function... + return LLDB_INVALID_ADDRESS; + } + + lldb::addr_t load_addr = func_so_addr.GetCallableLoadAddress (&target, is_indirect); + + if (load_addr != LLDB_INVALID_ADDRESS) + { + return load_addr; + } + } + + return LLDB_INVALID_ADDRESS; } @@ -592,7 +672,7 @@ Symbol::GetInstructions (const ExecutionContext &exe_ctx, { const bool prefer_file_cache = false; return Disassembler::DisassembleRange (module_sp->GetArchitecture(), - NULL, + nullptr, flavor, exe_ctx, m_addr_range, diff --git a/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp index f1e581f..0e390dd 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp @@ -29,11 +29,11 @@ using namespace lldb_private; SymbolContext::SymbolContext() : target_sp (), module_sp (), - comp_unit (NULL), - function (NULL), - block (NULL), + comp_unit (nullptr), + function (nullptr), + block (nullptr), line_entry (), - symbol (NULL) + symbol (nullptr) { } @@ -78,11 +78,11 @@ SymbolContext::SymbolContext(const SymbolContext& rhs) : SymbolContext::SymbolContext (SymbolContextScope *sc_scope) : target_sp (), module_sp (), - comp_unit (NULL), - function (NULL), - block (NULL), + comp_unit (nullptr), + function (nullptr), + block (nullptr), line_entry (), - symbol (NULL) + symbol (nullptr) { sc_scope->CalculateSymbolContext (this); } @@ -113,11 +113,11 @@ SymbolContext::Clear(bool clear_target) if (clear_target) target_sp.reset(); module_sp.reset(); - comp_unit = NULL; - function = NULL; - block = NULL; + comp_unit = nullptr; + function = nullptr; + block = nullptr; line_entry.Clear(); - symbol = NULL; + symbol = nullptr; } bool @@ -142,7 +142,7 @@ SymbolContext::DumpStopContext dumped_something = true; } - if (function != NULL) + if (function != nullptr) { SymbolContext inline_parent_sc; Address inline_parent_addr; @@ -202,7 +202,7 @@ SymbolContext::DumpStopContext } } } - else if (symbol != NULL) + else if (symbol != nullptr) { if (symbol->GetMangled().GetName()) { @@ -243,14 +243,14 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *t s->EOL(); } - if (comp_unit != NULL) + if (comp_unit != nullptr) { s->Indent("CompileUnit: "); comp_unit->GetDescription (s, level); s->EOL(); } - if (function != NULL) + if (function != nullptr) { s->Indent(" Function: "); function->GetDescription (s, level, target); @@ -265,7 +265,7 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *t } } - if (block != NULL) + if (block != nullptr) { std::vector<Block *> blocks; blocks.push_back (block); @@ -297,7 +297,7 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *t s->EOL(); } - if (symbol != NULL) + if (symbol != nullptr) { s->Indent(" Symbol: "); symbol->GetDescription(s, level, target); @@ -335,12 +335,12 @@ SymbolContext::Dump(Stream *s, Target *target) const s->EOL(); s->Indent(); *s << "CompileUnit = " << (void *)comp_unit; - if (comp_unit != NULL) + if (comp_unit != nullptr) *s << " {0x" << comp_unit->GetID() << "} " << *(static_cast<FileSpec*> (comp_unit)); s->EOL(); s->Indent(); *s << "Function = " << (void *)function; - if (function != NULL) + if (function != nullptr) { *s << " {0x" << function->GetID() << "} " << function->GetType()->GetName() << ", address-range = "; function->GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); @@ -356,7 +356,7 @@ SymbolContext::Dump(Stream *s, Target *target) const s->EOL(); s->Indent(); *s << "Block = " << (void *)block; - if (block != NULL) + if (block != nullptr) *s << " {0x" << block->GetID() << '}'; // Dump the block and pass it a negative depth to we print all the parent blocks //if (block != NULL) @@ -368,7 +368,7 @@ SymbolContext::Dump(Stream *s, Target *target) const s->EOL(); s->Indent(); *s << "Symbol = " << (void *)symbol; - if (symbol != NULL && symbol->GetMangled()) + if (symbol != nullptr && symbol->GetMangled()) *s << ' ' << symbol->GetMangled().GetName().AsCString(); s->EOL(); s->IndentLess(); @@ -409,7 +409,7 @@ SymbolContext::GetAddressRange (uint32_t scope, return true; } - if ((scope & eSymbolContextBlock) && (block != NULL)) + if ((scope & eSymbolContextBlock) && (block != nullptr)) { if (use_inline_block_range) { @@ -423,7 +423,7 @@ SymbolContext::GetAddressRange (uint32_t scope, } } - if ((scope & eSymbolContextFunction) && (function != NULL)) + if ((scope & eSymbolContextFunction) && (function != nullptr)) { if (range_idx == 0) { @@ -432,7 +432,7 @@ SymbolContext::GetAddressRange (uint32_t scope, } } - if ((scope & eSymbolContextSymbol) && (symbol != NULL)) + if ((scope & eSymbolContextSymbol) && (symbol != nullptr)) { if (range_idx == 0) { @@ -562,7 +562,7 @@ SymbolContext::GetFunctionBlock () // the function itself. return &function->GetBlock(true); } - return NULL; + return nullptr; } bool @@ -777,7 +777,7 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) { if (sc.module_sp) { - if (m_module_sp.get() != NULL) + if (m_module_sp.get() != nullptr) { if (m_module_sp.get() != sc.module_sp.get()) return false; @@ -795,15 +795,15 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) if (m_file_spec_ap.get()) { // If we don't have a block or a comp_unit, then we aren't going to match a source file. - if (sc.block == NULL && sc.comp_unit == NULL) + if (sc.block == nullptr && sc.comp_unit == nullptr) return false; // Check if the block is present, and if so is it inlined: bool was_inlined = false; - if (sc.block != NULL) + if (sc.block != nullptr) { const InlineFunctionInfo *inline_info = sc.block->GetInlinedFunctionInfo(); - if (inline_info != NULL) + if (inline_info != nullptr) { was_inlined = true; if (!FileSpec::Equal (inline_info->GetDeclaration().GetFile(), *(m_file_spec_ap.get()), false)) @@ -812,7 +812,7 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) } // Next check the comp unit, but only if the SymbolContext was not inlined. - if (!was_inlined && sc.comp_unit != NULL) + if (!was_inlined && sc.comp_unit != nullptr) { if (!FileSpec::Equal (*(sc.comp_unit), *(m_file_spec_ap.get()), false)) return false; @@ -832,10 +832,10 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) bool was_inlined = false; ConstString func_name(m_function_spec.c_str()); - if (sc.block != NULL) + if (sc.block != nullptr) { const InlineFunctionInfo *inline_info = sc.block->GetInlinedFunctionInfo(); - if (inline_info != NULL) + if (inline_info != nullptr) { was_inlined = true; const Mangled &name = inline_info->GetMangled(); @@ -846,12 +846,12 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) // If it wasn't inlined, check the name in the function or symbol: if (!was_inlined) { - if (sc.function != NULL) + if (sc.function != nullptr) { if (!sc.function->GetMangled().NameMatches(func_name)) return false; } - else if (sc.symbol != NULL) + else if (sc.symbol != nullptr) { if (!sc.symbol->GetMangled().NameMatches(func_name)) return false; @@ -873,7 +873,7 @@ SymbolContextSpecifier::AddressMatches(lldb::addr_t addr) } else { - Address match_address (addr, NULL); + Address match_address (addr, nullptr); SymbolContext sc; m_target_sp->GetImages().ResolveSymbolContextForAddress(match_address, eSymbolContextEverything, sc); return SymbolContextMatches(sc); @@ -903,22 +903,22 @@ SymbolContextSpecifier::GetDescription (Stream *s, lldb::DescriptionLevel level) s->Printf ("Module: %s\n", m_module_spec.c_str()); } - if (m_type == eFileSpecified && m_file_spec_ap.get() != NULL) + if (m_type == eFileSpecified && m_file_spec_ap.get() != nullptr) { m_file_spec_ap->GetPath (path_str, PATH_MAX); s->Indent(); s->Printf ("File: %s", path_str); if (m_type == eLineStartSpecified) { - s->Printf (" from line %zu", m_start_line); + s->Printf (" from line %" PRIu64 "", (uint64_t)m_start_line); if (m_type == eLineEndSpecified) - s->Printf ("to line %zu", m_end_line); + s->Printf ("to line %" PRIu64 "", (uint64_t)m_end_line); else s->Printf ("to end"); } else if (m_type == eLineEndSpecified) { - s->Printf (" from start to line %zu", m_end_line); + s->Printf (" from start to line %" PRIu64 "", (uint64_t)m_end_line); } s->Printf (".\n"); } @@ -926,16 +926,16 @@ SymbolContextSpecifier::GetDescription (Stream *s, lldb::DescriptionLevel level) if (m_type == eLineStartSpecified) { s->Indent(); - s->Printf ("From line %zu", m_start_line); + s->Printf ("From line %" PRIu64 "", (uint64_t)m_start_line); if (m_type == eLineEndSpecified) - s->Printf ("to line %zu", m_end_line); + s->Printf ("to line %" PRIu64 "", (uint64_t)m_end_line); else s->Printf ("to end"); s->Printf (".\n"); } else if (m_type == eLineEndSpecified) { - s->Printf ("From start to line %zu.\n", m_end_line); + s->Printf ("From start to line %" PRIu64 ".\n", (uint64_t)m_end_line); } if (m_type == eFunctionSpecified) @@ -950,7 +950,7 @@ SymbolContextSpecifier::GetDescription (Stream *s, lldb::DescriptionLevel level) s->Printf ("Class name: %s.\n", m_class_name.c_str()); } - if (m_type == eAddressRangeSpecified && m_address_range_ap.get() != NULL) + if (m_type == eAddressRangeSpecified && m_address_range_ap.get() != nullptr) { s->Indent(); s->PutCString ("Address range: "); @@ -1013,10 +1013,10 @@ SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_in return false; } if (merge_symbol_into_function - && sc.symbol != NULL - && sc.comp_unit == NULL - && sc.function == NULL - && sc.block == NULL + && sc.symbol != nullptr + && sc.comp_unit == nullptr + && sc.function == nullptr + && sc.block == nullptr && sc.line_entry.IsValid() == false) { if (sc.symbol->ValueIsAddress()) @@ -1034,7 +1034,7 @@ SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_in // Do we already have a function with this symbol? if (pos->symbol == sc.symbol) return false; - if (pos->symbol == NULL) + if (pos->symbol == nullptr) { pos->symbol = sc.symbol; return false; @@ -1053,10 +1053,10 @@ SymbolContextList::MergeSymbolContextIntoFunctionContext (const SymbolContext& s uint32_t start_idx, uint32_t stop_idx) { - if (symbol_sc.symbol != NULL - && symbol_sc.comp_unit == NULL - && symbol_sc.function == NULL - && symbol_sc.block == NULL + if (symbol_sc.symbol != nullptr + && symbol_sc.comp_unit == nullptr + && symbol_sc.function == nullptr + && symbol_sc.block == nullptr && symbol_sc.line_entry.IsValid() == false) { if (symbol_sc.symbol->ValueIsAddress()) @@ -1077,7 +1077,7 @@ SymbolContextList::MergeSymbolContextIntoFunctionContext (const SymbolContext& s if (function_sc.symbol == symbol_sc.symbol) return true; // Already have a symbol context with this symbol, return true - if (function_sc.symbol == NULL) + if (function_sc.symbol == nullptr) { // We successfully merged this symbol into an existing symbol context m_symbol_contexts[i].symbol = symbol_sc.symbol; diff --git a/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp b/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp index 412c460..a5b138b 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp @@ -22,7 +22,7 @@ SymbolFile* SymbolFile::FindPlugin (ObjectFile* obj_file) { std::unique_ptr<SymbolFile> best_symfile_ap; - if (obj_file != NULL) + if (obj_file != nullptr) { // We need to test the abilities of this section list. So create what it would @@ -46,7 +46,7 @@ SymbolFile::FindPlugin (ObjectFile* obj_file) uint32_t best_symfile_abilities = 0; SymbolFileCreateInstance create_callback; - for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != nullptr; ++idx) { std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file)); @@ -79,7 +79,7 @@ SymbolFile::GetTypeList () { if (m_obj_file) return m_obj_file->GetModule()->GetTypeList(); - return NULL; + return nullptr; } lldb_private::ClangASTContext & diff --git a/contrib/llvm/tools/lldb/source/Symbol/SymbolVendor.cpp b/contrib/llvm/tools/lldb/source/Symbol/SymbolVendor.cpp index b51ac5a..a3f4104 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/SymbolVendor.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/SymbolVendor.cpp @@ -37,7 +37,7 @@ SymbolVendor::FindPlugin (const lldb::ModuleSP &module_sp, lldb_private::Stream std::unique_ptr<SymbolVendor> instance_ap; SymbolVendorCreateInstance create_callback; - for (size_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != NULL; ++idx) + for (size_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != nullptr; ++idx) { instance_ap.reset(create_callback(module_sp, feedback_strm)); @@ -109,7 +109,7 @@ SymbolVendor::SetCompileUnitAtIndex (size_t idx, const CompUnitSP &cu_sp) // unit once, so if this assertion fails, we need to make sure that // we don't have a race condition, or have a second parse of the same // compile unit. - assert(m_compile_units[idx].get() == NULL); + assert(m_compile_units[idx].get() == nullptr); m_compile_units[idx] = cu_sp; return true; } @@ -247,7 +247,7 @@ SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) if (m_sym_file_ap.get()) return m_sym_file_ap->ResolveTypeUID(type_uid); } - return NULL; + return nullptr; } @@ -382,7 +382,7 @@ SymbolVendor::Dump(Stream *s) { bool show_context = false; - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<void*>(this)); s->Indent(); s->PutCString("SymbolVendor"); if (m_sym_file_ap.get()) @@ -427,7 +427,7 @@ SymbolVendor::GetCompileUnitAtIndex(size_t idx) if (idx < num_compile_units) { cu_sp = m_compile_units[idx]; - if (cu_sp.get() == NULL) + if (cu_sp.get() == nullptr) { m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx); cu_sp = m_compile_units[idx]; @@ -450,7 +450,7 @@ SymbolVendor::GetSymtab () return objfile->GetSymtab (); } } - return NULL; + return nullptr; } void @@ -468,6 +468,27 @@ SymbolVendor::ClearSymtab() } } +void +SymbolVendor::SectionFileAddressesChanged () +{ + ModuleSP module_sp(GetModule()); + if (module_sp) + { + ObjectFile *module_objfile = module_sp->GetObjectFile (); + if (m_sym_file_ap.get()) + { + ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile (); + if (symfile_objfile != module_objfile) + symfile_objfile->SectionFileAddressesChanged (); + } + Symtab *symtab = GetSymtab (); + if (symtab) + { + symtab->SectionFileAddressesChanged (); + } + } +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ diff --git a/contrib/llvm/tools/lldb/source/Symbol/Symtab.cpp b/contrib/llvm/tools/lldb/source/Symbol/Symtab.cpp index 430fc17..907072c 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Symtab.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Symtab.cpp @@ -78,6 +78,13 @@ Symtab::GetNumSymbols() const } void +Symtab::SectionFileAddressesChanged () +{ + m_name_to_index.Clear(); + m_file_addr_to_index_computed = false; +} + +void Symtab::Dump (Stream *s, Target *target, SortOrder sort_order) { Mutex::Locker locker (m_mutex); @@ -85,19 +92,19 @@ Symtab::Dump (Stream *s, Target *target, SortOrder sort_order) // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); const FileSpec &file_spec = m_objfile->GetFileSpec(); - const char * object_name = NULL; + const char * object_name = nullptr; if (m_objfile->GetModule()) object_name = m_objfile->GetModule()->GetObjectName().GetCString(); if (file_spec) - s->Printf("Symtab, file = %s%s%s%s, num_symbols = %zu", + s->Printf("Symtab, file = %s%s%s%s, num_symbols = %" PRIu64, file_spec.GetPath().c_str(), object_name ? "(" : "", object_name ? object_name : "", object_name ? ")" : "", - m_symbols.size()); + (uint64_t)m_symbols.size()); else - s->Printf("Symtab, num_symbols = %zu", m_symbols.size()); + s->Printf("Symtab, num_symbols = %" PRIu64 "", (uint64_t)m_symbols.size()); if (!m_symbols.empty()) { @@ -166,7 +173,7 @@ Symtab::Dump(Stream *s, Target *target, std::vector<uint32_t>& indexes) const const size_t num_symbols = GetNumSymbols(); //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - s->Printf("Symtab %zu symbol indexes (%zu symbols total):\n", indexes.size(), m_symbols.size()); + s->Printf("Symtab %" PRIu64 " symbol indexes (%" PRIu64 " symbols total):\n", (uint64_t)indexes.size(), (uint64_t)m_symbols.size()); s->IndentMore(); if (!indexes.empty()) @@ -232,7 +239,7 @@ Symtab::SymbolAtIndex(size_t idx) // when calling this function to avoid performance issues. if (idx < m_symbols.size()) return &m_symbols[idx]; - return NULL; + return nullptr; } @@ -243,7 +250,7 @@ Symtab::SymbolAtIndex(size_t idx) const // when calling this function to avoid performance issues. if (idx < m_symbols.size()) return &m_symbols[idx]; - return NULL; + return nullptr; } //---------------------------------------------------------------------- @@ -286,7 +293,7 @@ Symtab::InitNameIndexes() // The "const char *" in "class_contexts" must come from a ConstString::GetCString() std::set<const char *> class_contexts; UniqueCStringMap<uint32_t> mangled_name_to_index; - std::vector<const char *> symbol_contexts(num_symbols, NULL); + std::vector<const char *> symbol_contexts(num_symbols, nullptr); for (entry.value = 0; entry.value<num_symbols; ++entry.value) { @@ -776,7 +783,7 @@ Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Vis } } } - return NULL; + return nullptr; } size_t @@ -854,7 +861,7 @@ Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symb } } } - return NULL; + return nullptr; } typedef struct @@ -867,36 +874,10 @@ typedef struct } SymbolSearchInfo; static int -SymbolWithFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr) -{ - const Symbol *curr_symbol = info->symtab->SymbolAtIndex (index_ptr[0]); - if (curr_symbol == NULL) - return -1; - - const addr_t info_file_addr = info->file_addr; - - // lldb::Symbol::GetAddressRangePtr() will only return a non NULL address - // range if the symbol has a section! - if (curr_symbol->ValueIsAddress()) - { - const addr_t curr_file_addr = curr_symbol->GetAddress().GetFileAddress(); - if (info_file_addr < curr_file_addr) - return -1; - if (info_file_addr > curr_file_addr) - return +1; - info->match_symbol = const_cast<Symbol *>(curr_symbol); - info->match_index_ptr = index_ptr; - return 0; - } - - return -1; -} - -static int SymbolWithClosestFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr) { const Symbol *symbol = info->symtab->SymbolAtIndex (index_ptr[0]); - if (symbol == NULL) + if (symbol == nullptr) return -1; const addr_t info_file_addr = info->file_addr; @@ -921,19 +902,6 @@ SymbolWithClosestFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr) return -1; } -static SymbolSearchInfo -FindIndexPtrForSymbolContainingAddress(Symtab* symtab, addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes) -{ - SymbolSearchInfo info = { symtab, file_addr, NULL, NULL, 0 }; - ::bsearch (&info, - indexes, - num_indexes, - sizeof(uint32_t), - (ComparisonFunction)SymbolWithClosestFileAddress); - return info; -} - - void Symtab::InitAddressIndexes() { @@ -1034,7 +1002,7 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr, const uint32_t* index Mutex::Locker locker (m_mutex); - SymbolSearchInfo info = { this, file_addr, NULL, NULL, 0 }; + SymbolSearchInfo info = { this, file_addr, nullptr, nullptr, 0 }; ::bsearch (&info, indexes, @@ -1064,7 +1032,7 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr, const uint32_t* index if (info.match_offset < symbol_byte_size) return info.match_symbol; } - return NULL; + return nullptr; } Symbol * @@ -1078,7 +1046,7 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr) const FileRangeToIndexMap::Entry *entry = m_file_addr_to_index.FindEntryThatContains(file_addr); if (entry) return SymbolAtIndex(entry->data); - return NULL; + return nullptr; } void @@ -1157,7 +1125,7 @@ Symtab::FindFunctionSymbols (const ConstString &name, { const UniqueCStringMap<uint32_t>::Entry *match; for (match = m_basename_to_index.FindFirstValueForName(name_cstr); - match != NULL; + match != nullptr; match = m_basename_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); @@ -1174,7 +1142,7 @@ Symtab::FindFunctionSymbols (const ConstString &name, { const UniqueCStringMap<uint32_t>::Entry *match; for (match = m_method_to_index.FindFirstValueForName(name_cstr); - match != NULL; + match != nullptr; match = m_method_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); @@ -1191,7 +1159,7 @@ Symtab::FindFunctionSymbols (const ConstString &name, { const UniqueCStringMap<uint32_t>::Entry *match; for (match = m_selector_to_index.FindFirstValueForName(name_cstr); - match != NULL; + match != nullptr; match = m_selector_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); diff --git a/contrib/llvm/tools/lldb/source/Symbol/Type.cpp b/contrib/llvm/tools/lldb/source/Symbol/Type.cpp index 073940e..4eb538f 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Type.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Type.cpp @@ -30,6 +30,8 @@ #include "llvm/ADT/StringRef.h" +#include "clang/AST/Decl.h" + using namespace lldb; using namespace lldb_private; @@ -91,7 +93,7 @@ Type::Type m_name (name), m_symbol_file (symbol_file), m_context (context), - m_encoding_type (NULL), + m_encoding_type (nullptr), m_encoding_uid (encoding_uid), m_encoding_uid_type (encoding_uid_type), m_byte_size (byte_size), @@ -106,9 +108,9 @@ Type::Type () : std::enable_shared_from_this<Type> (), UserID (0), m_name ("<INVALID TYPE>"), - m_symbol_file (NULL), - m_context (NULL), - m_encoding_type (NULL), + m_symbol_file (nullptr), + m_context (nullptr), + m_encoding_type (nullptr), m_encoding_uid (LLDB_INVALID_UID), m_encoding_uid_type (eEncodingInvalid), m_byte_size (0), @@ -201,16 +203,16 @@ Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name) void Type::Dump (Stream *s, bool show_context) { - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<void*>(this)); s->Indent(); - *s << "Type" << (const UserID&)*this << ' '; + *s << "Type" << static_cast<const UserID&>(*this) << ' '; if (m_name) *s << ", name = \"" << m_name << "\""; if (m_byte_size != 0) s->Printf(", size = %" PRIu64, m_byte_size); - if (show_context && m_context != NULL) + if (show_context && m_context != nullptr) { s->PutCString(", context = ( "); m_context->DumpSymbolContext(s); @@ -306,7 +308,7 @@ Type::DumpValue Type * Type::GetEncodingType () { - if (m_encoding_type == NULL && m_encoding_uid != LLDB_INVALID_UID) + if (m_encoding_type == nullptr && m_encoding_uid != LLDB_INVALID_UID) m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid); return m_encoding_type; } @@ -406,7 +408,7 @@ Type::DumpValueInMemory if (address != LLDB_INVALID_ADDRESS) { DataExtractor data; - Target *target = NULL; + Target *target = nullptr; if (exe_ctx) target = exe_ctx->GetTargetPtr(); if (target) @@ -439,14 +441,14 @@ Type::ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType } uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size); - if (dst != NULL) + if (dst != nullptr) { if (address_type == eAddressTypeHost) { // The address is an address in this process, so just copy it if (addr == 0) return false; - memcpy (dst, (uint8_t*)NULL + addr, byte_size); + memcpy (dst, (uint8_t*)nullptr + addr, byte_size); return true; } else @@ -488,7 +490,7 @@ Type::GetDeclaration () const bool Type::ResolveClangType (ResolveState clang_type_resolve_state) { - Type *encoding_type = NULL; + Type *encoding_type = nullptr; if (!m_clang_type.IsValid()) { encoding_type = GetEncodingType(); @@ -603,7 +605,7 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state) // resolved appropriately. if (m_encoding_uid != LLDB_INVALID_UID) { - if (encoding_type == NULL) + if (encoding_type == nullptr) encoding_type = GetEncodingType(); if (encoding_type) { @@ -777,7 +779,7 @@ Type::GetTypeScopeAndBasename (const char* &name_cstr, if (namespace_separator) { const char* template_arg_char = ::strchr (basename_cstr, '<'); - while (namespace_separator != NULL) + while (namespace_separator != nullptr) { if (template_arg_char && namespace_separator > template_arg_char) // but namespace'd template arguments are still good to go break; @@ -796,6 +798,13 @@ Type::GetTypeScopeAndBasename (const char* &name_cstr, } +ModuleSP +Type::GetModule() +{ + if (m_symbol_file) + return m_symbol_file->GetObjectFile()->GetModule(); + return ModuleSP(); +} TypeAndOrName::TypeAndOrName () : m_type_pair(), m_type_name() @@ -927,76 +936,95 @@ TypeAndOrName::HasClangASTType () const TypeImpl::TypeImpl() : -m_static_type(), -m_dynamic_type() + m_module_wp(), + m_static_type(), + m_dynamic_type() { } TypeImpl::TypeImpl(const TypeImpl& rhs) : -m_static_type(rhs.m_static_type), -m_dynamic_type(rhs.m_dynamic_type) + m_module_wp (rhs.m_module_wp), + m_static_type(rhs.m_static_type), + m_dynamic_type(rhs.m_dynamic_type) { } -TypeImpl::TypeImpl (lldb::TypeSP type_sp) : -m_static_type(type_sp), -m_dynamic_type() +TypeImpl::TypeImpl (const lldb::TypeSP &type_sp) : + m_module_wp (), + m_static_type(), + m_dynamic_type() { + SetType (type_sp); } -TypeImpl::TypeImpl (ClangASTType clang_type) : -m_static_type(clang_type), -m_dynamic_type() +TypeImpl::TypeImpl (const ClangASTType &clang_type) : + m_module_wp (), + m_static_type(), + m_dynamic_type() { + SetType (clang_type); } -TypeImpl::TypeImpl (lldb::TypeSP type_sp, ClangASTType dynamic) : -m_static_type (type_sp), -m_dynamic_type(dynamic) +TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const ClangASTType &dynamic) : + m_module_wp (), + m_static_type (type_sp), + m_dynamic_type(dynamic) { + SetType (type_sp, dynamic); } -TypeImpl::TypeImpl (ClangASTType clang_type, ClangASTType dynamic) : -m_static_type (clang_type), -m_dynamic_type(dynamic) +TypeImpl::TypeImpl (const ClangASTType &static_type, const ClangASTType &dynamic_type) : + m_module_wp (), + m_static_type (), + m_dynamic_type() { + SetType (static_type, dynamic_type); } -TypeImpl::TypeImpl (TypePair pair, ClangASTType dynamic) : -m_static_type (pair), -m_dynamic_type(dynamic) +TypeImpl::TypeImpl (const TypePair &pair, const ClangASTType &dynamic) : + m_module_wp (), + m_static_type (), + m_dynamic_type() { + SetType (pair, dynamic); } void -TypeImpl::SetType (lldb::TypeSP type_sp) +TypeImpl::SetType (const lldb::TypeSP &type_sp) { m_static_type.SetType(type_sp); + if (type_sp) + m_module_wp = type_sp->GetModule(); + else + m_module_wp = lldb::ModuleWP(); } void -TypeImpl::SetType (ClangASTType clang_type) +TypeImpl::SetType (const ClangASTType &clang_type) { + m_module_wp = lldb::ModuleWP(); m_static_type.SetType (clang_type); } void -TypeImpl::SetType (lldb::TypeSP type_sp, ClangASTType dynamic) +TypeImpl::SetType (const lldb::TypeSP &type_sp, const ClangASTType &dynamic) { - m_static_type.SetType (type_sp); + SetType (type_sp); m_dynamic_type = dynamic; } void -TypeImpl::SetType (ClangASTType clang_type, ClangASTType dynamic) +TypeImpl::SetType (const ClangASTType &clang_type, const ClangASTType &dynamic) { + m_module_wp = lldb::ModuleWP(); m_static_type.SetType (clang_type); m_dynamic_type = dynamic; } void -TypeImpl::SetType (TypePair pair, ClangASTType dynamic) +TypeImpl::SetType (const TypePair &pair, const ClangASTType &dynamic) { + m_module_wp = pair.GetModule(); m_static_type = pair; m_dynamic_type = dynamic; } @@ -1006,6 +1034,7 @@ TypeImpl::operator = (const TypeImpl& rhs) { if (rhs != *this) { + m_module_wp = rhs.m_module_wp; m_static_type = rhs.m_static_type; m_dynamic_type = rhs.m_dynamic_type; } @@ -1013,24 +1042,55 @@ TypeImpl::operator = (const TypeImpl& rhs) } bool +TypeImpl::CheckModule (lldb::ModuleSP &module_sp) const +{ + // Check if we have a module for this type. If we do and the shared pointer is + // can be successfully initialized with m_module_wp, return true. Else return false + // if we didn't have a module, or if we had a module and it has been deleted. Any + // functions doing anything with a TypeSP in this TypeImpl class should call this + // function and only do anything with the ivars if this function returns true. If + // we have a module, the "module_sp" will be filled in with a strong reference to the + // module so that the module will at least stay around long enough for the type + // query to succeed. + module_sp = m_module_wp.lock(); + if (!module_sp) + { + lldb::ModuleWP empty_module_wp; + // If either call to "std::weak_ptr::owner_before(...) value returns true, this + // indicates that m_module_wp once contained (possibly still does) a reference + // to a valid shared pointer. This helps us know if we had a valid reference to + // a section which is now invalid because the module it was in was deleted + if (empty_module_wp.owner_before(m_module_wp) || m_module_wp.owner_before(empty_module_wp)) + { + // m_module_wp had a valid reference to a module, but all strong references + // have been released and the module has been deleted + return false; + } + } + // We either successfully locked the module, or didn't have one to begin with + return true; +} + +bool TypeImpl::operator == (const TypeImpl& rhs) const { - return m_static_type == rhs.m_static_type && - m_dynamic_type == rhs.m_dynamic_type; + return m_static_type == rhs.m_static_type && m_dynamic_type == rhs.m_dynamic_type; } bool TypeImpl::operator != (const TypeImpl& rhs) const { - return m_static_type != rhs.m_static_type || - m_dynamic_type != rhs.m_dynamic_type; + return m_static_type != rhs.m_static_type || m_dynamic_type != rhs.m_dynamic_type; } bool TypeImpl::IsValid() const { // just a name is not valid - return m_static_type.IsValid() || m_dynamic_type.IsValid(); + ModuleSP module_sp; + if (CheckModule (module_sp)) + return m_static_type.IsValid() || m_dynamic_type.IsValid(); + return false; } TypeImpl::operator bool () const @@ -1041,6 +1101,7 @@ TypeImpl::operator bool () const void TypeImpl::Clear() { + m_module_wp = lldb::ModuleWP(); m_static_type.Clear(); m_dynamic_type.Clear(); } @@ -1048,113 +1109,201 @@ TypeImpl::Clear() ConstString TypeImpl::GetName () const { - if (m_dynamic_type) - return m_dynamic_type.GetTypeName(); - return m_static_type.GetName (); + ModuleSP module_sp; + if (CheckModule (module_sp)) + { + if (m_dynamic_type) + return m_dynamic_type.GetTypeName(); + return m_static_type.GetName (); + } + return ConstString(); +} + +ConstString +TypeImpl::GetDisplayTypeName () const +{ + ModuleSP module_sp; + if (CheckModule (module_sp)) + { + if (m_dynamic_type) + return m_dynamic_type.GetDisplayTypeName(); + return m_static_type.GetDisplayTypeName(); + } + return ConstString(); } TypeImpl TypeImpl::GetPointerType () const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetPointerType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetPointerType()); + } + return TypeImpl(m_static_type.GetPointerType()); } - return TypeImpl(m_static_type.GetPointerType()); + return TypeImpl(); } TypeImpl TypeImpl::GetPointeeType () const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetPointeeType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetPointeeType()); + } + return TypeImpl(m_static_type.GetPointeeType()); } - return TypeImpl(m_static_type.GetPointeeType()); + return TypeImpl(); } TypeImpl TypeImpl::GetReferenceType () const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetLValueReferenceType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetLValueReferenceType()); + } + return TypeImpl(m_static_type.GetReferenceType()); } - return TypeImpl(m_static_type.GetReferenceType()); + return TypeImpl(); } TypeImpl TypeImpl::GetTypedefedType () const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType()); + } + return TypeImpl(m_static_type.GetTypedefedType()); } - return TypeImpl(m_static_type.GetTypedefedType()); + return TypeImpl(); } TypeImpl TypeImpl::GetDereferencedType () const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetNonReferenceType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetNonReferenceType()); + } + return TypeImpl(m_static_type.GetDereferencedType()); } - return TypeImpl(m_static_type.GetDereferencedType()); + return TypeImpl(); } TypeImpl TypeImpl::GetUnqualifiedType() const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetFullyUnqualifiedType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetFullyUnqualifiedType()); + } + return TypeImpl(m_static_type.GetUnqualifiedType()); } - return TypeImpl(m_static_type.GetUnqualifiedType()); + return TypeImpl(); } TypeImpl TypeImpl::GetCanonicalType() const { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - return TypeImpl(m_static_type, m_dynamic_type.GetCanonicalType()); + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetCanonicalType()); + } + return TypeImpl(m_static_type.GetCanonicalType()); } - return TypeImpl(m_static_type.GetCanonicalType()); + return TypeImpl(); } ClangASTType TypeImpl::GetClangASTType (bool prefer_dynamic) { - if (prefer_dynamic) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - if (m_dynamic_type.IsValid()) - return m_dynamic_type; + if (prefer_dynamic) + { + if (m_dynamic_type.IsValid()) + return m_dynamic_type; + } + return m_static_type.GetClangASTType(); } - return m_static_type.GetClangASTType(); + return ClangASTType(); } clang::ASTContext * TypeImpl::GetClangASTContext (bool prefer_dynamic) { - if (prefer_dynamic) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - if (m_dynamic_type.IsValid()) - return m_dynamic_type.GetASTContext(); + if (prefer_dynamic) + { + if (m_dynamic_type.IsValid()) + return m_dynamic_type.GetASTContext(); + } + return m_static_type.GetClangASTContext(); } - return m_static_type.GetClangASTContext(); + return NULL; } bool TypeImpl::GetDescription (lldb_private::Stream &strm, - lldb::DescriptionLevel description_level) + lldb::DescriptionLevel description_level) { - if (m_dynamic_type.IsValid()) + ModuleSP module_sp; + if (CheckModule (module_sp)) { - strm.Printf("Dynamic:\n"); - m_dynamic_type.DumpTypeDescription(&strm); - strm.Printf("\nStatic:\n"); + if (m_dynamic_type.IsValid()) + { + strm.Printf("Dynamic:\n"); + m_dynamic_type.DumpTypeDescription(&strm); + strm.Printf("\nStatic:\n"); + } + m_static_type.GetClangASTType().DumpTypeDescription(&strm); + } + else + { + strm.PutCString("Invalid TypeImpl module for type has been deleted\n"); } - m_static_type.GetClangASTType().DumpTypeDescription(&strm); return true; } + +TypeEnumMemberImpl::TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl, + const lldb_private::ClangASTType& integer_type) : + m_integer_type_sp(), + m_name(), + m_value(), + m_valid(false) + +{ + if (enum_member_decl) + { + m_integer_type_sp.reset(new TypeImpl(integer_type)); + m_name = ConstString(enum_member_decl->getNameAsString().c_str()); + m_value = enum_member_decl->getInitVal(); + m_valid = true; + } +} diff --git a/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp b/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp index a033edd..8d97b2b 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp @@ -179,49 +179,6 @@ TypeList::Dump(Stream *s, bool show_context) } } -// depending on implementation details, type lookup might fail because of -// embedded spurious namespace:: prefixes. this call strips them, paying -// attention to the fact that a type might have namespace'd type names as -// arguments to templates, and those must not be stripped off -static bool -GetTypeScopeAndBasename(const char* name_cstr, std::string &scope, std::string &basename, bool *exact_ptr) -{ - // Protect against null c string. - - if (name_cstr && name_cstr[0]) - { - const char *basename_cstr = name_cstr; - const char* namespace_separator = ::strstr (basename_cstr, "::"); - if (namespace_separator) - { - const char* template_arg_char = ::strchr (basename_cstr, '<'); - while (namespace_separator != NULL) - { - if (template_arg_char && namespace_separator > template_arg_char) // but namespace'd template arguments are still good to go - break; - basename_cstr = namespace_separator + 2; - namespace_separator = strstr(basename_cstr, "::"); - } - if (basename_cstr > name_cstr) - { - scope.assign (name_cstr, basename_cstr - name_cstr); - if (scope.size() >= 2 && scope[0] == ':' && scope[1] == ':') - { - // The typename passed in started with "::" so make sure we only do exact matches - if (exact_ptr) - *exact_ptr = true; - // Strip the leading "::" as this won't ever show in qualified typenames we get - // from clang. - scope.erase(0,2); - } - basename.assign (basename_cstr); - return true; - } - } - } - return false; -} - void TypeList::RemoveMismatchedTypes (const char *qualified_typename, bool exact_match) diff --git a/contrib/llvm/tools/lldb/source/Symbol/UnwindPlan.cpp b/contrib/llvm/tools/lldb/source/Symbol/UnwindPlan.cpp index 7b361e7..ff0468e 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/UnwindPlan.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/UnwindPlan.cpp @@ -126,7 +126,7 @@ UnwindPlan::Row::RegisterLocation::Dump (Stream &s, const UnwindPlan* unwind_pla case inOtherRegister: { - const RegisterInfo *other_reg_info = NULL; + const RegisterInfo *other_reg_info = nullptr; if (unwind_plan) other_reg_info = unwind_plan->GetRegisterInfo (thread, m_location.reg_num); if (other_reg_info) @@ -313,6 +313,19 @@ UnwindPlan::AppendRow (const UnwindPlan::RowSP &row_sp) m_row_list.back() = row_sp; } +void +UnwindPlan::InsertRow (const UnwindPlan::RowSP &row_sp) +{ + collection::iterator it = m_row_list.begin(); + while (it != m_row_list.end()) { + RowSP row = *it; + if (row->GetOffset() > row_sp->GetOffset()) + break; + it++; + } + m_row_list.insert(it, row_sp); +} + UnwindPlan::RowSP UnwindPlan::GetRowForFunctionOffset (int offset) const { @@ -326,7 +339,7 @@ UnwindPlan::GetRowForFunctionOffset (int offset) const collection::const_iterator pos, end = m_row_list.end(); for (pos = m_row_list.begin(); pos != end; ++pos) { - if ((*pos)->GetOffset() <= offset) + if ((*pos)->GetOffset() <= static_cast<lldb::offset_t>(offset)) row = *pos; else break; @@ -381,7 +394,7 @@ UnwindPlan::PlanValidAtAddress (Address addr) if (log) { StreamString s; - if (addr.Dump (&s, NULL, Address::DumpStyleSectionNameOffset)) + if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset)) { log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s' at address %s", m_source_name.GetCString(), s.GetData()); @@ -397,13 +410,13 @@ UnwindPlan::PlanValidAtAddress (Address addr) // If the 0th Row of unwind instructions is missing, or if it doesn't provide // a register to use to find the Canonical Frame Address, this is not a valid UnwindPlan. - if (GetRowAtIndex(0).get() == NULL || GetRowAtIndex(0)->GetCFARegister() == LLDB_INVALID_REGNUM) + if (GetRowAtIndex(0).get() == nullptr || GetRowAtIndex(0)->GetCFARegister() == LLDB_INVALID_REGNUM) { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (log) { StreamString s; - if (addr.Dump (&s, NULL, Address::DumpStyleSectionNameOffset)) + if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset)) { log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s' at address %s", m_source_name.GetCString(), s.GetData()); @@ -480,6 +493,6 @@ UnwindPlan::GetRegisterInfo (Thread* thread, uint32_t unwind_reg) const return reg_ctx->GetRegisterInfoAtIndex (reg); } } - return NULL; + return nullptr; } diff --git a/contrib/llvm/tools/lldb/source/Symbol/UnwindTable.cpp b/contrib/llvm/tools/lldb/source/Symbol/UnwindTable.cpp index 33eb4d6..df9f5b9 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/UnwindTable.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/UnwindTable.cpp @@ -17,7 +17,6 @@ #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" -#include "lldb/Target/UnwindAssembly.h" // There is one UnwindTable object per ObjectFile. // It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile. @@ -30,8 +29,8 @@ UnwindTable::UnwindTable (ObjectFile& objfile) : m_object_file (objfile), m_unwinds (), m_initialized (false), - m_assembly_profiler (NULL), - m_eh_frame (NULL) + m_mutex (), + m_eh_frame (nullptr) { } @@ -44,6 +43,11 @@ UnwindTable::Initialize () if (m_initialized) return; + Mutex::Locker locker(m_mutex); + + if (m_initialized) // check again once we've acquired the lock + return; + SectionList* sl = m_object_file.GetSectionList (); if (sl) { @@ -54,12 +58,7 @@ UnwindTable::Initialize () } } - ArchSpec arch; - if (m_object_file.GetArchitecture (arch)) - { - m_assembly_profiler = UnwindAssembly::FindPlugin (arch); - m_initialized = true; - } + m_initialized = true; } UnwindTable::~UnwindTable () @@ -75,6 +74,8 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte Initialize(); + Mutex::Locker locker(m_mutex); + // There is an UnwindTable per object file, so we can safely use file handles addr_t file_addr = addr.GetFileAddress(); iterator end = m_unwinds.end (); @@ -94,13 +95,13 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid()) { // Does the eh_frame unwind info has a function bounds for this addr? - if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range)) + if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range)) { return no_unwind_found; } } - FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range)); + FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range)); m_unwinds.insert (insert_pos, std::make_pair(range.GetBaseAddress().GetFileAddress(), func_unwinder_sp)); // StreamFile s(stdout, false); // Dump (s); @@ -121,13 +122,13 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid()) { // Does the eh_frame unwind info has a function bounds for this addr? - if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range)) + if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range)) { return no_unwind_found; } } - FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range)); + FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range)); return func_unwinder_sp; } @@ -135,6 +136,7 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym void UnwindTable::Dump (Stream &s) { + Mutex::Locker locker(m_mutex); s.Printf("UnwindTable for '%s':\n", m_object_file.GetFileSpec().GetPath().c_str()); const_iterator begin = m_unwinds.begin(); const_iterator end = m_unwinds.end(); @@ -151,3 +153,9 @@ UnwindTable::GetEHFrameInfo () Initialize(); return m_eh_frame; } + +bool +UnwindTable::GetArchitecture (lldb_private::ArchSpec &arch) +{ + return m_object_file.GetArchitecture (arch); +} diff --git a/contrib/llvm/tools/lldb/source/Symbol/Variable.cpp b/contrib/llvm/tools/lldb/source/Symbol/Variable.cpp index 36fe3b1..e6a9b02 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/Variable.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/Variable.cpp @@ -87,13 +87,13 @@ Variable::GetType() { if (m_symfile_type_sp) return m_symfile_type_sp->GetType(); - return NULL; + return nullptr; } void Variable::Dump(Stream *s, bool show_context) const { - s->Printf("%p: ", this); + s->Printf("%p: ", static_cast<const void*>(this)); s->Indent(); *s << "Variable" << (const UserID&)*this; @@ -123,7 +123,7 @@ Variable::Dump(Stream *s, bool show_context) const } } - if (show_context && m_owner_scope != NULL) + if (show_context && m_owner_scope != nullptr) { s->PutCString(", context = ( "); m_owner_scope->DumpSymbolContext(s); @@ -144,7 +144,7 @@ Variable::Dump(Stream *s, bool show_context) const if (variable_sc.function) loclist_base_addr = variable_sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); } - ABI *abi = NULL; + ABI *abi = nullptr; if (m_owner_scope) { ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule()); @@ -171,12 +171,12 @@ Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module) { SymbolContext sc; m_owner_scope->CalculateSymbolContext(&sc); - sc.block = NULL; + sc.block = nullptr; sc.line_entry.Clear(); bool show_inlined_frames = false; dumped_declaration_info = sc.DumpStopContext (s, - NULL, + nullptr, Address(), show_fullpaths, show_module, @@ -277,7 +277,7 @@ Variable::IsInScope (StackFrame *frame) { case eValueTypeRegister: case eValueTypeRegisterSet: - return frame != NULL; + return frame != nullptr; case eValueTypeConstResult: case eValueTypeVariableGlobal: @@ -297,7 +297,7 @@ Variable::IsInScope (StackFrame *frame) CalculateSymbolContext (&variable_sc); // Check for static or global variable defined at the compile unit // level that wasn't defined in a block - if (variable_sc.block == NULL) + if (variable_sc.block == nullptr) return true; if (variable_sc.block == deepest_frame_block) @@ -419,7 +419,7 @@ Variable::GetValuesForVariableExpressionPath (const char *variable_expr_path, const char *variable_sub_expr_path = variable_expr_path + variable_name.size(); if (*variable_sub_expr_path) { - const char* first_unparsed = NULL; + const char* first_unparsed = nullptr; ValueObject::ExpressionPathScanEndReason reason_to_stop; ValueObject::ExpressionPathEndResultType final_value_type; ValueObject::GetValueForExpressionPathOptions options; @@ -485,7 +485,7 @@ Variable::DumpLocationForAddress (Stream *s, const Address &address) CalculateSymbolContext(&sc); if (sc.module_sp == address.GetModule()) { - ABI *abi = NULL; + ABI *abi = nullptr; if (m_owner_scope) { ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule()); @@ -553,7 +553,7 @@ PrivateAutoCompleteMembers (StackFrame *frame, { for (uint32_t i = 0; i < num_bases; ++i) { - ClangASTType base_class_type (clang_type.GetDirectBaseClassAtIndex (i, NULL)); + ClangASTType base_class_type (clang_type.GetDirectBaseClassAtIndex (i, nullptr)); PrivateAutoCompleteMembers (frame, partial_member_name, @@ -571,7 +571,7 @@ PrivateAutoCompleteMembers (StackFrame *frame, { for (uint32_t i = 0; i < num_vbases; ++i) { - ClangASTType vbase_class_type (clang_type.GetVirtualBaseClassAtIndex(i,NULL)); + ClangASTType vbase_class_type (clang_type.GetVirtualBaseClassAtIndex(i,nullptr)); PrivateAutoCompleteMembers (frame, partial_member_name, @@ -592,7 +592,7 @@ PrivateAutoCompleteMembers (StackFrame *frame, { std::string member_name; - ClangASTType member_clang_type = clang_type.GetFieldAtIndex (i, member_name, NULL, NULL, NULL); + ClangASTType member_clang_type = clang_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr); if (partial_member_name.empty() || member_name.find(partial_member_name) == 0) |