From 99558cc424fee346a4070b42ac9c62546d499333 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 24 Aug 2015 23:46:31 +0000 Subject: [PATCH] Final bit of type system cleanup that abstracts declaration contexts into lldb_private::CompilerDeclContext and renames ClangType to CompilerType in many accessors and functions. Create a new "lldb_private::CompilerDeclContext" class that will replace all direct uses of "clang::DeclContext" when used in compiler agnostic code, yet still allow for conversion to clang::DeclContext subclasses by clang specific code. This completes the abstraction of type parsing by removing all "clang::" references from the SymbolFileDWARF. The new "lldb_private::CompilerDeclContext" class abstracts decl contexts found in compiler type systems so they can be used in internal API calls. The TypeSystem is required to support CompilerDeclContexts with new pure virtual functions that start with "DeclContext" in the member function names. Converted all code that used lldb_private::ClangNamespaceDecl over to use the new CompilerDeclContext class and removed the ClangNamespaceDecl.cpp and ClangNamespaceDecl.h files. Removed direct use of clang APIs from SBType and now use the abstract type systems to correctly explore types. Bulk renames for things that used to return a ClangASTType which is now CompilerType: "Type::GetClangFullType()" to "Type::GetFullCompilerType()" "Type::GetClangLayoutType()" to "Type::GetLayoutCompilerType()" "Type::GetClangForwardType()" to "Type::GetForwardCompilerType()" "Value::GetClangType()" to "Value::GetCompilerType()" "Value::SetClangType (const CompilerType &)" to "Value::SetCompilerType (const CompilerType &)" "ValueObject::GetClangType ()" to "ValueObject::GetCompilerType()" many more renames that are similar. llvm-svn: 245905 --- lldb/include/lldb/Core/ClangForward.h | 2 + lldb/include/lldb/Core/Module.h | 12 +- lldb/include/lldb/Core/Value.h | 4 +- lldb/include/lldb/Core/ValueObject.h | 4 +- lldb/include/lldb/Core/ValueObjectCast.h | 2 +- lldb/include/lldb/Core/ValueObjectChild.h | 2 +- .../lldb/Core/ValueObjectConstResult.h | 2 +- .../lldb/Core/ValueObjectConstResultCast.h | 4 +- .../lldb/Core/ValueObjectConstResultChild.h | 4 +- .../lldb/Core/ValueObjectDynamicValue.h | 2 +- lldb/include/lldb/Core/ValueObjectMemory.h | 2 +- lldb/include/lldb/Core/ValueObjectRegister.h | 6 +- .../lldb/Core/ValueObjectSyntheticFilter.h | 2 +- lldb/include/lldb/Core/ValueObjectVariable.h | 2 +- .../lldb/DataFormatters/FormatManager.h | 2 +- .../lldb/DataFormatters/FormattersContainer.h | 2 +- lldb/include/lldb/Expression/ClangASTSource.h | 2 +- .../lldb/Expression/ClangExpressionDeclMap.h | 5 +- .../lldb/Expression/ClangExpressionVariable.h | 6 +- lldb/include/lldb/Symbol/Block.h | 4 +- lldb/include/lldb/Symbol/ClangASTContext.h | 273 ++-- lldb/include/lldb/Symbol/ClangASTImporter.h | 4 +- lldb/include/lldb/Symbol/ClangNamespaceDecl.h | 105 -- .../include/lldb/Symbol/CompilerDeclContext.h | 141 ++ lldb/include/lldb/Symbol/CompilerType.h | 36 +- lldb/include/lldb/Symbol/Function.h | 6 +- lldb/include/lldb/Symbol/SymbolFile.h | 26 +- lldb/include/lldb/Symbol/SymbolVendor.h | 11 +- lldb/include/lldb/Symbol/Type.h | 41 +- lldb/include/lldb/Symbol/TypeSystem.h | 210 +-- lldb/include/lldb/lldb-forward.h | 2 +- lldb/lldb.xcodeproj/project.pbxproj | 12 +- lldb/source/API/SBType.cpp | 55 +- lldb/source/API/SBValue.cpp | 4 +- .../Breakpoint/BreakpointResolverName.cpp | 1 - lldb/source/Commands/CommandObjectArgs.cpp | 2 +- lldb/source/Commands/CommandObjectMemory.cpp | 6 +- lldb/source/Commands/CommandObjectTarget.cpp | 8 +- .../Commands/CommandObjectWatchpoint.cpp | 4 +- lldb/source/Core/AddressResolverName.cpp | 1 - lldb/source/Core/Disassembler.cpp | 1 - lldb/source/Core/FormatEntity.cpp | 6 +- lldb/source/Core/Module.cpp | 18 +- lldb/source/Core/ModuleList.cpp | 1 - lldb/source/Core/SourceManager.cpp | 1 - lldb/source/Core/Value.cpp | 16 +- lldb/source/Core/ValueObject.cpp | 70 +- lldb/source/Core/ValueObjectCast.cpp | 10 +- lldb/source/Core/ValueObjectChild.cpp | 14 +- lldb/source/Core/ValueObjectConstResult.cpp | 18 +- .../Core/ValueObjectConstResultImpl.cpp | 4 +- lldb/source/Core/ValueObjectDynamicValue.cpp | 18 +- lldb/source/Core/ValueObjectMemory.cpp | 10 +- lldb/source/Core/ValueObjectRegister.cpp | 10 +- .../Core/ValueObjectSyntheticFilter.cpp | 4 +- lldb/source/Core/ValueObjectVariable.cpp | 14 +- .../DataFormatters/CXXFormatterFunctions.cpp | 17 +- lldb/source/DataFormatters/Cocoa.cpp | 8 +- lldb/source/DataFormatters/CoreMedia.cpp | 4 +- lldb/source/DataFormatters/FormatManager.cpp | 8 +- lldb/source/DataFormatters/LibCxx.cpp | 6 +- .../DataFormatters/LibCxxInitializerList.cpp | 2 +- lldb/source/DataFormatters/LibCxxList.cpp | 2 +- lldb/source/DataFormatters/LibCxxMap.cpp | 4 +- .../DataFormatters/LibCxxUnorderedMap.cpp | 2 +- lldb/source/DataFormatters/LibCxxVector.cpp | 2 +- lldb/source/DataFormatters/LibStdcpp.cpp | 2 +- lldb/source/DataFormatters/NSArray.cpp | 6 +- lldb/source/DataFormatters/NSIndexPath.cpp | 4 +- lldb/source/DataFormatters/NSSet.cpp | 4 +- lldb/source/DataFormatters/TypeFormat.cpp | 6 +- .../DataFormatters/ValueObjectPrinter.cpp | 2 +- lldb/source/DataFormatters/VectorType.cpp | 6 +- lldb/source/Expression/ClangASTSource.cpp | 67 +- .../Expression/ClangExpressionDeclMap.cpp | 70 +- .../Expression/ClangExpressionVariable.cpp | 10 +- lldb/source/Expression/ClangFunction.cpp | 10 +- .../source/Expression/ClangUserExpression.cpp | 12 +- lldb/source/Expression/Materializer.cpp | 4 +- .../Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 6 +- .../ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp | 8 +- .../ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 8 +- .../Plugins/ABI/SysV-arm/ABISysV_arm.cpp | 6 +- .../Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp | 8 +- .../Plugins/ABI/SysV-i386/ABISysV_i386.cpp | 4 +- .../Plugins/ABI/SysV-mips/ABISysV_mips.cpp | 4 +- .../ABI/SysV-mips64/ABISysV_mips64.cpp | 4 +- .../Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp | 8 +- .../Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp | 8 +- .../ABI/SysV-x86_64/ABISysV_x86_64.cpp | 6 +- .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp | 4 +- .../ItaniumABI/ItaniumABILanguageRuntime.cpp | 8 +- .../AppleObjCRuntime/AppleObjCRuntime.cpp | 10 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 14 +- .../AppleObjCTrampolineHandler.cpp | 6 +- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 1 - .../Python/OperatingSystemPython.cpp | 1 - .../SymbolFile/DWARF/DWARFDebugInfoEntry.h | 1 - .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 203 +-- .../SymbolFile/DWARF/SymbolFileDWARF.h | 449 ++++--- .../DWARF/SymbolFileDWARFDebugMap.cpp | 55 +- .../DWARF/SymbolFileDWARFDebugMap.h | 16 +- .../SymbolFile/Symtab/SymbolFileSymtab.cpp | 63 - .../SymbolFile/Symtab/SymbolFileSymtab.h | 23 - .../MacOSX/AppleGetItemInfoHandler.cpp | 10 +- .../MacOSX/AppleGetPendingItemsHandler.cpp | 10 +- .../MacOSX/AppleGetQueuesHandler.cpp | 8 +- .../MacOSX/AppleGetThreadItemInfoHandler.cpp | 10 +- lldb/source/Symbol/Block.cpp | 33 +- lldb/source/Symbol/CMakeLists.txt | 2 +- lldb/source/Symbol/ClangASTContext.cpp | 1154 ++++++++--------- lldb/source/Symbol/ClangASTImporter.cpp | 1 - lldb/source/Symbol/ClangNamespaceDecl.cpp | 25 - lldb/source/Symbol/CompilerDeclContext.cpp | 64 + lldb/source/Symbol/CompilerType.cpp | 53 +- lldb/source/Symbol/Function.cpp | 41 +- lldb/source/Symbol/SymbolContext.cpp | 17 +- lldb/source/Symbol/SymbolFile.cpp | 51 + lldb/source/Symbol/SymbolVendor.cpp | 22 +- lldb/source/Symbol/Type.cpp | 116 +- lldb/source/Symbol/TypeList.cpp | 4 +- lldb/source/Symbol/Variable.cpp | 10 +- lldb/source/Target/ObjCLanguageRuntime.cpp | 4 +- lldb/source/Target/StackFrame.cpp | 18 +- lldb/source/Target/Thread.cpp | 2 +- lldb/source/Target/ThreadPlanStepOut.cpp | 2 +- lldb/source/Target/ThreadPlanTracer.cpp | 2 +- 127 files changed, 2111 insertions(+), 1964 deletions(-) delete mode 100644 lldb/include/lldb/Symbol/ClangNamespaceDecl.h create mode 100644 lldb/include/lldb/Symbol/CompilerDeclContext.h delete mode 100644 lldb/source/Symbol/ClangNamespaceDecl.cpp create mode 100644 lldb/source/Symbol/CompilerDeclContext.cpp diff --git a/lldb/include/lldb/Core/ClangForward.h b/lldb/include/lldb/Core/ClangForward.h index 6c627c2ad3b7..80abc15f671c 100644 --- a/lldb/include/lldb/Core/ClangForward.h +++ b/lldb/include/lldb/Core/ClangForward.h @@ -132,6 +132,8 @@ namespace clang namespace llvm { + class APInt; + class APSInt; class LLVMContext; class ExecutionEngine; } diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index ab2252608d64..ec4a4415db81 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -324,7 +324,7 @@ public: //------------------------------------------------------------------ size_t FindFunctions (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool symbols_ok, bool inlines_ok, @@ -393,8 +393,8 @@ public: /// The name of the global or static variable we are looking /// for. /// - /// @param[in] namespace_decl - /// If valid, a namespace to search in. + /// @param[in] parent_decl_ctx + /// If valid, a decl context that results must exist within /// /// @param[in] append /// If \b true, any matches will be appended to \a @@ -414,7 +414,7 @@ public: //------------------------------------------------------------------ size_t FindGlobalVariables (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variable_list); @@ -525,7 +525,7 @@ public: size_t FindTypesInNamespace (const SymbolContext& sc, const ConstString &type_name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList& type_list); @@ -1193,7 +1193,7 @@ private: size_t FindTypes_Impl (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeList& types); diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 57f8de4348ab..91dda349d0d5 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -134,10 +134,10 @@ public: operator=(const Value &rhs); const CompilerType & - GetClangType(); + GetCompilerType(); void - SetClangType (const CompilerType &clang_type); + SetCompilerType (const CompilerType &clang_type); ValueType GetValueType() const; diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index e9e4379733f0..075968a0b51d 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -374,7 +374,7 @@ public: virtual ~ValueObject(); CompilerType - GetClangType (); + GetCompilerType (); // this vends a TypeImpl that is useful at the SB API layer virtual TypeImpl @@ -1232,7 +1232,7 @@ protected: //------------------------------------------------------------------ virtual CompilerType - GetClangTypeImpl () = 0; + GetCompilerTypeImpl () = 0; const char * GetLocationAsCStringImpl (const Value& value, diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index 239375d3635b..8bbc9da6fb48 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -66,7 +66,7 @@ protected: UpdateValue () override; CompilerType - GetClangTypeImpl () override; + GetCompilerTypeImpl () override; CompilerType m_cast_type; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 9ad3ea3cb6f0..203958ed550d 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -90,7 +90,7 @@ protected: CanUpdateWithInvalidExecutionContext (); virtual CompilerType - GetClangTypeImpl () + GetCompilerTypeImpl () { return m_clang_type; } diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 39713bbc1f21..758191a86385 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -139,7 +139,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); ConstString m_type_name; uint64_t m_byte_size; diff --git a/lldb/include/lldb/Core/ValueObjectConstResultCast.h b/lldb/include/lldb/Core/ValueObjectConstResultCast.h index 2f99afa522e3..c79414329fd4 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultCast.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultCast.h @@ -39,9 +39,9 @@ public: int32_t synthetic_index) override; virtual CompilerType - GetClangType () + GetCompilerType () { - return ValueObjectCast::GetClangType(); + return ValueObjectCast::GetCompilerType(); } lldb::ValueObjectSP diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h index b666d7e46e5d..553d90d889fb 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h @@ -46,9 +46,9 @@ public: CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; virtual CompilerType - GetClangType () + GetCompilerType () { - return ValueObjectChild::GetClangType(); + return ValueObjectChild::GetCompilerType(); } lldb::ValueObjectSP diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index ecc760e82d57..f5cb4d98428d 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -131,7 +131,7 @@ protected: } virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); Address m_address; ///< The variable that this value object is based upon TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index cc5176209994..08b7ad4afff6 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -67,7 +67,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); Address m_address; ///< The variable that this value object is based upon lldb::TypeSP m_type_sp; diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 5166d439f067..bf29b819e000 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -60,7 +60,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; @@ -114,7 +114,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; const RegisterSet *m_reg_set; @@ -171,7 +171,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); lldb::RegisterContextSP m_reg_ctx_sp; RegisterInfo m_reg_info; diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index d6c2d2badec9..5eb7e2b5195c 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -166,7 +166,7 @@ protected: } virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); virtual void CreateSynthFilter (); diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index d1e8aa137328..5cbf25ed361b 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -75,7 +75,7 @@ protected: UpdateValue (); virtual CompilerType - GetClangTypeImpl (); + GetCompilerTypeImpl (); lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon Value m_resolved_value; ///< The value that DWARFExpression resolves this variable to before we patch it up diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h index b3f15e708940..ebc00bddd6e9 100644 --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -248,7 +248,7 @@ public: { FormattersMatchVector matches; GetPossibleMatches (valobj, - valobj.GetClangType(), + valobj.GetCompilerType(), lldb_private::eFormatterChoiceCriterionDirectChoice, use_dynamic, matches, diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index 67353771ca50..c16ed9c2cee2 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -268,7 +268,7 @@ public: uint32_t* why = NULL) { uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice; - CompilerType ast_type(valobj.GetClangType()); + CompilerType ast_type(valobj.GetCompilerType()); bool ret = Get(valobj, ast_type, entry, use_dynamic, value); if (ret) entry = MapValueType(entry); diff --git a/lldb/include/lldb/Expression/ClangASTSource.h b/lldb/include/lldb/Expression/ClangASTSource.h index 16df4973ffda..bc6b996567a8 100644 --- a/lldb/include/lldb/Expression/ClangASTSource.h +++ b/lldb/include/lldb/Expression/ClangASTSource.h @@ -353,7 +353,7 @@ protected: void FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module, - ClangNamespaceDecl &namespace_decl, + CompilerDeclContext &namespace_decl, unsigned int current_id); //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h index 8ff2a75f4b9b..9de64a777103 100644 --- a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h @@ -19,7 +19,6 @@ // Other libraries and framework includes // Project includes -#include "llvm/ADT/APInt.h" #include "llvm/ADT/DenseMap.h" #include "clang/AST/Decl.h" #include "lldb/lldb-public.h" @@ -385,7 +384,7 @@ public: void FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module, - ClangNamespaceDecl &namespace_decl, + CompilerDeclContext &namespace_decl, unsigned int current_id); private: ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser. @@ -546,7 +545,7 @@ private: FindGlobalVariable (Target &target, lldb::ModuleSP &module, const ConstString &name, - ClangNamespaceDecl *namespace_decl, + CompilerDeclContext *namespace_decl, TypeFromUser *type = NULL); //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Expression/ClangExpressionVariable.h b/lldb/include/lldb/Expression/ClangExpressionVariable.h index 3edec351ebea..580ab2a342a6 100644 --- a/lldb/include/lldb/Expression/ClangExpressionVariable.h +++ b/lldb/include/lldb/Expression/ClangExpressionVariable.h @@ -222,10 +222,10 @@ public: SetRegisterInfo (const RegisterInfo *reg_info); CompilerType - GetClangType (); + GetCompilerType (); void - SetClangType (const CompilerType &clang_type); + SetCompilerType (const CompilerType &clang_type); TypeFromUser GetTypeFromUser (); @@ -420,7 +420,7 @@ public: { lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size)); var_sp->SetName (name); - var_sp->SetClangType (user_type); + var_sp->SetCompilerType (user_type); m_variables.push_back(var_sp); return var_sp; } diff --git a/lldb/include/lldb/Symbol/Block.h b/lldb/include/lldb/Symbol/Block.h index 5022ac2e4e33..873d630a51b8 100644 --- a/lldb/include/lldb/Symbol/Block.h +++ b/lldb/include/lldb/Symbol/Block.h @@ -357,8 +357,8 @@ public: return m_inlineInfoSP.get(); } - clang::DeclContext * - GetClangDeclContext(); + CompilerDeclContext + GetDeclContext(); //------------------------------------------------------------------ /// Get the memory cost of this object. diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index e137f911e916..1ff982a136b7 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -196,10 +196,7 @@ public: GetDeclContextForType (clang::QualType type); static clang::DeclContext * - GetDeclContextForType (const CompilerType& type) - { - return GetDeclContextForType(GetQualType(type)); - } + GetDeclContextForType (const CompilerType& type); uint32_t GetPointerByteSize () override; @@ -213,12 +210,6 @@ public: return GetTranslationUnitDecl (getASTContext()); } - static bool - GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx, - lldb::LanguageType &language, - bool &is_instance_method, - ConstString &language_object_name); - static CompilerType CopyType(clang::ASTContext *dest_context, CompilerType source_type); @@ -262,7 +253,7 @@ public: { clang::NamedDecl *named_decl = result[0]; if (const RecordDeclType *record_decl = llvm::dyn_cast(named_decl)) - clang_type.SetClangType(ast, clang::QualType(record_decl->getTypeForDecl(), 0)); + clang_type.SetCompilerType(ast, clang::QualType(record_decl->getTypeForDecl(), 0)); } } } @@ -531,6 +522,16 @@ public: lldb_private::Type *type, CompilerType &clang_type) override; + CompilerDeclContext + GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *dwarf_cu, + const DWARFDebugInfoEntry* die) override; + + CompilerDeclContext + GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *dwarf_cu, + const DWARFDebugInfoEntry* die) override; + //------------------------------------------------------------------ // ClangASTContext callbacks for external source lookups. //------------------------------------------------------------------ @@ -549,86 +550,111 @@ public: llvm::DenseMap &base_offsets, llvm::DenseMap &vbase_offsets); - bool - DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl, - SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die) override; - clang::NamespaceDecl * ResolveNamespaceDIE (SymbolFileDWARF *dwarf, DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry *die) override; + const DWARFDebugInfoEntry *die); - clang::DeclContext* - GetClangDeclContextForTypeUID (SymbolFileDWARF *dwarf, - const lldb_private::SymbolContext &sc, - lldb::user_id_t type_uid) override; + //---------------------------------------------------------------------- + // CompilerDeclContext override functions + //---------------------------------------------------------------------- - clang::DeclContext* - GetClangDeclContextContainingTypeUID (SymbolFileDWARF *dwarf, - lldb::user_id_t type_uid) override; + bool + DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) override; + ConstString + DeclContextGetName (void *opaque_decl_ctx) override; + + bool + DeclContextIsClassMethod (void *opaque_decl_ctx, + lldb::LanguageType *language_ptr, + bool *is_instance_method_ptr, + ConstString *language_object_name_ptr) override; + + //---------------------------------------------------------------------- + // Clang specific clang::DeclContext functions + //---------------------------------------------------------------------- + + static clang::DeclContext * + DeclContextGetAsDeclContext (const CompilerDeclContext &dc); + + static clang::ObjCMethodDecl * + DeclContextGetAsObjCMethodDecl (const CompilerDeclContext &dc); + + static clang::CXXMethodDecl * + DeclContextGetAsCXXMethodDecl (const CompilerDeclContext &dc); + + static clang::FunctionDecl * + DeclContextGetAsFunctionDecl (const CompilerDeclContext &dc); + + static clang::NamespaceDecl * + DeclContextGetAsNamespaceDecl (const CompilerDeclContext &dc); + + static ClangASTMetadata * + DeclContextGetMetaData (const CompilerDeclContext &dc, const void *object); + + static clang::ASTContext * + DeclContextGetClangASTContext (const CompilerDeclContext &dc); //---------------------------------------------------------------------- // Tests //---------------------------------------------------------------------- bool - IsArrayType (void* type, + IsArrayType (void *type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override; bool - IsVectorType (void* type, + IsVectorType (void *type, CompilerType *element_type, uint64_t *size) override; bool - IsAggregateType (void* type) override; + IsAggregateType (void *type) override; bool - IsBeingDefined (void* type) override; + IsBeingDefined (void *type) override; bool - IsCharType (void* type) override; + IsCharType (void *type) override; bool - IsCompleteType (void* type) override; + IsCompleteType (void *type) override; bool - IsConst(void* type) override; + IsConst(void *type) override; bool - IsCStringType (void* type, uint32_t &length) override; + IsCStringType (void *type, uint32_t &length) override; static bool IsCXXClassType (const CompilerType& type); bool - IsDefined(void* type) override; + IsDefined(void *type) override; bool - IsFloatingPointType (void* type, uint32_t &count, bool &is_complex) override; + IsFloatingPointType (void *type, uint32_t &count, bool &is_complex) override; bool - IsFunctionType (void* type, bool *is_variadic_ptr) override; - + IsFunctionType (void *type, bool *is_variadic_ptr) override; + uint32_t - IsHomogeneousAggregate (void* type, CompilerType* base_type_ptr) override; + IsHomogeneousAggregate (void *type, CompilerType* base_type_ptr) override; size_t - GetNumberOfFunctionArguments (void* type) override; + GetNumberOfFunctionArguments (void *type) override; CompilerType - GetFunctionArgumentAtIndex (void* type, const size_t index) override; + GetFunctionArgumentAtIndex (void *type, const size_t index) override; bool - IsFunctionPointerType (void* type) override; + IsFunctionPointerType (void *type) override; bool - IsIntegerType (void* type, bool &is_signed) override; + IsIntegerType (void *type, bool &is_signed) override; static bool IsObjCClassType (const CompilerType& type); @@ -643,34 +669,34 @@ public: IsObjCObjectPointerType (const CompilerType& type, CompilerType *target_type = NULL); bool - IsPolymorphicClass (void* type) override; + IsPolymorphicClass (void *type) override; bool - IsPossibleDynamicType (void* type, + IsPossibleDynamicType (void *type, CompilerType *target_type, // Can pass NULL bool check_cplusplus, bool check_objc) override; bool - IsRuntimeGeneratedType (void* type) override; + IsRuntimeGeneratedType (void *type) override; bool - IsPointerType (void* type, CompilerType *pointee_type) override; + IsPointerType (void *type, CompilerType *pointee_type) override; bool - IsPointerOrReferenceType (void* type, CompilerType *pointee_type) override; + IsPointerOrReferenceType (void *type, CompilerType *pointee_type) override; bool - IsReferenceType (void* type, CompilerType *pointee_type, bool* is_rvalue) override; + IsReferenceType (void *type, CompilerType *pointee_type, bool* is_rvalue) override; bool - IsScalarType (void* type) override; + IsScalarType (void *type) override; bool - IsTypedefType (void* type) override; + IsTypedefType (void *type) override; bool - IsVoidType (void* type) override; + IsVoidType (void *type) override; static bool GetCXXClassName (const CompilerType& type, std::string &class_name); @@ -684,26 +710,26 @@ public: //---------------------------------------------------------------------- bool - GetCompleteType (void* type) override; + GetCompleteType (void *type) override; //---------------------------------------------------------------------- // Accessors //---------------------------------------------------------------------- ConstString - GetTypeName (void* type) override; + GetTypeName (void *type) override; uint32_t - GetTypeInfo (void* type, CompilerType *pointee_or_element_clang_type) override; + GetTypeInfo (void *type, CompilerType *pointee_or_element_clang_type) override; lldb::LanguageType - GetMinimumLanguage (void* type) override; + GetMinimumLanguage (void *type) override; lldb::TypeClass - GetTypeClass (void* type) override; + GetTypeClass (void *type) override; unsigned - GetTypeQualifiers(void* type) override; + GetTypeQualifiers(void *type) override; //---------------------------------------------------------------------- // Creating related types @@ -723,52 +749,52 @@ public: static CompilerType CreateTypedefType (const CompilerType& type, const char *typedef_name, - clang::DeclContext *decl_ctx); + const CompilerDeclContext &compiler_decl_ctx); CompilerType - GetArrayElementType (void* type, uint64_t *stride) override; + GetArrayElementType (void *type, uint64_t *stride) override; CompilerType - GetCanonicalType (void* type) override; + GetCanonicalType (void *type) override; CompilerType - GetFullyUnqualifiedType (void* type) override; + GetFullyUnqualifiedType (void *type) override; // Returns -1 if this isn't a function of if the function doesn't have a prototype // Returns a value >= 0 if there is a prototype. int - GetFunctionArgumentCount (void* type) override; + GetFunctionArgumentCount (void *type) override; CompilerType - GetFunctionArgumentTypeAtIndex (void* type, size_t idx) override; + GetFunctionArgumentTypeAtIndex (void *type, size_t idx) override; CompilerType - GetFunctionReturnType (void* type) override; + GetFunctionReturnType (void *type) override; size_t - GetNumMemberFunctions (void* type) override; + GetNumMemberFunctions (void *type) override; TypeMemberFunctionImpl - GetMemberFunctionAtIndex (void* type, size_t idx) override; + GetMemberFunctionAtIndex (void *type, size_t idx) override; static CompilerType GetLValueReferenceType (const CompilerType& type); CompilerType - GetNonReferenceType (void* type) override; + GetNonReferenceType (void *type) override; CompilerType - GetPointeeType (void* type) override; + GetPointeeType (void *type) override; CompilerType - GetPointerType (void* type) override; + GetPointerType (void *type) override; static CompilerType GetRValueReferenceType (const CompilerType& type); // If the current object represents a typedef type, get the underlying type CompilerType - GetTypedefedType (void* type) override; + GetTypedefedType (void *type) override; static CompilerType RemoveFastQualifiers (const CompilerType& type); @@ -777,7 +803,7 @@ public: // Create related types using the current type's AST //---------------------------------------------------------------------- CompilerType - GetBasicTypeFromAST (void* type, lldb::BasicType basic_type) override; + GetBasicTypeFromAST (lldb::BasicType basic_type) override; //---------------------------------------------------------------------- // Exploring the type @@ -790,58 +816,61 @@ public: } uint64_t - GetBitSize (void* type, ExecutionContextScope *exe_scope) override; + GetBitSize (void *type, ExecutionContextScope *exe_scope) override; lldb::Encoding - GetEncoding (void* type, uint64_t &count) override; + GetEncoding (void *type, uint64_t &count) override; lldb::Format - GetFormat (void* type) override; + GetFormat (void *type) override; size_t - GetTypeBitAlign (void* type) override; + GetTypeBitAlign (void *type) override; uint32_t - GetNumChildren (void* type, bool omit_empty_base_classes) override; + GetNumChildren (void *type, bool omit_empty_base_classes) override; lldb::BasicType - GetBasicTypeEnumeration (void* type) override; + GetBasicTypeEnumeration (void *type) override; static lldb::BasicType - GetBasicTypeEnumeration (void* type, const ConstString &name); - - static uint32_t - GetNumDirectBaseClasses (const CompilerType& type); - - static uint32_t - GetNumVirtualBaseClasses (const CompilerType& type); - + GetBasicTypeEnumeration (void *type, const ConstString &name); + + void + ForEachEnumerator (void *type, std::function const &callback) override; + uint32_t - GetNumFields (void* type) override; - - static CompilerType - GetDirectBaseClassAtIndex (const CompilerType& type, - size_t idx, - uint32_t *bit_offset_ptr); - - static CompilerType - GetVirtualBaseClassAtIndex (const CompilerType& type, - size_t idx, - uint32_t *bit_offset_ptr); + GetNumFields (void *type) override; CompilerType - GetFieldAtIndex (void* type, + GetFieldAtIndex (void *type, size_t idx, std::string& name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override; - + + uint32_t + GetNumDirectBaseClasses (void *type) override; + + uint32_t + GetNumVirtualBaseClasses (void *type) override; + + CompilerType + GetDirectBaseClassAtIndex (void *type, + size_t idx, + uint32_t *bit_offset_ptr) override; + + CompilerType + GetVirtualBaseClassAtIndex (void *type, + size_t idx, + uint32_t *bit_offset_ptr) override; + static uint32_t GetNumPointeeChildren (clang::QualType type); CompilerType - GetChildClangTypeAtIndex (void* type, + GetChildClangTypeAtIndex (void *type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, @@ -859,7 +888,7 @@ public: // Lookup a child given a name. This function will match base class names // and member member names in "clang_type" only, not descendants. uint32_t - GetIndexOfChildWithName (void* type, + GetIndexOfChildWithName (void *type, const char *name, bool omit_empty_base_classes) override; @@ -869,16 +898,16 @@ public: // TODO: Return all matches for a given name by returning a vector> // so we catch all names that match a given child name, not just the first. size_t - GetIndexOfChildMemberWithName (void* type, + GetIndexOfChildMemberWithName (void *type, const char *name, bool omit_empty_base_classes, std::vector& child_indexes) override; size_t - GetNumTemplateArguments (void* type) override; + GetNumTemplateArguments (void *type) override; CompilerType - GetTemplateArgument (void* type, + GetTemplateArgument (void *type, size_t idx, lldb::TemplateArgumentKind &kind) override; @@ -906,7 +935,7 @@ public: lldb::AccessType access); clang::CXXMethodDecl * - AddMethodToCXXRecordType (void* type, + AddMethodToCXXRecordType (void *type, const char *name, const CompilerType &method_type, lldb::AccessType access, @@ -919,7 +948,7 @@ public: // C++ Base Classes clang::CXXBaseSpecifier * - CreateBaseClassSpecifier (void* type, + CreateBaseClassSpecifier (void *type, lldb::AccessType access, bool is_virtual, bool base_of_class); @@ -929,7 +958,7 @@ public: unsigned num_base_classes); bool - SetBaseClassesForClassType (void* type, + SetBaseClassesForClassType (void *type, clang::CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes); @@ -950,13 +979,13 @@ public: static clang::ObjCMethodDecl * AddMethodToObjCObjectType (const CompilerType& type, - const char *name, // the full symbol name as seen in the symbol table (void* type, "-[NString stringWithCString:]") + const char *name, // the full symbol name as seen in the symbol table (void *type, "-[NString stringWithCString:]") const CompilerType &method_clang_type, lldb::AccessType access, bool is_artificial); bool - SetHasExternalStorage (void* type, bool has_extern); + SetHasExternalStorage (void *type, bool has_extern); //------------------------------------------------------------------ @@ -972,7 +1001,7 @@ public: // Modifying Enumeration types //---------------------------------------------------------------------- bool - AddEnumerationValueToEnumerationType (void* type, + AddEnumerationValueToEnumerationType (void *type, const CompilerType &enumerator_qual_type, const Declaration &decl, const char *name, @@ -982,7 +1011,7 @@ public: CompilerType - GetEnumerationIntegerType (void* type); + GetEnumerationIntegerType (void *type); //------------------------------------------------------------------ @@ -998,7 +1027,7 @@ public: // Converts "s" to a floating point value and place resulting floating // point bytes in the "dst" buffer. size_t - ConvertStringToFloatValue (void* type, + ConvertStringToFloatValue (void *type, const char *s, uint8_t *dst, size_t dst_size) override; @@ -1006,7 +1035,7 @@ public: // Dumping types //---------------------------------------------------------------------- void - DumpValue (void* type, + DumpValue (void *type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, @@ -1021,7 +1050,7 @@ public: uint32_t depth) override; bool - DumpTypeValue (void* type, + DumpTypeValue (void *type, Stream *s, lldb::Format format, const DataExtractor &data, @@ -1032,7 +1061,7 @@ public: ExecutionContextScope *exe_scope) override; void - DumpSummary (void* type, + DumpSummary (void *type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, @@ -1040,10 +1069,10 @@ public: size_t data_byte_size) override; virtual void - DumpTypeDescription (void* type) override; // Dump to stdout + DumpTypeDescription (void *type) override; // Dump to stdout void - DumpTypeDescription (void* type, Stream *s) override; + DumpTypeDescription (void *type, Stream *s) override; static clang::EnumDecl * GetAsEnumDecl (const CompilerType& type); @@ -1053,7 +1082,7 @@ public: GetAsRecordDecl (const CompilerType& type); clang::CXXRecordDecl * - GetAsCXXRecordDecl (void* type); + GetAsCXXRecordDecl (void *type); static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl (const CompilerType& type); @@ -1184,25 +1213,15 @@ protected: clang::DeclContext * GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, - const lldb_private::SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); - clang::DeclContext * - GetClangDeclContextForDIEOffset (SymbolFileDWARF *dwarf, - const lldb_private::SymbolContext &sc, - dw_offset_t die_offset); - clang::DeclContext * GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die, const DWARFDebugInfoEntry **decl_ctx_die); - clang::DeclContext * - GetClangDeclContextContainingDIEOffset (SymbolFileDWARF *dwarf, - dw_offset_t die_offset); - bool CopyUniqueClassMethodTypes (SymbolFileDWARF *dwarf, SymbolFileDWARF *src_symfile, diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index ee4fcada8a6d..96164f29a446 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -17,7 +17,7 @@ #include "clang/AST/ASTImporter.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" +#include "lldb/Symbol/CompilerDeclContext.h" namespace lldb_private { @@ -155,7 +155,7 @@ public: // Namespace maps // - typedef std::vector < std::pair > NamespaceMap; + typedef std::vector < std::pair > NamespaceMap; typedef std::shared_ptr NamespaceMapSP; void RegisterNamespaceMap (const clang::NamespaceDecl *decl, diff --git a/lldb/include/lldb/Symbol/ClangNamespaceDecl.h b/lldb/include/lldb/Symbol/ClangNamespaceDecl.h deleted file mode 100644 index 13a4c0011aff..000000000000 --- a/lldb/include/lldb/Symbol/ClangNamespaceDecl.h +++ /dev/null @@ -1,105 +0,0 @@ -//===-- ClangNamespaceDecl.h ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ClangNamespaceDecl_h_ -#define liblldb_ClangNamespaceDecl_h_ - -#include - -#include "lldb/lldb-public.h" -#include "lldb/Core/ClangForward.h" - -namespace lldb_private { - -class ClangNamespaceDecl -{ -public: - ClangNamespaceDecl () : - m_ast (NULL), - m_namespace_decl (NULL) - { - } - - ClangNamespaceDecl (clang::ASTContext *ast, clang::NamespaceDecl *namespace_decl) : - m_ast (ast), - m_namespace_decl (namespace_decl) - { - } - - ClangNamespaceDecl (const ClangNamespaceDecl &rhs) : - m_ast (rhs.m_ast), - m_namespace_decl (rhs.m_namespace_decl) - { - } - - const ClangNamespaceDecl & - operator = (const ClangNamespaceDecl &rhs) - { - m_ast = rhs.m_ast; - m_namespace_decl = rhs.m_namespace_decl; - return *this; - } - - //------------------------------------------------------------------ - /// Convert to bool operator. - /// - /// This allows code to check a ClangNamespaceDecl object to see if - /// it contains a valid namespace decl using code such as: - /// - /// @code - /// ClangNamespaceDecl ns_decl(...); - /// if (ns_decl) - /// { ... - /// @endcode - /// - /// @return - /// /b True this object contains a valid namespace decl, \b - /// false otherwise. - //------------------------------------------------------------------ - explicit operator bool() const - { - return m_ast != NULL && m_namespace_decl != NULL; - } - - clang::ASTContext * - GetASTContext() const - { - return m_ast; - } - - void - SetASTContext (clang::ASTContext *ast) - { - m_ast = ast; - } - - clang::NamespaceDecl * - GetNamespaceDecl () const - { - return m_namespace_decl; - } - - void - SetNamespaceDecl (clang::NamespaceDecl *namespace_decl) - { - m_namespace_decl = namespace_decl; - } - - std::string - GetQualifiedName () const; - -protected: - clang::ASTContext *m_ast; - clang::NamespaceDecl *m_namespace_decl; -}; - - -} // namespace lldb_private - -#endif // #ifndef liblldb_ClangNamespaceDecl_h_ diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h new file mode 100644 index 000000000000..ba65ce764cbc --- /dev/null +++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h @@ -0,0 +1,141 @@ +//===-- CompilerDeclContext.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CompilerDeclContext_h_ +#define liblldb_CompilerDeclContext_h_ + +#include "lldb/lldb-private.h" +#include "lldb/Core/ConstString.h" + +namespace lldb_private { + +class CompilerDeclContext +{ +public: + //---------------------------------------------------------------------- + // Constructors and Destructors + //---------------------------------------------------------------------- + CompilerDeclContext () : + m_type_system (nullptr), + m_opaque_decl_ctx (nullptr) + { + } + + CompilerDeclContext (TypeSystem *type_system, void *decl_ctx) : + m_type_system (type_system), + m_opaque_decl_ctx (decl_ctx) + { + } + + ~CompilerDeclContext() + { + } + + //---------------------------------------------------------------------- + // Tests + //---------------------------------------------------------------------- + + explicit operator bool () const + { + return IsValid (); + } + + bool + operator < (const CompilerDeclContext &rhs) const + { + if (m_type_system == rhs.m_type_system) + return m_type_system < rhs.m_type_system; + return m_type_system < rhs.m_type_system; + } + + bool + IsValid () const + { + return m_type_system != nullptr && m_opaque_decl_ctx != nullptr; + } + + bool + IsClang () const; + + //---------------------------------------------------------------------- + /// Checks if this decl context represents a method of a class. + /// + /// @param[out] language_ptr + /// If non NULL and \b true is returned from this function, + /// this will indicate if the language that respresents the method. + /// + /// @param[out] is_instance_method_ptr + /// If non NULL and \b true is returned from this function, + /// this will indicate if the method is an instance function (true) + /// or a class method (false indicating the function is static, or + /// doesn't require an instance of the class to be called). + /// + /// @param[out] language_object_name_ptr + /// If non NULL and \b true is returned from this function, + /// this will indicate if implicit object name for the language + /// like "this" for C++, and "self" for Objective C. + /// + /// @return + /// Returns true if this is a decl context that represents a method + /// in a struct, union or class. + //---------------------------------------------------------------------- + bool + IsClassMethod (lldb::LanguageType *language_ptr, + bool *is_instance_method_ptr, + ConstString *language_object_name_ptr); + + //---------------------------------------------------------------------- + // Accessors + //---------------------------------------------------------------------- + + TypeSystem * + GetTypeSystem() const + { + return m_type_system; + } + + void * + GetOpaqueDeclContext() const + { + return m_opaque_decl_ctx; + } + + void + SetDeclContext (TypeSystem* type_system, void* decl_ctx) + { + m_type_system = type_system; + m_opaque_decl_ctx = decl_ctx; + } + + void + Clear() + { + m_type_system = nullptr; + m_opaque_decl_ctx = nullptr; + } + + ConstString + GetName () const; + + bool + IsStructUnionOrClass () const; + +private: + TypeSystem *m_type_system; + void *m_opaque_decl_ctx; + +}; + +bool operator == (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs); +bool operator != (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs); + + +} // namespace lldb_private + +#endif // #ifndef liblldb_CompilerDeclContext_h_ diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 152f515f1fcd..e25ac8e7e4d1 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -12,7 +12,7 @@ #include #include - +#include #include "lldb/lldb-private.h" #include "lldb/Core/ClangForward.h" @@ -235,9 +235,9 @@ public: GetTypeClass () const; void - SetClangType (TypeSystem* type_system, void* type); + SetCompilerType (TypeSystem* type_system, void* type); void - SetClangType (clang::ASTContext *ast, clang::QualType qual_type); + SetCompilerType (clang::ASTContext *ast, clang::QualType qual_type); unsigned GetTypeQualifiers() const; @@ -284,9 +284,6 @@ public: // If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType () const; - - CompilerType - RemoveFastQualifiers () const; //---------------------------------------------------------------------- // Create related types using the current type's AST @@ -321,7 +318,16 @@ public: static lldb::BasicType GetBasicTypeEnumeration (const ConstString &name); - + + //---------------------------------------------------------------------- + // If this type is an enumeration, iterate through all of its enumerators + // using a callback. If the callback returns true, keep iterating, else + // abort the iteration. + //---------------------------------------------------------------------- + void + ForEachEnumerator (std::function const &callback) const; uint32_t GetNumFields () const; @@ -331,7 +337,21 @@ public: uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const; - + + uint32_t + GetNumDirectBaseClasses () const; + + uint32_t + GetNumVirtualBaseClasses () const; + + CompilerType + GetDirectBaseClassAtIndex (size_t idx, + uint32_t *bit_offset_ptr) const; + + CompilerType + GetVirtualBaseClassAtIndex (size_t idx, + uint32_t *bit_offset_ptr) const; + uint32_t GetIndexOfFieldWithName (const char* name, CompilerType* field_clang_type = NULL, diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index a380a91e9190..01a2af182d33 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -550,8 +550,8 @@ public: /// @return /// The DeclContext, or NULL if none exists. //------------------------------------------------------------------ - clang::DeclContext * - GetClangDeclContext(); + CompilerDeclContext + GetDeclContext(); //------------------------------------------------------------------ /// Get accessor for the type that describes the function @@ -574,7 +574,7 @@ public: GetType() const; CompilerType - GetClangType (); + GetCompilerType (); uint32_t GetPrologueByteSize (); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 8c6db5575768..63418625cb81 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -13,7 +13,8 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" +#include "lldb/Symbol/CompilerDeclContext.h" + #include "lldb/Symbol/Type.h" namespace lldb_private { @@ -130,15 +131,15 @@ public: virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0; virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0; virtual bool CompleteType (CompilerType &clang_type) = 0; - virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { return NULL; } - virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { return NULL; } + virtual CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) { return CompilerDeclContext(); } + virtual CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t uid) { return CompilerDeclContext(); } virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0; - virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) = 0; - virtual uint32_t FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) = 0; - virtual uint32_t FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) = 0; - virtual uint32_t FindFunctions (const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) = 0; - virtual uint32_t FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) = 0; - virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types) = 0; + virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list); + virtual uint32_t FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables); + virtual uint32_t FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables); + virtual uint32_t FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list); + virtual uint32_t FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list); + virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeList& types); // virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0; virtual TypeList * GetTypeList (); virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, @@ -150,10 +151,13 @@ public: virtual lldb_private::TypeSystem * GetTypeSystemForLanguage (lldb::LanguageType language); - virtual ClangNamespaceDecl + virtual CompilerDeclContext FindNamespace (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *parent_namespace_decl) = 0; + const CompilerDeclContext *parent_decl_ctx) + { + return CompilerDeclContext(); + } ObjectFile* GetObjectFile() { return m_obj_file; } const ObjectFile* GetObjectFile() const { return m_obj_file; } diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index 248918af2833..cbf2181bffc9 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -15,7 +15,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/TypeList.h" @@ -97,7 +96,7 @@ public: virtual size_t FindGlobalVariables (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables); @@ -110,7 +109,7 @@ public: virtual size_t FindFunctions (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, @@ -125,15 +124,15 @@ public: virtual size_t FindTypes (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeList& types); - virtual ClangNamespaceDecl + virtual CompilerDeclContext FindNamespace (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *parent_namespace_decl); + const CompilerDeclContext *parent_decl_ctx); virtual size_t GetNumCompileUnits(); diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index f6e89ecd254c..616a2fc64e6f 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -241,18 +241,18 @@ public: // Get the clang type, and resolve definitions for any // class/struct/union/enum types completely. CompilerType - GetClangFullType (); + GetFullCompilerType (); // Get the clang type, and resolve definitions enough so that the type could // have layout performed. This allows ptrs and refs to class/struct/union/enum // types remain forward declarations. CompilerType - GetClangLayoutType (); + GetLayoutCompilerType (); // Get the clang type and leave class/struct/union/enum types as forward // declarations if they haven't already been fully defined. CompilerType - GetClangForwardType (); + GetForwardCompilerType (); ClangASTContext & GetClangASTContext (); @@ -276,12 +276,6 @@ public: uint32_t GetEncodingMask (); - CompilerType - CreateClangTypedefType (Type *typedef_type, Type *base_type); - - bool - IsRealObjCClass(); - bool IsCompleteObjCClass() { @@ -340,10 +334,10 @@ public: } TypePair (lldb::TypeSP type) : - clang_type(), - type_sp(type) + clang_type(), + type_sp(type) { - clang_type = type_sp->GetClangForwardType(); + clang_type = type_sp->GetForwardCompilerType (); } bool @@ -392,7 +386,7 @@ public: GetDisplayTypeName () const { if (type_sp) - return type_sp->GetClangForwardType().GetDisplayTypeName(); + return type_sp->GetForwardCompilerType ().GetDisplayTypeName(); if (clang_type) return clang_type.GetDisplayTypeName(); return ConstString(); @@ -409,7 +403,7 @@ public: SetType (lldb::TypeSP type) { type_sp = type; - clang_type = type_sp->GetClangForwardType(); + clang_type = type_sp->GetForwardCompilerType (); } lldb::TypeSP @@ -428,7 +422,7 @@ public: GetPointerType () const { if (type_sp) - return type_sp->GetClangLayoutType().GetPointerType(); + return type_sp->GetLayoutCompilerType ().GetPointerType(); return clang_type.GetPointerType(); } @@ -436,7 +430,7 @@ public: GetPointeeType () const { if (type_sp) - return type_sp->GetClangFullType().GetPointeeType(); + return type_sp->GetFullCompilerType ().GetPointeeType(); return clang_type.GetPointeeType(); } @@ -444,7 +438,7 @@ public: GetReferenceType () const { if (type_sp) - return ClangASTContext::GetLValueReferenceType(type_sp->GetClangLayoutType()); + return ClangASTContext::GetLValueReferenceType(type_sp->GetLayoutCompilerType ()); return ClangASTContext::GetLValueReferenceType(clang_type); } @@ -452,7 +446,7 @@ public: GetTypedefedType () const { if (type_sp) - return type_sp->GetClangFullType().GetTypedefedType(); + return type_sp->GetFullCompilerType ().GetTypedefedType(); return clang_type.GetTypedefedType(); } @@ -460,7 +454,7 @@ public: GetDereferencedType () const { if (type_sp) - return type_sp->GetClangFullType().GetNonReferenceType(); + return type_sp->GetFullCompilerType ().GetNonReferenceType(); return clang_type.GetNonReferenceType(); } @@ -468,7 +462,7 @@ public: GetUnqualifiedType () const { if (type_sp) - return type_sp->GetClangLayoutType().GetFullyUnqualifiedType(); + return type_sp->GetLayoutCompilerType ().GetFullyUnqualifiedType(); return clang_type.GetFullyUnqualifiedType(); } @@ -476,7 +470,7 @@ public: GetCanonicalType () const { if (type_sp) - return type_sp->GetClangFullType().GetCanonicalType(); + return type_sp->GetFullCompilerType ().GetCanonicalType(); return clang_type.GetCanonicalType(); } @@ -910,8 +904,9 @@ public: { } - TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl, - const lldb_private::CompilerType& integer_type); + TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp, + const ConstString &name, + const llvm::APSInt &value); TypeEnumMemberImpl (const TypeEnumMemberImpl& rhs) : m_integer_type_sp(rhs.m_integer_type_sp), diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 0083a3981edc..838dc8a3edbf 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -10,9 +10,11 @@ #ifndef liblldb_TypeSystem_h_ #define liblldb_TypeSystem_h_ +#include #include #include "lldb/lldb-private.h" #include "lldb/Core/ClangForward.h" +#include "lldb/Symbol/CompilerDeclContext.h" #include "clang/AST/CharUnits.h" #include "clang/AST/Type.h" @@ -65,6 +67,22 @@ public: return false; } + virtual CompilerDeclContext + GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *dwarf_cu, + const DWARFDebugInfoEntry* die) + { + return CompilerDeclContext(); + } + + virtual CompilerDeclContext + GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *dwarf_cu, + const DWARFDebugInfoEntry* die) + { + return CompilerDeclContext(); + } + virtual SymbolFile * GetSymbolFile () const { @@ -78,98 +96,83 @@ public: m_sym_file = sym_file; } + //---------------------------------------------------------------------- + // CompilerDeclContext functions + //---------------------------------------------------------------------- + virtual bool - DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl, - SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die) - { - return false; - } + DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) = 0; - virtual clang::NamespaceDecl * - ResolveNamespaceDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry *die) - { - return nullptr; - } + virtual ConstString + DeclContextGetName (void *opaque_decl_ctx) = 0; - virtual clang::DeclContext* - GetClangDeclContextForTypeUID (SymbolFileDWARF *dwarf, - const lldb_private::SymbolContext &sc, - lldb::user_id_t type_uid) - { - return nullptr; - } - - virtual clang::DeclContext* - GetClangDeclContextContainingTypeUID (SymbolFileDWARF *dwarf, lldb::user_id_t type_uid) - { - return nullptr; - } + virtual bool + DeclContextIsClassMethod (void *opaque_decl_ctx, + lldb::LanguageType *language_ptr, + bool *is_instance_method_ptr, + ConstString *language_object_name_ptr) = 0; //---------------------------------------------------------------------- // Tests //---------------------------------------------------------------------- virtual bool - IsArrayType (void * type, + IsArrayType (void *type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) = 0; virtual bool - IsAggregateType (void * type) = 0; + IsAggregateType (void *type) = 0; virtual bool - IsCharType (void * type) = 0; + IsCharType (void *type) = 0; virtual bool - IsCompleteType (void * type) = 0; + IsCompleteType (void *type) = 0; virtual bool - IsDefined(void * type) = 0; + IsDefined(void *type) = 0; virtual bool - IsFloatingPointType (void * type, uint32_t &count, bool &is_complex) = 0; + IsFloatingPointType (void *type, uint32_t &count, bool &is_complex) = 0; virtual bool - IsFunctionType (void * type, bool *is_variadic_ptr) = 0; - + IsFunctionType (void *type, bool *is_variadic_ptr) = 0; + virtual size_t - GetNumberOfFunctionArguments (void * type) = 0; + GetNumberOfFunctionArguments (void *type) = 0; virtual CompilerType - GetFunctionArgumentAtIndex (void * type, const size_t index) = 0; + GetFunctionArgumentAtIndex (void *type, const size_t index) = 0; virtual bool - IsFunctionPointerType (void * type) = 0; + IsFunctionPointerType (void *type) = 0; virtual bool - IsIntegerType (void * type, bool &is_signed) = 0; + IsIntegerType (void *type, bool &is_signed) = 0; virtual bool - IsPossibleDynamicType (void * type, + IsPossibleDynamicType (void *type, CompilerType *target_type, // Can pass NULL bool check_cplusplus, bool check_objc) = 0; virtual bool - IsPointerType (void * type, CompilerType *pointee_type) = 0; + IsPointerType (void *type, CompilerType *pointee_type) = 0; virtual bool - IsScalarType (void * type) = 0; + IsScalarType (void *type) = 0; virtual bool - IsVoidType (void * type) = 0; + IsVoidType (void *type) = 0; //---------------------------------------------------------------------- // Type Completion //---------------------------------------------------------------------- virtual bool - GetCompleteType (void * type) = 0; + GetCompleteType (void *type) = 0; //---------------------------------------------------------------------- // AST related queries @@ -183,82 +186,103 @@ public: //---------------------------------------------------------------------- virtual ConstString - GetTypeName (void * type) = 0; + GetTypeName (void *type) = 0; virtual uint32_t - GetTypeInfo (void * type, CompilerType *pointee_or_element_clang_type) = 0; + GetTypeInfo (void *type, CompilerType *pointee_or_element_clang_type) = 0; virtual lldb::LanguageType - GetMinimumLanguage (void * type) = 0; + GetMinimumLanguage (void *type) = 0; virtual lldb::TypeClass - GetTypeClass (void * type) = 0; + GetTypeClass (void *type) = 0; //---------------------------------------------------------------------- // Creating related types //---------------------------------------------------------------------- virtual CompilerType - GetArrayElementType (void * type, uint64_t *stride) = 0; + GetArrayElementType (void *type, uint64_t *stride) = 0; virtual CompilerType - GetCanonicalType (void * type) = 0; + GetCanonicalType (void *type) = 0; // Returns -1 if this isn't a function of if the function doesn't have a prototype // Returns a value >= 0 if there is a prototype. virtual int - GetFunctionArgumentCount (void * type) = 0; + GetFunctionArgumentCount (void *type) = 0; virtual CompilerType - GetFunctionArgumentTypeAtIndex (void * type, size_t idx) = 0; + GetFunctionArgumentTypeAtIndex (void *type, size_t idx) = 0; virtual CompilerType - GetFunctionReturnType (void * type) = 0; + GetFunctionReturnType (void *type) = 0; virtual size_t - GetNumMemberFunctions (void * type) = 0; + GetNumMemberFunctions (void *type) = 0; virtual TypeMemberFunctionImpl - GetMemberFunctionAtIndex (void * type, size_t idx) = 0; + GetMemberFunctionAtIndex (void *type, size_t idx) = 0; virtual CompilerType - GetPointeeType (void * type) = 0; + GetPointeeType (void *type) = 0; virtual CompilerType - GetPointerType (void * type) = 0; + GetPointerType (void *type) = 0; //---------------------------------------------------------------------- // Exploring the type //---------------------------------------------------------------------- virtual uint64_t - GetBitSize (void * type, ExecutionContextScope *exe_scope) = 0; + GetBitSize (void *type, ExecutionContextScope *exe_scope) = 0; virtual lldb::Encoding - GetEncoding (void * type, uint64_t &count) = 0; + GetEncoding (void *type, uint64_t &count) = 0; virtual lldb::Format - GetFormat (void * type) = 0; + GetFormat (void *type) = 0; virtual uint32_t - GetNumChildren (void * type, bool omit_empty_base_classes) = 0; + GetNumChildren (void *type, bool omit_empty_base_classes) = 0; virtual lldb::BasicType - GetBasicTypeEnumeration (void * type) = 0; - + GetBasicTypeEnumeration (void *type) = 0; + + virtual void + ForEachEnumerator (void *type, std::function const &callback) + { + } + virtual uint32_t - GetNumFields (void * type) = 0; + GetNumFields (void *type) = 0; virtual CompilerType - GetFieldAtIndex (void * type, + GetFieldAtIndex (void *type, size_t idx, std::string& name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) = 0; - + + virtual uint32_t + GetNumDirectBaseClasses (void *type) = 0; + + virtual uint32_t + GetNumVirtualBaseClasses (void *type) = 0; + virtual CompilerType - GetChildClangTypeAtIndex (void * type, + GetDirectBaseClassAtIndex (void *type, + size_t idx, + uint32_t *bit_offset_ptr) = 0; + + virtual CompilerType + GetVirtualBaseClassAtIndex (void *type, + size_t idx, + uint32_t *bit_offset_ptr) = 0; + + virtual CompilerType + GetChildClangTypeAtIndex (void *type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, @@ -276,7 +300,7 @@ public: // Lookup a child given a name. This function will match base class names // and member member names in "clang_type" only, not descendants. virtual uint32_t - GetIndexOfChildWithName (void * type, + GetIndexOfChildWithName (void *type, const char *name, bool omit_empty_base_classes) = 0; @@ -286,16 +310,16 @@ public: // TODO: Return all matches for a given name by returning a vector> // so we catch all names that match a given child name, not just the first. virtual size_t - GetIndexOfChildMemberWithName (void * type, + GetIndexOfChildMemberWithName (void *type, const char *name, bool omit_empty_base_classes, std::vector& child_indexes) = 0; virtual size_t - GetNumTemplateArguments (void * type) = 0; + GetNumTemplateArguments (void *type) = 0; virtual CompilerType - GetTemplateArgument (void * type, + GetTemplateArgument (void *type, size_t idx, lldb::TemplateArgumentKind &kind) = 0; @@ -303,7 +327,7 @@ public: // Dumping types //---------------------------------------------------------------------- virtual void - DumpValue (void * type, + DumpValue (void *type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, @@ -318,7 +342,7 @@ public: uint32_t depth) = 0; virtual bool - DumpTypeValue (void * type, + DumpTypeValue (void *type, Stream *s, lldb::Format format, const DataExtractor &data, @@ -329,20 +353,20 @@ public: ExecutionContextScope *exe_scope) = 0; virtual void - DumpTypeDescription (void * type) = 0; // Dump to stdout + DumpTypeDescription (void *type) = 0; // Dump to stdout virtual void - DumpTypeDescription (void * type, Stream *s) = 0; + DumpTypeDescription (void *type, Stream *s) = 0; //---------------------------------------------------------------------- // TODO: These methods appear unused. Should they be removed? //---------------------------------------------------------------------- virtual bool - IsRuntimeGeneratedType (void * type) = 0; + IsRuntimeGeneratedType (void *type) = 0; virtual void - DumpSummary (void * type, + DumpSummary (void *type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, @@ -352,7 +376,7 @@ public: // Converts "s" to a floating point value and place resulting floating // point bytes in the "dst" buffer. virtual size_t - ConvertStringToFloatValue (void * type, + ConvertStringToFloatValue (void *type, const char *s, uint8_t *dst, size_t dst_size) = 0; @@ -362,52 +386,52 @@ public: //---------------------------------------------------------------------- virtual bool - IsPointerOrReferenceType (void * type, CompilerType *pointee_type) = 0; + IsPointerOrReferenceType (void *type, CompilerType *pointee_type) = 0; virtual unsigned - GetTypeQualifiers(void * type) = 0; + GetTypeQualifiers(void *type) = 0; virtual bool - IsCStringType (void * type, uint32_t &length) = 0; + IsCStringType (void *type, uint32_t &length) = 0; virtual size_t - GetTypeBitAlign (void * type) = 0; + GetTypeBitAlign (void *type) = 0; virtual CompilerType - GetBasicTypeFromAST (void * type, lldb::BasicType basic_type) = 0; + GetBasicTypeFromAST (lldb::BasicType basic_type) = 0; virtual bool - IsBeingDefined (void * type) = 0; + IsBeingDefined (void *type) = 0; virtual bool - IsConst(void * type) = 0; + IsConst(void *type) = 0; virtual uint32_t - IsHomogeneousAggregate (void * type, CompilerType* base_type_ptr) = 0; + IsHomogeneousAggregate (void *type, CompilerType* base_type_ptr) = 0; virtual bool - IsPolymorphicClass (void * type) = 0; + IsPolymorphicClass (void *type) = 0; virtual bool - IsTypedefType (void * type) = 0; + IsTypedefType (void *type) = 0; // If the current object represents a typedef type, get the underlying type virtual CompilerType - GetTypedefedType (void * type) = 0; + GetTypedefedType (void *type) = 0; virtual bool - IsVectorType (void * type, + IsVectorType (void *type, CompilerType *element_type, uint64_t *size) = 0; virtual CompilerType - GetFullyUnqualifiedType (void * type) = 0; + GetFullyUnqualifiedType (void *type) = 0; virtual CompilerType - GetNonReferenceType (void * type) = 0; + GetNonReferenceType (void *type) = 0; virtual bool - IsReferenceType (void * type, CompilerType *pointee_type, bool* is_rvalue) = 0; + IsReferenceType (void *type, CompilerType *pointee_type, bool* is_rvalue) = 0; protected: SymbolFile *m_sym_file; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index b190246a95e2..87c61e941655 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -48,7 +48,6 @@ class ClangASTContext; class ClangASTImporter; class ClangASTMetadata; class ClangASTSource; -class ClangNamespaceDecl; class ClangExpression; class ClangExpressionDeclMap; class ClangExpressionParser; @@ -67,6 +66,7 @@ class CommandObject; class CommandReturnObject; class Communication; class CompactUnwindInfo; +class CompilerDeclContext; class CompilerType; class CompileUnit; class Condition; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index e34ef57c628e..63e0354abfc0 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -169,6 +169,7 @@ 2656BBC41AE073A800441749 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; 2656BBC51AE073AD00441749 /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 260157C41885F4FF00F875CF /* libpanel.dylib */; }; 2656BBC61AE073B500441749 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 966C6B7818E6A56A0093F5EC /* libz.dylib */; }; + 2657AFB71B86910100958979 /* CompilerDeclContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2657AFB61B86910100958979 /* CompilerDeclContext.cpp */; settings = {ASSET_TAGS = (); }; }; 2660AAB914622483003A9694 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; settings = {COMPILER_FLAGS = "-Dregister="; }; }; 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26651A17133BF9DF005B64B7 /* Opcode.cpp */; }; 266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266603C91345B5A8004DA8B6 /* ConnectionSharedMemory.cpp */; }; @@ -474,7 +475,6 @@ 268900D113353E6F00698AC0 /* ClangASTContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */; }; 268900D213353E6F00698AC0 /* CompilerType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* CompilerType.cpp */; }; 268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */; }; - 268900D413353E6F00698AC0 /* ClangNamespaceDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */; }; 268900D513353E6F00698AC0 /* CompileUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */; }; 268900D613353E6F00698AC0 /* Declaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1610F1B8EC00F91463 /* Declaration.cpp */; }; 268900D713353E6F00698AC0 /* DWARFCallFrameInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1710F1B8EC00F91463 /* DWARFCallFrameInfo.cpp */; }; @@ -1447,6 +1447,8 @@ 265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextKDP_x86_64.cpp; sourceTree = ""; }; 265205A713D3E3F700132FE2 /* RegisterContextKDP_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_x86_64.h; sourceTree = ""; }; 26579F68126A25920007C5CB /* darwin-debug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "darwin-debug"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2657AFB51B8690EC00958979 /* CompilerDeclContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CompilerDeclContext.h; path = include/lldb/Symbol/CompilerDeclContext.h; sourceTree = ""; }; + 2657AFB61B86910100958979 /* CompilerDeclContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompilerDeclContext.cpp; path = source/Symbol/CompilerDeclContext.cpp; sourceTree = ""; }; 265ABF6210F42EE900531910 /* DebugSymbols.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DebugSymbols.framework; path = /System/Library/PrivateFrameworks/DebugSymbols.framework; sourceTree = ""; }; 265E9BE1115C2BAA00D0DCCB /* debugserver.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = debugserver.xcodeproj; path = tools/debugserver/debugserver.xcodeproj; sourceTree = ""; }; 2660D9F611922A1300958FBD /* StringExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractor.cpp; path = source/Utility/StringExtractor.cpp; sourceTree = ""; }; @@ -1627,8 +1629,6 @@ 266960601199F4230075C61A /* build-swig-Python.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "build-swig-Python.sh"; sourceTree = ""; }; 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "edit-swig-python-wrapper-file.py"; sourceTree = ""; }; 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = ""; }; - 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = ""; }; - 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = ""; }; 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystem.cpp; path = source/Target/OperatingSystem.cpp; sourceTree = ""; }; 266DFE9813FD658300D0C574 /* OperatingSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OperatingSystem.h; path = include/lldb/Target/OperatingSystem.h; sourceTree = ""; }; 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = ""; }; @@ -4146,14 +4146,14 @@ 26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */, 49D8FB3713B5594900411094 /* ClangASTImporter.h */, 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */, + 2657AFB51B8690EC00958979 /* CompilerDeclContext.h */, + 2657AFB61B86910100958979 /* CompilerDeclContext.cpp */, 49E45FA911F660DC008F7B28 /* CompilerType.h */, 49E45FAD11F660FE008F7B28 /* CompilerType.cpp */, 495B38431489714C002708C5 /* ClangExternalASTSourceCommon.h */, 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */, 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */, 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */, - 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */, - 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */, 964463ED1A330C1B00154ED8 /* CompactUnwindInfo.h */, 964463EB1A330C0500154ED8 /* CompactUnwindInfo.cpp */, 26BC7C5710F1B6E900F91463 /* CompileUnit.h */, @@ -6264,7 +6264,6 @@ 2613F6C81B17B82F00D4DB85 /* CxaDemangle.cpp in Sources */, 268900D213353E6F00698AC0 /* CompilerType.cpp in Sources */, 268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */, - 268900D413353E6F00698AC0 /* ClangNamespaceDecl.cpp in Sources */, 268900D513353E6F00698AC0 /* CompileUnit.cpp in Sources */, 268900D613353E6F00698AC0 /* Declaration.cpp in Sources */, 268900D713353E6F00698AC0 /* DWARFCallFrameInfo.cpp in Sources */, @@ -6463,6 +6462,7 @@ 26EFC4CD18CFAF0D00865D87 /* ObjectFileJIT.cpp in Sources */, 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */, 494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */, + 2657AFB71B86910100958979 /* CompilerDeclContext.cpp in Sources */, 49DA65031485C92A005FF180 /* AppleObjCDeclVendor.cpp in Sources */, 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */, 26A527C114E24F5F00F3A14A /* ProcessMachCore.cpp in Sources */, diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 0c089f5d47fc..ed2a0a74f774 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -14,10 +14,10 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" +#include "llvm/ADT/APSInt.h" #include "clang/AST/Decl.h" using namespace lldb; @@ -343,12 +343,7 @@ SBType SBType::GetBasicType(lldb::BasicType basic_type) { if (IsValid() && m_opaque_sp->IsValid()) - { - ClangASTContext* ast = m_opaque_sp->GetTypeSystem(false)->AsClangASTContext(); - if (ast) - return SBType (ClangASTContext::GetBasicType (ast->getASTContext(), basic_type)); - } - + return SBType(m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type)); return SBType(); } @@ -356,7 +351,7 @@ uint32_t SBType::GetNumberOfDirectBaseClasses () { if (IsValid()) - return ClangASTContext::GetNumDirectBaseClasses(m_opaque_sp->GetCompilerType(true)); + return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses(); return 0; } @@ -364,7 +359,7 @@ uint32_t SBType::GetNumberOfVirtualBaseClasses () { if (IsValid()) - return ClangASTContext::GetNumVirtualBaseClasses(m_opaque_sp->GetCompilerType(true)); + return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses(); return 0; } @@ -399,16 +394,10 @@ SBType::GetDirectBaseClassAtIndex (uint32_t idx) SBTypeMember sb_type_member; if (IsValid()) { - CompilerType this_type (m_opaque_sp->GetCompilerType (true)); - if (this_type.IsValid()) - { - uint32_t bit_offset = 0; - CompilerType base_class_type (ClangASTContext::GetDirectBaseClassAtIndex(this_type, idx, &bit_offset)); - if (base_class_type.IsValid()) - { - sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); - } - } + uint32_t bit_offset = 0; + CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetDirectBaseClassAtIndex(idx, &bit_offset); + if (base_class_type.IsValid()) + sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } return sb_type_member; @@ -420,16 +409,10 @@ SBType::GetVirtualBaseClassAtIndex (uint32_t idx) SBTypeMember sb_type_member; if (IsValid()) { - CompilerType this_type (m_opaque_sp->GetCompilerType (true)); - if (this_type.IsValid()) - { - uint32_t bit_offset = 0; - CompilerType base_class_type (ClangASTContext::GetVirtualBaseClassAtIndex(this_type, idx, &bit_offset)); - if (base_class_type.IsValid()) - { - sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); - } - } + uint32_t bit_offset = 0; + CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetVirtualBaseClassAtIndex(idx, &bit_offset); + if (base_class_type.IsValid()) + sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } return sb_type_member; } @@ -440,16 +423,14 @@ SBType::GetEnumMembers () SBTypeEnumMemberList sb_enum_member_list; if (IsValid()) { - const clang::EnumDecl *enum_decl = ClangASTContext::GetAsEnumDecl(m_opaque_sp->GetCompilerType(true).GetFullyUnqualifiedType()); - if (enum_decl) + CompilerType this_type (m_opaque_sp->GetCompilerType (true)); + if (this_type.IsValid()) { - clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; - for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) - { - SBTypeEnumMember enum_member; - enum_member.reset(new TypeEnumMemberImpl(*enum_pos, CompilerType(m_opaque_sp->GetTypeSystem(true), enum_decl->getIntegerType().getAsOpaquePtr()))); + this_type.ForEachEnumerator([&sb_enum_member_list] (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value) -> bool { + SBTypeEnumMember enum_member (lldb::TypeEnumMemberImplSP (new TypeEnumMemberImpl(lldb::TypeImplSP(new TypeImpl(integer_type)), name, value))); sb_enum_member_list.Append(enum_member); - } + return true; // Keep iterating + }); } } return sb_enum_member_list; diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index cd5ba6775986..e44488a819c6 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -1319,7 +1319,7 @@ SBValue::GetOpaqueType() ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) - return value_sp->GetClangType().GetOpaqueQualType(); + return value_sp->GetCompilerType().GetOpaqueQualType(); return NULL; } @@ -1812,7 +1812,7 @@ SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error) watch_type |= LLDB_WATCH_TYPE_WRITE; Error rc; - CompilerType type (value_sp->GetClangType()); + CompilerType type (value_sp->GetCompilerType()); WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc); error.SetError(rc); diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 136cea022d1a..c7f62aeae6e6 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index 32afc48537fb..5443c8492be9 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -234,7 +234,7 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) return false; } - value.SetClangType (clang_type); + value.SetCompilerType (clang_type); value_list.PushValue(value); } diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 4b3ba112171f..9eca2a8bb13a 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -533,7 +533,7 @@ protected: clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name)); if (tdecl) { - clang_ast_type.SetClangType(ClangASTContext::GetASTContext(&tdecl->getASTContext()),(const lldb::clang_type_t)tdecl->getTypeForDecl()); + clang_ast_type.SetCompilerType(ClangASTContext::GetASTContext(&tdecl->getASTContext()),(const lldb::clang_type_t)tdecl->getTypeForDecl()); } } @@ -550,7 +550,7 @@ protected: else { TypeSP type_sp (type_list.GetTypeAtIndex(0)); - clang_ast_type = type_sp->GetClangFullType(); + clang_ast_type = type_sp->GetFullCompilerType (); } } @@ -1124,7 +1124,7 @@ protected: result_sp.get()) { uint64_t value = result_sp->GetValueAsUnsigned(0); - switch (result_sp->GetClangType().GetByteSize(nullptr)) + switch (result_sp->GetCompilerType().GetByteSize(nullptr)) { case 1: { uint8_t byte = (uint8_t)value; diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 03d115670b8a..715a713de3d6 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1871,7 +1871,7 @@ LookupTypeInModule (CommandInterpreter &interpreter, { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetClangFullType (); + type_sp->GetFullCompilerType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); // Print all typedef chains TypeSP typedef_type_sp (type_sp); @@ -1880,7 +1880,7 @@ LookupTypeInModule (CommandInterpreter &interpreter, { strm.EOL(); strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString()); - typedefed_type_sp->GetClangFullType (); + typedefed_type_sp->GetFullCompilerType (); typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true); typedef_type_sp = typedefed_type_sp; typedefed_type_sp = typedef_type_sp->GetTypedefType(); @@ -1924,7 +1924,7 @@ LookupTypeHere (CommandInterpreter &interpreter, { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetClangFullType (); + type_sp->GetFullCompilerType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); // Print all typedef chains TypeSP typedef_type_sp (type_sp); @@ -1933,7 +1933,7 @@ LookupTypeHere (CommandInterpreter &interpreter, { strm.EOL(); strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString()); - typedefed_type_sp->GetClangFullType (); + typedefed_type_sp->GetFullCompilerType (); typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true); typedef_type_sp = typedefed_type_sp; typedefed_type_sp = typedef_type_sp->GetTypedefType(); diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index c1c02de745d6..d3b282e2c600 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -1061,7 +1061,7 @@ protected: size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize() : m_option_watchpoint.watch_size; } - clang_type = valobj_sp->GetClangType(); + clang_type = valobj_sp->GetCompilerType(); } else { @@ -1295,7 +1295,7 @@ protected: // Fetch the type from the value object, the type of the watched object is the pointee type /// of the expression, so convert to that if we found a valid type. - CompilerType clang_type(valobj_sp->GetClangType()); + CompilerType clang_type(valobj_sp->GetCompilerType()); Error error; Watchpoint *wp = target->CreateWatchpoint(addr, size, &clang_type, watch_type, error).get(); diff --git a/lldb/source/Core/AddressResolverName.cpp b/lldb/source/Core/AddressResolverName.cpp index 1c6205fa6bdf..293002ad517f 100644 --- a/lldb/source/Core/AddressResolverName.cpp +++ b/lldb/source/Core/AddressResolverName.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Symbol.h" diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index e6669f558fb1..232d6a52cc6c 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -28,7 +28,6 @@ #include "lldb/Interpreter/OptionValueDictionary.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/OptionValueUInt64.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContext.h" diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index d67860fc1f8c..e261a8520854 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -885,10 +885,10 @@ DumpValue (Stream &s, } // TODO use flags for these - const uint32_t type_info_flags = target->GetClangType().GetTypeInfo(NULL); + const uint32_t type_info_flags = target->GetCompilerType().GetTypeInfo(NULL); bool is_array = (type_info_flags & eTypeIsArray) != 0; bool is_pointer = (type_info_flags & eTypeIsPointer) != 0; - bool is_aggregate = target->GetClangType().IsAggregateType(); + bool is_aggregate = target->GetCompilerType().IsAggregateType(); if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eValueObjectRepresentationStyleValue) // this should be wrong, but there are some exceptions { @@ -1788,7 +1788,7 @@ FormatEntity::Format (const Entry &entry, ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp)); const char *var_representation = nullptr; const char *var_name = var_value_sp->GetName().GetCString(); - if (var_value_sp->GetClangType().IsAggregateType() && + if (var_value_sp->GetCompilerType().IsAggregateType() && DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get())) { static StringSummaryFormat format(TypeSummaryImpl::Flags() diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index fff9970a649f..23d426dbd3b5 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -723,14 +723,14 @@ Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t li size_t Module::FindGlobalVariables (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables) { SymbolVendor *symbols = GetSymbolVendor (); if (symbols) - return symbols->FindGlobalVariables(name, namespace_decl, append, max_matches, variables); + return symbols->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables); return 0; } @@ -773,7 +773,7 @@ Module::FindCompileUnits (const FileSpec &path, size_t Module::FindFunctions (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_symbols, bool include_inlines, @@ -803,7 +803,7 @@ Module::FindFunctions (const ConstString &name, if (symbols) { symbols->FindFunctions(lookup_name, - namespace_decl, + parent_decl_ctx, lookup_name_type_mask, include_inlines, append, @@ -843,7 +843,7 @@ Module::FindFunctions (const ConstString &name, { if (symbols) { - symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list); + symbols->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list); // Now check our symbol table for symbols that are code symbols if requested if (include_symbols) @@ -961,7 +961,7 @@ Module::FindAddressesForLine (const lldb::TargetSP target_sp, size_t Module::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeList& types) @@ -971,7 +971,7 @@ Module::FindTypes_Impl (const SymbolContext& sc, { SymbolVendor *symbols = GetSymbolVendor (); if (symbols) - return symbols->FindTypes(sc, name, namespace_decl, append, max_matches, types); + return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types); } return 0; } @@ -979,12 +979,12 @@ Module::FindTypes_Impl (const SymbolContext& sc, size_t Module::FindTypesInNamespace (const SymbolContext& sc, const ConstString &type_name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList& type_list) { const bool append = true; - return FindTypes_Impl(sc, type_name, namespace_decl, append, max_matches, type_list); + return FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, type_list); } lldb::TypeSP diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index d89831e6a255..9f92913aa52e 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -22,7 +22,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/VariableList.h" diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index b93c9d8cd460..2d1b517d65e7 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -18,7 +18,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/Stream.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index 0b2bb4899d7c..01d7927dce54 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -275,7 +275,7 @@ Value::GetValueByteSize (Error *error_ptr) case eContextTypeLLDBType: // Type * case eContextTypeVariable: // Variable * { - const CompilerType &ast_type = GetClangType(); + const CompilerType &ast_type = GetCompilerType(); if (ast_type.IsValid()) byte_size = ast_type.GetByteSize(nullptr); } @@ -298,7 +298,7 @@ Value::GetValueByteSize (Error *error_ptr) } const CompilerType & -Value::GetClangType () +Value::GetCompilerType () { if (!m_clang_type.IsValid()) { @@ -314,7 +314,7 @@ Value::GetClangType () { Type *lldb_type = GetType(); if (lldb_type) - m_clang_type = lldb_type->GetClangForwardType(); + m_clang_type = lldb_type->GetForwardCompilerType (); } break; @@ -325,7 +325,7 @@ Value::GetClangType () { Type *variable_type = variable->GetType(); if (variable_type) - m_clang_type = variable_type->GetClangForwardType(); + m_clang_type = variable_type->GetForwardCompilerType (); } } break; @@ -336,7 +336,7 @@ Value::GetClangType () } void -Value::SetClangType (const CompilerType &clang_type) +Value::SetCompilerType (const CompilerType &clang_type) { m_clang_type = clang_type; } @@ -355,7 +355,7 @@ Value::GetValueDefaultFormat () case eContextTypeLLDBType: case eContextTypeVariable: { - const CompilerType &ast_type = GetClangType(); + const CompilerType &ast_type = GetCompilerType(); if (ast_type.IsValid()) return ast_type.GetFormat(); } @@ -407,7 +407,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, lldb::addr_t address = LLDB_INVALID_ADDRESS; AddressType address_type = eAddressTypeFile; Address file_so_addr; - const CompilerType &ast_type = GetClangType(); + const CompilerType &ast_type = GetCompilerType(); switch (m_value_type) { case eValueTypeVector: @@ -721,7 +721,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, Scalar & Value::ResolveValue(ExecutionContext *exe_ctx) { - const CompilerType &clang_type = GetClangType(); + const CompilerType &clang_type = GetCompilerType(); if (clang_type.IsValid()) { switch (m_value_type) diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 90e73c440884..96ba0b344503 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -325,7 +325,7 @@ ValueObject::ClearDynamicTypeInformation () CompilerType ValueObject::MaybeCalculateCompleteType () { - CompilerType clang_type(GetClangTypeImpl()); + CompilerType clang_type(GetCompilerTypeImpl()); if (m_did_calculate_complete_objc_class_type) { @@ -371,7 +371,7 @@ ValueObject::MaybeCalculateCompleteType () if (complete_objc_class_type_sp) { - CompilerType complete_class(complete_objc_class_type_sp->GetClangFullType()); + CompilerType complete_class(complete_objc_class_type_sp->GetFullCompilerType ()); if (complete_class.GetCompleteType()) { @@ -396,7 +396,7 @@ ValueObject::MaybeCalculateCompleteType () } CompilerType -ValueObject::GetClangType () +ValueObject::GetCompilerType () { return MaybeCalculateCompleteType(); } @@ -404,7 +404,7 @@ ValueObject::GetClangType () TypeImpl ValueObject::GetTypeImpl () { - return TypeImpl(GetClangType()); + return TypeImpl(GetCompilerType()); } DataExtractor & @@ -726,7 +726,7 @@ size_t ValueObject::GetIndexOfChildWithName (const ConstString &name) { bool omit_empty_base_classes = true; - return GetClangType().GetIndexOfChildWithName (name.GetCString(), omit_empty_base_classes); + return GetCompilerType().GetIndexOfChildWithName (name.GetCString(), omit_empty_base_classes); } ValueObjectSP @@ -743,7 +743,7 @@ ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create) std::vector child_indexes; bool omit_empty_base_classes = true; - const size_t num_child_indexes = GetClangType().GetIndexOfChildMemberWithName (name.GetCString(), + const size_t num_child_indexes = GetCompilerType().GetIndexOfChildMemberWithName (name.GetCString(), omit_empty_base_classes, child_indexes); if (num_child_indexes > 0) @@ -834,7 +834,7 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_ ExecutionContext exe_ctx (GetExecutionContextRef()); - child_clang_type = GetClangType().GetChildClangTypeAtIndex (&exe_ctx, + child_clang_type = GetCompilerType().GetChildClangTypeAtIndex (&exe_ctx, idx, transparent_pointers, omit_empty_base_classes, @@ -1046,7 +1046,7 @@ ValueObject::GetPointeeData (DataExtractor& data, break; case eAddressTypeHost: { - const uint64_t max_bytes = GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope()); + const uint64_t max_bytes = GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope()); if (max_bytes > offset) { size_t bytes_read = std::min(max_bytes - offset, bytes); @@ -1102,7 +1102,7 @@ ValueObject::SetData (DataExtractor &data, Error &error) } uint64_t count = 0; - const Encoding encoding = GetClangType().GetEncoding(count); + const Encoding encoding = GetCompilerType().GetEncoding(count); const size_t byte_size = GetByteSize(); @@ -1226,7 +1226,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp, size_t bytes_read = 0; size_t total_bytes_read = 0; - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); CompilerType elem_or_pointee_clang_type; const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type)); if (type_flags.AnySet (eTypeIsArray | eTypeIsPointer) && @@ -1385,7 +1385,7 @@ ValueObject::GetObjectDescription () if (runtime == NULL) { // Aw, hell, if the things a pointer, or even just an integer, let's try ObjC anyway... - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); if (clang_type) { bool is_signed; @@ -1449,7 +1449,7 @@ ValueObject::GetValueAsCString () } else { - my_format = GetValue().GetClangType().GetFormat(); + my_format = GetValue().GetCompilerType().GetFormat(); } } } @@ -1886,7 +1886,7 @@ ValueObject::SetValueFromCString (const char *value_str, Error& error) } uint64_t count = 0; - const Encoding encoding = GetClangType().GetEncoding (count); + const Encoding encoding = GetCompilerType().GetEncoding (count); const size_t byte_size = GetByteSize(); @@ -1984,7 +1984,7 @@ ValueObject::GetDeclaration (Declaration &decl) ConstString ValueObject::GetTypeName() { - return GetClangType().GetConstTypeName(); + return GetCompilerType().GetConstTypeName(); } ConstString @@ -1996,14 +1996,14 @@ ValueObject::GetDisplayTypeName() ConstString ValueObject::GetQualifiedTypeName() { - return GetClangType().GetConstQualifiedTypeName(); + return GetCompilerType().GetConstQualifiedTypeName(); } LanguageType ValueObject::GetObjectRuntimeLanguage () { - return GetClangType().GetMinimumLanguage (); + return GetCompilerType().GetMinimumLanguage (); } void @@ -2025,37 +2025,37 @@ ValueObject::GetSyntheticChild (const ConstString &key) const uint32_t ValueObject::GetTypeInfo (CompilerType *pointee_or_element_clang_type) { - return GetClangType().GetTypeInfo (pointee_or_element_clang_type); + return GetCompilerType().GetTypeInfo (pointee_or_element_clang_type); } bool ValueObject::IsPointerType () { - return GetClangType().IsPointerType(); + return GetCompilerType().IsPointerType(); } bool ValueObject::IsArrayType () { - return GetClangType().IsArrayType (NULL, NULL, NULL); + return GetCompilerType().IsArrayType (NULL, NULL, NULL); } bool ValueObject::IsScalarType () { - return GetClangType().IsScalarType (); + return GetCompilerType().IsScalarType (); } bool ValueObject::IsIntegerType (bool &is_signed) { - return GetClangType().IsIntegerType (is_signed); + return GetCompilerType().IsIntegerType (is_signed); } bool ValueObject::IsPointerOrReferenceType () { - return GetClangType().IsPointerOrReferenceType (); + return GetCompilerType().IsPointerOrReferenceType (); } bool @@ -2066,7 +2066,7 @@ ValueObject::IsPossibleDynamicType () if (process) return process->IsPossibleDynamicValue(*this); else - return GetClangType().IsPossibleDynamicType (NULL, true, true); + return GetCompilerType().IsPossibleDynamicType (NULL, true, true); } bool @@ -2088,7 +2088,7 @@ bool ValueObject::IsObjCNil () { const uint32_t mask = eTypeIsObjC | eTypeIsPointer; - bool isObjCpointer = (((GetClangType().GetTypeInfo(NULL)) & mask) == mask); + bool isObjCpointer = (((GetCompilerType().GetTypeInfo(NULL)) & mask) == mask); if (!isObjCpointer) return false; bool canReadValue = true; @@ -2156,7 +2156,7 @@ ValueObject::GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_cre // We haven't made a synthetic array member for INDEX yet, so // lets make one and cache it for any future reference. ValueObjectChild *synthetic_child = new ValueObjectChild (*this, - GetClangType(), + GetCompilerType(), index_const_str, GetByteSize(), 0, @@ -2417,7 +2417,7 @@ ValueObject::GetBaseClassPath (Stream &s) if (IsBaseClass()) { bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath (s); - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); std::string cxx_class_name; bool this_had_base_class = ClangASTContext::GetCXXClassName (clang_type, cxx_class_name); if (this_had_base_class) @@ -2536,7 +2536,7 @@ ValueObject::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExp ValueObject *non_base_class_parent = GetNonBaseClassParent(); if (non_base_class_parent) { - CompilerType non_base_class_parent_clang_type = non_base_class_parent->GetClangType(); + CompilerType non_base_class_parent_clang_type = non_base_class_parent->GetCompilerType(); if (non_base_class_parent_clang_type) { if (parent && parent->IsDereferenceOfParent() && epformat == eGetExpressionPathFormatHonorPointers) @@ -2757,7 +2757,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr, const char* expression_cstr = *first_unparsed; // hide the top level expression_cstr - CompilerType root_clang_type = root->GetClangType(); + CompilerType root_clang_type = root->GetCompilerType(); CompilerType pointee_clang_type; Flags pointee_clang_type_info; @@ -3073,7 +3073,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr, } else { - if (root->GetClangType().GetMinimumLanguage() == eLanguageTypeObjC + if (root->GetCompilerType().GetMinimumLanguage() == eLanguageTypeObjC && pointee_clang_type_info.AllClear(eTypeIsPointer) && root->HasSyntheticValue() && (options.m_synthetic_children_traversal == GetValueForExpressionPathOptions::SyntheticChildrenTraversal::ToSynthetic || @@ -3281,7 +3281,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr, const char* expression_cstr = *first_unparsed; // hide the top level expression_cstr - CompilerType root_clang_type = root->GetClangType(); + CompilerType root_clang_type = root->GetCompilerType(); CompilerType pointee_clang_type; Flags pointee_clang_type_info; Flags root_clang_type_info(root_clang_type.GetTypeInfo(&pointee_clang_type)); @@ -3611,7 +3611,7 @@ ValueObject::CreateConstantValue (const ConstString &name) m_error = m_value.GetValueAsData (&exe_ctx, data, 0, GetModule().get()); valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), - GetClangType(), + GetCompilerType(), name, data, GetAddressOf()); @@ -3678,7 +3678,7 @@ lldb::addr_t ValueObject::GetCPPVTableAddress (AddressType &address_type) { CompilerType pointee_type; - CompilerType this_type(GetClangType()); + CompilerType this_type(GetCompilerType()); uint32_t type_info = this_type.GetTypeInfo(&pointee_type); if (type_info) { @@ -3726,7 +3726,7 @@ ValueObject::Dereference (Error &error) bool child_is_base_class = false; bool child_is_deref_of_parent = false; const bool transparent_pointers = false; - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); CompilerType child_clang_type; ExecutionContext exe_ctx (GetExecutionContextRef()); @@ -3806,7 +3806,7 @@ ValueObject::AddressOf (Error &error) case eAddressTypeFile: case eAddressTypeLoad: { - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); if (clang_type) { std::string name (1, '&'); @@ -4258,7 +4258,7 @@ ValueObject::CanProvideValue () // we need to support invalid types as providers of values because some bare-board // debugging scenarios have no notion of types, but still manage to have raw numeric // values for things like registers. sigh. - const CompilerType &type(GetClangType()); + const CompilerType &type(GetCompilerType()); return (false == type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue)); } diff --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp index 6b6f67e08f0b..637882cecc97 100644 --- a/lldb/source/Core/ValueObjectCast.cpp +++ b/lldb/source/Core/ValueObjectCast.cpp @@ -55,7 +55,7 @@ ValueObjectCast::ValueObjectCast { SetName (name); //m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType()); - m_value.SetClangType (cast_type); + m_value.SetCompilerType (cast_type); } ValueObjectCast::~ValueObjectCast() @@ -63,7 +63,7 @@ ValueObjectCast::~ValueObjectCast() } CompilerType -ValueObjectCast::GetClangTypeImpl () +ValueObjectCast::GetCompilerTypeImpl () { return m_cast_type; } @@ -71,7 +71,7 @@ ValueObjectCast::GetClangTypeImpl () size_t ValueObjectCast::CalculateNumChildren() { - return GetClangType().GetNumChildren (true); + return GetCompilerType().GetNumChildren (true); } uint64_t @@ -98,9 +98,9 @@ ValueObjectCast::UpdateValue () Value old_value(m_value); m_update_point.SetUpdated(); m_value = m_parent->GetValue(); - CompilerType clang_type (GetClangType()); + CompilerType clang_type (GetCompilerType()); //m_value.SetContext (Value::eContextTypeClangType, clang_type); - m_value.SetClangType (clang_type); + m_value.SetCompilerType (clang_type); SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren()); if (!CanProvideValue()) { diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index 92b0ad44a17b..8e8eb2d7a888 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -64,7 +64,7 @@ ValueObjectChild::GetValueType() const size_t ValueObjectChild::CalculateNumChildren() { - return GetClangType().GetNumChildren (true); + return GetCompilerType().GetNumChildren (true); } static void @@ -88,7 +88,7 @@ ValueObjectChild::GetTypeName() { if (m_type_name.IsEmpty()) { - m_type_name = GetClangType().GetConstTypeName (); + m_type_name = GetCompilerType().GetConstTypeName (); AdjustForBitfieldness(m_type_name, m_bitfield_bit_size); } return m_type_name; @@ -97,7 +97,7 @@ ValueObjectChild::GetTypeName() ConstString ValueObjectChild::GetQualifiedTypeName() { - ConstString qualified_name = GetClangType().GetConstTypeName(); + ConstString qualified_name = GetCompilerType().GetConstTypeName(); AdjustForBitfieldness(qualified_name, m_bitfield_bit_size); return qualified_name; } @@ -105,7 +105,7 @@ ValueObjectChild::GetQualifiedTypeName() ConstString ValueObjectChild::GetDisplayTypeName() { - ConstString display_name = GetClangType().GetDisplayTypeName(); + ConstString display_name = GetCompilerType().GetDisplayTypeName(); AdjustForBitfieldness(display_name, m_bitfield_bit_size); return display_name; } @@ -136,14 +136,14 @@ ValueObjectChild::UpdateValue () { if (parent->UpdateValueIfNeeded(false)) { - m_value.SetClangType(GetClangType()); + m_value.SetCompilerType(GetCompilerType()); // Copy the parent scalar value and the scalar value type m_value.GetScalar() = parent->GetValue().GetScalar(); Value::ValueType value_type = parent->GetValue().GetValueType(); m_value.SetValueType (value_type); - if (parent->GetClangType().IsPointerOrReferenceType ()) + if (parent->GetCompilerType().IsPointerOrReferenceType ()) { lldb::addr_t addr = parent->GetPointerValue (); m_value.GetScalar() = addr; @@ -225,7 +225,7 @@ ValueObjectChild::UpdateValue () { const bool thread_and_frame_only_if_stopped = true; ExecutionContext exe_ctx (GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped)); - if (GetClangType().GetTypeInfo() & lldb::eTypeHasValue) + if (GetCompilerType().GetTypeInfo() & lldb::eTypeHasValue) m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get()); else m_error.Clear(); // No value so nothing to read... diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index 3fb1cfb25c70..cb11e7270211 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -94,7 +94,7 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); m_value.SetValueType(Value::eValueTypeHostAddress); - m_value.SetClangType(clang_type); + m_value.SetCompilerType(clang_type); m_name = name; SetIsConstant (); SetValueIsValid(true); @@ -146,7 +146,7 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope m_value.GetScalar() = (uintptr_t)data_sp->GetBytes(); m_value.SetValueType(Value::eValueTypeHostAddress); //m_value.SetContext(Value::eContextTypeClangType, clang_type); - m_value.SetClangType (clang_type); + m_value.SetCompilerType (clang_type); m_name = name; SetIsConstant (); SetValueIsValid(true); @@ -192,7 +192,7 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope case eAddressTypeHost: m_value.SetValueType(Value::eValueTypeHostAddress); break; } // m_value.SetContext(Value::eContextTypeClangType, clang_type); - m_value.SetClangType (clang_type); + m_value.SetCompilerType (clang_type); m_name = name; SetIsConstant (); SetValueIsValid(true); @@ -242,9 +242,9 @@ ValueObjectConstResult::~ValueObjectConstResult() } CompilerType -ValueObjectConstResult::GetClangTypeImpl() +ValueObjectConstResult::GetCompilerTypeImpl() { - return m_value.GetClangType(); + return m_value.GetCompilerType(); } lldb::ValueType @@ -259,7 +259,7 @@ ValueObjectConstResult::GetByteSize() ExecutionContext exe_ctx(GetExecutionContextRef()); if (m_byte_size == 0) - SetByteSize(GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope())); + SetByteSize(GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope())); return m_byte_size; } @@ -272,21 +272,21 @@ ValueObjectConstResult::SetByteSize (size_t size) size_t ValueObjectConstResult::CalculateNumChildren() { - return GetClangType().GetNumChildren (true); + return GetCompilerType().GetNumChildren (true); } ConstString ValueObjectConstResult::GetTypeName() { if (m_type_name.IsEmpty()) - m_type_name = GetClangType().GetConstTypeName (); + m_type_name = GetCompilerType().GetConstTypeName (); return m_type_name; } ConstString ValueObjectConstResult::GetDisplayTypeName() { - return GetClangType().GetDisplayTypeName(); + return GetCompilerType().GetDisplayTypeName(); } bool diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp index eb02fe4f439d..92b0ec204298 100644 --- a/lldb/source/Core/ValueObjectConstResultImpl.cpp +++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp @@ -71,7 +71,7 @@ ValueObjectConstResultImpl::CreateChildAtIndex (size_t idx, bool synthetic_array bool child_is_deref_of_parent = false; const bool transparent_pointers = synthetic_array_member == false; - CompilerType clang_type = m_impl_backend->GetClangType(); + CompilerType clang_type = m_impl_backend->GetCompilerType(); CompilerType child_clang_type; ExecutionContext exe_ctx (m_impl_backend->GetExecutionContextRef()); @@ -132,7 +132,7 @@ ValueObjectConstResultImpl::AddressOf (Error &error) return lldb::ValueObjectSP(); if (m_live_address != LLDB_INVALID_ADDRESS) { - CompilerType clang_type(m_impl_backend->GetClangType()); + CompilerType clang_type(m_impl_backend->GetCompilerType()); lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&m_live_address,sizeof(lldb::addr_t))); diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index 0085a33c3756..57304c06c08e 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -50,17 +50,17 @@ ValueObjectDynamicValue::~ValueObjectDynamicValue() } CompilerType -ValueObjectDynamicValue::GetClangTypeImpl () +ValueObjectDynamicValue::GetCompilerTypeImpl () { const bool success = UpdateValueIfNeeded(false); if (success) { if (m_dynamic_type_info.HasType()) - return m_value.GetClangType(); + return m_value.GetCompilerType(); else - return m_parent->GetClangType(); + return m_parent->GetCompilerType(); } - return m_parent->GetClangType(); + return m_parent->GetCompilerType(); } ConstString @@ -105,7 +105,7 @@ ValueObjectDynamicValue::GetDisplayTypeName() if (success) { if (m_dynamic_type_info.HasType()) - return GetClangType().GetDisplayTypeName(); + return GetCompilerType().GetDisplayTypeName(); if (m_dynamic_type_info.HasName()) return m_dynamic_type_info.GetName(); } @@ -117,7 +117,7 @@ ValueObjectDynamicValue::CalculateNumChildren() { const bool success = UpdateValueIfNeeded(false); if (success && m_dynamic_type_info.HasType()) - return GetClangType().GetNumChildren (true); + return GetCompilerType().GetNumChildren (true); else return m_parent->GetNumChildren(); } @@ -166,7 +166,7 @@ FixupTypeAndOrName (const TypeAndOrName& type_andor_name, else if (parent.IsPointerOrReferenceType()) corrected_name.append(" &"); // the parent type should be a correctly pointer'ed or referenc'ed type - ret.SetCompilerType(parent.GetClangType()); + ret.SetCompilerType(parent.GetCompilerType()); ret.SetName(corrected_name.c_str()); } return ret; @@ -241,7 +241,7 @@ ValueObjectDynamicValue::UpdateValue () { if (class_type_or_name.HasType()) { - m_type_impl = TypeImpl(m_parent->GetClangType(),FixupTypeAndOrName(class_type_or_name, *m_parent).GetCompilerType()); + m_type_impl = TypeImpl(m_parent->GetCompilerType(),FixupTypeAndOrName(class_type_or_name, *m_parent).GetCompilerType()); } else { @@ -303,7 +303,7 @@ ValueObjectDynamicValue::UpdateValue () m_dynamic_type_info = FixupTypeAndOrName(m_dynamic_type_info, *m_parent); //m_value.SetContext (Value::eContextTypeClangType, corrected_type); - m_value.SetClangType (m_dynamic_type_info.GetCompilerType()); + m_value.SetCompilerType (m_dynamic_type_info.GetCompilerType()); // Our address is the location of the dynamic type stored in memory. It isn't a load address, // because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us... diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp index 8ad0d344e057..2ad3aa072564 100644 --- a/lldb/source/Core/ValueObjectMemory.cpp +++ b/lldb/source/Core/ValueObjectMemory.cpp @@ -104,7 +104,7 @@ ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope, SetName (ConstString(name)); // m_value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType()); - m_value.SetClangType(m_clang_type); + m_value.SetCompilerType(m_clang_type); lldb::addr_t load_address = m_address.GetLoadAddress (target_sp.get()); if (load_address != LLDB_INVALID_ADDRESS) { @@ -132,10 +132,10 @@ ValueObjectMemory::~ValueObjectMemory() } CompilerType -ValueObjectMemory::GetClangTypeImpl () +ValueObjectMemory::GetCompilerTypeImpl () { if (m_type_sp) - return m_type_sp->GetClangForwardType(); + return m_type_sp->GetForwardCompilerType (); return m_clang_type; } @@ -151,7 +151,7 @@ ConstString ValueObjectMemory::GetDisplayTypeName() { if (m_type_sp) - return m_type_sp->GetClangForwardType().GetDisplayTypeName(); + return m_type_sp->GetForwardCompilerType ().GetDisplayTypeName(); return m_clang_type.GetDisplayTypeName(); } @@ -250,7 +250,7 @@ ValueObjectMemory::UpdateValue () else { //value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType()); - value.SetClangType(m_clang_type); + value.SetCompilerType(m_clang_type); } m_error = value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp index 4f9e0f01505c..d332706a858e 100644 --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -43,7 +43,7 @@ ValueObjectRegisterContext::~ValueObjectRegisterContext() } CompilerType -ValueObjectRegisterContext::GetClangTypeImpl () +ValueObjectRegisterContext::GetCompilerTypeImpl () { return CompilerType(); } @@ -145,7 +145,7 @@ ValueObjectRegisterSet::~ValueObjectRegisterSet() } CompilerType -ValueObjectRegisterSet::GetClangTypeImpl () +ValueObjectRegisterSet::GetCompilerTypeImpl () { return CompilerType(); } @@ -308,7 +308,7 @@ ValueObjectRegister::~ValueObjectRegister() } CompilerType -ValueObjectRegister::GetClangTypeImpl () +ValueObjectRegister::GetCompilerTypeImpl () { if (!m_clang_type.IsValid()) { @@ -331,14 +331,14 @@ ConstString ValueObjectRegister::GetTypeName() { if (m_type_name.IsEmpty()) - m_type_name = GetClangType().GetConstTypeName (); + m_type_name = GetCompilerType().GetConstTypeName (); return m_type_name; } size_t ValueObjectRegister::CalculateNumChildren() { - return GetClangType().GetNumChildren(true); + return GetCompilerType().GetNumChildren(true); } uint64_t diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index ee8587cd89b3..899c064e2f0e 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -83,9 +83,9 @@ ValueObjectSynthetic::~ValueObjectSynthetic() } CompilerType -ValueObjectSynthetic::GetClangTypeImpl () +ValueObjectSynthetic::GetCompilerTypeImpl () { - return m_parent->GetClangType(); + return m_parent->GetCompilerType(); } ConstString diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index 3cca6c087999..2d97bf2b5564 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -55,11 +55,11 @@ ValueObjectVariable::~ValueObjectVariable() } CompilerType -ValueObjectVariable::GetClangTypeImpl () +ValueObjectVariable::GetCompilerTypeImpl () { Type *var_type = m_variable_sp->GetType(); if (var_type) - return var_type->GetClangForwardType(); + return var_type->GetForwardCompilerType (); return CompilerType(); } @@ -77,7 +77,7 @@ ValueObjectVariable::GetDisplayTypeName() { Type * var_type = m_variable_sp->GetType(); if (var_type) - return var_type->GetClangForwardType().GetDisplayTypeName(); + return var_type->GetForwardCompilerType ().GetDisplayTypeName(); return ConstString(); } @@ -93,7 +93,7 @@ ValueObjectVariable::GetQualifiedTypeName() size_t ValueObjectVariable::CalculateNumChildren() { - CompilerType type(GetClangType()); + CompilerType type(GetCompilerType()); if (!type.IsValid()) return 0; @@ -107,7 +107,7 @@ ValueObjectVariable::GetByteSize() { ExecutionContext exe_ctx(GetExecutionContextRef()); - CompilerType type(GetClangType()); + CompilerType type(GetCompilerType()); if (!type.IsValid()) return 0; @@ -168,9 +168,9 @@ ValueObjectVariable::UpdateValue () m_resolved_value = m_value; m_value.SetContext(Value::eContextTypeVariable, variable); - CompilerType clang_type = GetClangType(); + CompilerType clang_type = GetCompilerType(); if (clang_type.IsValid()) - m_value.SetClangType(clang_type); + m_value.SetCompilerType(clang_type); Value::ValueType value_type = m_value.GetValueType(); diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index 73ff5e9483de..b8302412d46b 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -312,13 +312,12 @@ lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Strea if (data_addr == 0 || data_addr == LLDB_INVALID_ADDRESS) return false; - ClangASTContext* lldb_ast = valobj.GetClangType().GetTypeSystem()->AsClangASTContext(); - clang::ASTContext* ast = lldb_ast ? lldb_ast->getASTContext() : nullptr; - - if (!ast) + // Get a wchar_t basic type from the current type system + CompilerType wchar_clang_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); + + if (!wchar_clang_type) return false; - CompilerType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar); const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here ReadStringAndDumpToStreamOptions options(valobj); @@ -1034,7 +1033,7 @@ lldb_private::formatters::NSAttributedStringSummaryProvider (ValueObject& valobj if (!pointer_value) return false; pointer_value += addr_size; - CompilerType type(valobj.GetClangType()); + CompilerType type(valobj.GetCompilerType()); ExecutionContext exe_ctx(target_sp,false); ValueObjectSP child_ptr_sp(valobj.CreateValueObjectFromAddress("string_ptr", pointer_value, exe_ctx, type)); if (!child_ptr_sp) @@ -1067,7 +1066,7 @@ lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject bool lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { - const uint32_t type_info = valobj.GetClangType().GetTypeInfo(); + const uint32_t type_info = valobj.GetCompilerType().GetTypeInfo(); ValueObjectSP real_guy_sp = valobj.GetSP(); @@ -1100,7 +1099,7 @@ lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& s { lldb::ValueObjectSP valobj_sp; - CompilerType charstar (valobj.GetClangType().GetBasicTypeFromAST(eBasicTypeChar).GetPointerType()); + CompilerType charstar (valobj.GetCompilerType().GetBasicTypeFromAST(eBasicTypeChar).GetPointerType()); if (!charstar) return false; @@ -1204,7 +1203,7 @@ lldb_private::formatters::VectorIteratorSyntheticFrontEnd::Update() return false; Error err; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); - m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetClangType().GetPointeeType()); + m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetCompilerType().GetPointeeType()); if (err.Fail()) m_item_sp.reset(); return false; diff --git a/lldb/source/DataFormatters/Cocoa.cpp b/lldb/source/DataFormatters/Cocoa.cpp index 11a9553c9f49..90dea21239fe 100644 --- a/lldb/source/DataFormatters/Cocoa.cpp +++ b/lldb/source/DataFormatters/Cocoa.cpp @@ -55,7 +55,7 @@ lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream& if (!strcmp(class_name,"NSBundle")) { uint64_t offset = 5 * ptr_size; - ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID), true)); + ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID), true)); StreamString summary_stream; bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); @@ -102,7 +102,7 @@ lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream if (!strcmp(class_name,"__NSTimeZone")) { uint64_t offset = ptr_size; - ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType(), true)); + ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true)); StreamString summary_stream; bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); if (was_nsstring_ok && summary_stream.GetSize() > 0) @@ -146,7 +146,7 @@ lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, St if (!strcmp(class_name,"NSConcreteNotification")) { uint64_t offset = ptr_size; - ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType(), true)); + ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true)); StreamString summary_stream; bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); if (was_nsstring_ok && summary_stream.GetSize() > 0) @@ -443,7 +443,7 @@ lldb_private::formatters::NSURLSummaryProvider (ValueObject& valobj, Stream& str { uint64_t offset_text = ptr_size + ptr_size + 8; // ISA + pointer + 8 bytes of data (even on 32bit) uint64_t offset_base = offset_text + ptr_size; - CompilerType type(valobj.GetClangType()); + CompilerType type(valobj.GetCompilerType()); ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset_text, type, true)); ValueObjectSP base(valobj.GetSyntheticChildAtOffset(offset_base, type, true)); if (!text) diff --git a/lldb/source/DataFormatters/CoreMedia.cpp b/lldb/source/DataFormatters/CoreMedia.cpp index 172bdf07d2cf..9fb7779db2dd 100644 --- a/lldb/source/DataFormatters/CoreMedia.cpp +++ b/lldb/source/DataFormatters/CoreMedia.cpp @@ -21,9 +21,9 @@ using namespace lldb_private::formatters; bool lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { - if (!valobj.GetClangType().IsValid()) + if (!valobj.GetCompilerType().IsValid()) return false; - ClangASTContext *ast_ctx = valobj.GetClangType().GetTypeSystem()->AsClangASTContext(); + ClangASTContext *ast_ctx = valobj.GetCompilerType().GetTypeSystem()->AsClangASTContext(); if (!ast_ctx) return false; diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index ffac77222563..e41d341a21e0 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -313,7 +313,7 @@ FormatManager::GetPossibleMatches (ValueObject& valobj, lldb::ValueObjectSP static_value_sp(valobj.GetStaticValue()); if (static_value_sp) GetPossibleMatches(*static_value_sp.get(), - static_value_sp->GetClangType(), + static_value_sp->GetCompilerType(), reason | lldb_private::eFormatterChoiceCriterionWentToStaticValue, use_dynamic, entries, @@ -1602,7 +1602,7 @@ FormatManager::LoadHardcodedFormatters() lldb::DynamicValueType, FormatManager&) -> TypeSummaryImpl::SharedPointer { static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::FunctionPointerSummaryProvider, "Function pointer summary provider")); - if (valobj.GetClangType().IsFunctionPointerType()) + if (valobj.GetCompilerType().IsFunctionPointerType()) { return formatter_sp; } @@ -1621,7 +1621,7 @@ FormatManager::LoadHardcodedFormatters() .SetSkipReferences(false), lldb_private::formatters::VectorTypeSummaryProvider, "vector_type pointer summary provider")); - if (valobj.GetClangType().IsVectorType(nullptr, nullptr)) + if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) { if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled()) return formatter_sp; @@ -1638,7 +1638,7 @@ FormatManager::LoadHardcodedFormatters() static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true), "vector_type synthetic children", lldb_private::formatters::VectorTypeSyntheticFrontEndCreator)); - if (valobj.GetClangType().IsVectorType(nullptr, nullptr)) + if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) { if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled()) return formatter_sp; diff --git a/lldb/source/DataFormatters/LibCxx.cpp b/lldb/source/DataFormatters/LibCxx.cpp index a04b4ff6b8c7..8a490e01e9b3 100644 --- a/lldb/source/DataFormatters/LibCxx.cpp +++ b/lldb/source/DataFormatters/LibCxx.cpp @@ -81,7 +81,7 @@ m_children() if (valobj_sp) { Update(); - m_bool_type = valobj_sp->GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeBool); + m_bool_type = valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool); } } @@ -377,7 +377,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex (siz return lldb::ValueObjectSP(); uint64_t count = 1 + shared_owners_sp->GetValueAsUnsigned(0); DataExtractor data(&count, 8, m_byte_order, m_ptr_size); - m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetClangType()); + m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetCompilerType()); } return m_count_sp; } @@ -390,7 +390,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex (siz return lldb::ValueObjectSP(); uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0); DataExtractor data(&count, 8, m_byte_order, m_ptr_size); - m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetClangType()); + m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetCompilerType()); } return m_weak_count_sp; } diff --git a/lldb/source/DataFormatters/LibCxxInitializerList.cpp b/lldb/source/DataFormatters/LibCxxInitializerList.cpp index ae1f31d0ee5d..652771e24662 100644 --- a/lldb/source/DataFormatters/LibCxxInitializerList.cpp +++ b/lldb/source/DataFormatters/LibCxxInitializerList.cpp @@ -101,7 +101,7 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() m_num_elements = 0; m_children.clear(); lldb::TemplateArgumentKind kind; - m_element_type = m_backend.GetClangType().GetTemplateArgument(0, kind); + m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind); if (kind != lldb::eTemplateArgumentKindType || false == m_element_type.IsValid()) return false; diff --git a/lldb/source/DataFormatters/LibCxxList.cpp b/lldb/source/DataFormatters/LibCxxList.cpp index c20e27d5977f..0eedb106be3b 100644 --- a/lldb/source/DataFormatters/LibCxxList.cpp +++ b/lldb/source/DataFormatters/LibCxxList.cpp @@ -332,7 +332,7 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update() ValueObjectSP impl_sp(m_backend.GetChildMemberWithName(ConstString("__end_"),true)); if (!impl_sp) return false; - CompilerType list_type = m_backend.GetClangType(); + CompilerType list_type = m_backend.GetCompilerType(); if (list_type.IsReferenceType()) list_type = list_type.GetNonReferenceType(); diff --git a/lldb/source/DataFormatters/LibCxxMap.cpp b/lldb/source/DataFormatters/LibCxxMap.cpp index 8682e88bcef5..37e0f1bcfe25 100644 --- a/lldb/source/DataFormatters/LibCxxMap.cpp +++ b/lldb/source/DataFormatters/LibCxxMap.cpp @@ -290,7 +290,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() deref = deref->GetChildMemberWithName(ConstString("__value_"), true); if (!deref) return false; - m_element_type = deref->GetClangType(); + m_element_type = deref->GetCompilerType(); return true; } @@ -301,7 +301,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset (const l return; if (!node) return; - CompilerType node_type(node->GetClangType()); + CompilerType node_type(node->GetCompilerType()); uint64_t bit_offset; if (node_type.GetIndexOfFieldWithName("__value_", NULL, &bit_offset) == UINT32_MAX) return; diff --git a/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp b/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp index 43669803195e..e64119c09a05 100644 --- a/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp +++ b/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp @@ -125,7 +125,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtInde return val_hash.first->CreateValueObjectFromData(stream.GetData(), data, exe_ctx, - val_hash.first->GetClangType()); + val_hash.first->GetCompilerType()); } bool diff --git a/lldb/source/DataFormatters/LibCxxVector.cpp b/lldb/source/DataFormatters/LibCxxVector.cpp index 2461bf60a8f9..735cbf5d1e99 100644 --- a/lldb/source/DataFormatters/LibCxxVector.cpp +++ b/lldb/source/DataFormatters/LibCxxVector.cpp @@ -112,7 +112,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() data_type_finder_sp = data_type_finder_sp->GetChildMemberWithName(ConstString("__first_"),true); if (!data_type_finder_sp) return false; - m_element_type = data_type_finder_sp->GetClangType().GetPointeeType(); + m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType(); m_element_size = m_element_type.GetByteSize(nullptr); if (m_element_size > 0) diff --git a/lldb/source/DataFormatters/LibStdcpp.cpp b/lldb/source/DataFormatters/LibStdcpp.cpp index 0f964739ead9..17e197a71ba1 100644 --- a/lldb/source/DataFormatters/LibStdcpp.cpp +++ b/lldb/source/DataFormatters/LibStdcpp.cpp @@ -78,7 +78,7 @@ lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::Update() m_pair_address += (is_64bit ? 32 : 16); - CompilerType my_type(valobj_sp->GetClangType()); + CompilerType my_type(valobj_sp->GetCompilerType()); if (my_type.GetNumTemplateArguments() >= 1) { TemplateArgumentKind kind; diff --git a/lldb/source/DataFormatters/NSArray.cpp b/lldb/source/DataFormatters/NSArray.cpp index a28a00c72feb..aed1e2ca60f4 100644 --- a/lldb/source/DataFormatters/NSArray.cpp +++ b/lldb/source/DataFormatters/NSArray.cpp @@ -528,9 +528,9 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd ( m_items (0), m_data_ptr (0) { - if (valobj_sp && valobj_sp->GetClangType().IsValid()) + if (valobj_sp && valobj_sp->GetCompilerType().IsValid()) { - ClangASTContext *ast = valobj_sp->GetClangType().GetTypeSystem()->AsClangASTContext(); + ClangASTContext *ast = valobj_sp->GetCompilerType().GetTypeSystem()->AsClangASTContext(); if (ast) m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy); } @@ -622,7 +622,7 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCre if (!runtime) return NULL; - CompilerType valobj_type(valobj_sp->GetClangType()); + CompilerType valobj_type(valobj_sp->GetCompilerType()); Flags flags(valobj_type.GetTypeInfo()); if (flags.IsClear(eTypeIsPointer)) diff --git a/lldb/source/DataFormatters/NSIndexPath.cpp b/lldb/source/DataFormatters/NSIndexPath.cpp index 60768b1d15d6..0908487310e1 100644 --- a/lldb/source/DataFormatters/NSIndexPath.cpp +++ b/lldb/source/DataFormatters/NSIndexPath.cpp @@ -49,7 +49,7 @@ public: { m_impl.Clear(); - TypeSystem* type_system = m_backend.GetClangType().GetTypeSystem(); + TypeSystem* type_system = m_backend.GetCompilerType().GetTypeSystem(); if (!type_system) return false; m_ast_ctx = type_system->AsClangASTContext(); @@ -227,7 +227,7 @@ protected: v = Value(scalar); } - v.SetClangType(desired_type); + v.SetCompilerType(desired_type); StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); diff --git a/lldb/source/DataFormatters/NSSet.cpp b/lldb/source/DataFormatters/NSSet.cpp index 116904ce99b4..77e33490ced7 100644 --- a/lldb/source/DataFormatters/NSSet.cpp +++ b/lldb/source/DataFormatters/NSSet.cpp @@ -470,7 +470,7 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex (size_t idx) CreateValueObjectFromData(idx_name.GetData(), data, m_exe_ctx_ref, - m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID)); + m_backend.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID)); } return set_item.valobj_sp; } @@ -638,7 +638,7 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex (size_t idx) CreateValueObjectFromData(idx_name.GetData(), data, m_exe_ctx_ref, - m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID)); + m_backend.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID)); } return set_item.valobj_sp; } diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp index 095559f8bfb0..67c726fd5e33 100644 --- a/lldb/source/DataFormatters/TypeFormat.cpp +++ b/lldb/source/DataFormatters/TypeFormat.cpp @@ -91,7 +91,7 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj, } else { - CompilerType clang_type = value.GetClangType (); + CompilerType clang_type = value.GetCompilerType (); if (clang_type) { // put custom bytes to display in the DataExtractor to override the default value logic @@ -208,9 +208,9 @@ TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj, { if (!type_sp) continue; - if ( (type_sp->GetClangForwardType().GetTypeInfo() & eTypeIsEnumeration) == eTypeIsEnumeration) + if ( (type_sp->GetForwardCompilerType().GetTypeInfo() & eTypeIsEnumeration) == eTypeIsEnumeration) { - valobj_enum_type = type_sp->GetClangFullType(); + valobj_enum_type = type_sp->GetFullCompilerType (); m_types.emplace(valobj_key,valobj_enum_type); break; } diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 0e02821d451f..c88b2fbb4b76 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -176,7 +176,7 @@ ValueObjectPrinter::GetMostSpecializedValue () } } } - m_clang_type = m_valobj->GetClangType(); + m_clang_type = m_valobj->GetCompilerType(); m_type_flags = m_clang_type.GetTypeInfo (); return true; } diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 408d2ad0cc4b..02e2b95232d3 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -21,7 +21,7 @@ using namespace lldb_private; using namespace lldb_private::formatters; static CompilerType -GetClangTypeForFormat (lldb::Format format, +GetCompilerTypeForFormat (lldb::Format format, CompilerType element_type, ClangASTContext *ast_ctx) { @@ -229,10 +229,10 @@ namespace lldb_private { Update() { m_parent_format = m_backend.GetFormat(); - CompilerType parent_type(m_backend.GetClangType()); + CompilerType parent_type(m_backend.GetCompilerType()); CompilerType element_type; parent_type.IsVectorType(&element_type, nullptr); - m_child_type = ::GetClangTypeForFormat(m_parent_format, element_type, parent_type.GetTypeSystem()->AsClangASTContext()); + m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type, parent_type.GetTypeSystem()->AsClangASTContext()); m_num_children = ::CalculateNumChildren(parent_type, m_child_type); m_item_format = GetItemFormatForFormat(m_parent_format, diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index d7bfa1a86548..46f14a82ae5b 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -18,7 +18,7 @@ #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangModulesDeclVendor.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" +#include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/TaggedASTType.h" @@ -252,7 +252,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) if (log) log->Printf(" CTD[%u] Searching namespace %s in module %s", current_id, - i->second.GetNamespaceDecl()->getNameAsString().c_str(), + i->second.GetName().AsCString(), i->first->GetFileSpec().GetFilename().GetCString()); TypeList types; @@ -271,7 +271,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) if (!type) continue; - CompilerType clang_type (type->GetClangFullType()); + CompilerType clang_type (type->GetFullCompilerType ()); if (!clang_type) continue; @@ -294,7 +294,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) SymbolContext null_sc; ConstString name(tag_decl->getName().str().c_str()); - ClangNamespaceDecl namespace_decl; + CompilerDeclContext namespace_decl; const ModuleList &module_list = m_target->GetImages(); @@ -310,7 +310,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl) if (!type) continue; - CompilerType clang_type (type->GetClangFullType()); + CompilerType clang_type (type->GetFullCompilerType ()); if (!clang_type) continue; @@ -401,7 +401,7 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de if (!complete_type_sp) return NULL; - TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType()); + TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetFullCompilerType ()); lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType(); if (!complete_opaque_type) @@ -598,7 +598,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) if (log) log->Printf(" CAS::FEVD[%u] Searching namespace %s in module %s", current_id, - i->second.GetNamespaceDecl()->getNameAsString().c_str(), + i->second.GetName().AsCString(), i->first->GetFileSpec().GetFilename().GetCString()); FindExternalVisibleDecls(context, @@ -618,7 +618,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) } else { - ClangNamespaceDecl namespace_decl; + CompilerDeclContext namespace_decl; if (log) log->Printf(" CAS::FEVD[%u] Searching the root namespace", current_id); @@ -647,7 +647,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) void ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module_sp, - ClangNamespaceDecl &namespace_decl, + CompilerDeclContext &namespace_decl, unsigned int current_id) { assert (m_ast_context); @@ -675,7 +675,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, if (module_sp && namespace_decl) { - ClangNamespaceDecl found_namespace_decl; + CompilerDeclContext found_namespace_decl; SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); @@ -687,7 +687,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, if (found_namespace_decl) { - context.m_namespace_map->push_back(std::pair(module_sp, found_namespace_decl)); + context.m_namespace_map->push_back(std::pair(module_sp, found_namespace_decl)); if (log) log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", @@ -709,7 +709,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, if (!image) continue; - ClangNamespaceDecl found_namespace_decl; + CompilerDeclContext found_namespace_decl; SymbolVendor *symbol_vendor = image->GetSymbolVendor(); @@ -722,7 +722,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, if (found_namespace_decl) { - context.m_namespace_map->push_back(std::pair(image, found_namespace_decl)); + context.m_namespace_map->push_back(std::pair(image, found_namespace_decl)); if (log) log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", @@ -760,7 +760,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, (name_string ? name_string : "")); } - CompilerType full_type = type_sp->GetClangFullType(); + CompilerType full_type = type_sp->GetFullCompilerType (); CompilerType copied_clang_type (GuardedCopyType(full_type)); @@ -1204,12 +1204,11 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context) if (!sc.function) continue; - DeclContext *function_ctx = sc.function->GetClangDeclContext(); - - if (!function_ctx) + CompilerDeclContext function_decl_ctx = sc.function->GetDeclContext(); + if (!function_decl_ctx) continue; - ObjCMethodDecl *method_decl = dyn_cast(function_ctx); + ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx); if (!method_decl) continue; @@ -1772,7 +1771,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s in namespace %s", current_id, static_cast(m_ast_context), name.GetCString(), - parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); + parent_map->begin()->second.GetName().AsCString()); else log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s", current_id, static_cast(m_ast_context), @@ -1785,10 +1784,10 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac i != e; ++i) { - ClangNamespaceDecl found_namespace_decl; + CompilerDeclContext found_namespace_decl; lldb::ModuleSP module_sp = i->first; - ClangNamespaceDecl module_parent_namespace_decl = i->second; + CompilerDeclContext module_parent_namespace_decl = i->second; SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); @@ -1802,7 +1801,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac if (!found_namespace_decl) continue; - namespace_map->push_back(std::pair(module_sp, found_namespace_decl)); + namespace_map->push_back(std::pair(module_sp, found_namespace_decl)); if (log) log->Printf(" CMN[%u] Found namespace %s in module %s", @@ -1816,7 +1815,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac const ModuleList &target_images = m_target->GetImages(); Mutex::Locker modules_locker(target_images.GetMutex()); - ClangNamespaceDecl null_namespace_decl; + CompilerDeclContext null_namespace_decl; for (size_t i = 0, e = target_images.GetSize(); i < e; ++i) { @@ -1825,7 +1824,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac if (!image) continue; - ClangNamespaceDecl found_namespace_decl; + CompilerDeclContext found_namespace_decl; SymbolVendor *symbol_vendor = image->GetSymbolVendor(); @@ -1839,7 +1838,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac if (!found_namespace_decl) continue; - namespace_map->push_back(std::pair(image, found_namespace_decl)); + namespace_map->push_back(std::pair(image, found_namespace_decl)); if (log) log->Printf(" CMN[%u] Found namespace %s in module %s", @@ -1854,19 +1853,27 @@ NamespaceDecl * ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls) { if (!namespace_decls) - return NULL; + return nullptr; - const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second; + const CompilerDeclContext &namespace_decl = namespace_decls->begin()->second; - Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); + clang::ASTContext *src_ast = ClangASTContext::DeclContextGetClangASTContext(namespace_decl); + if (!src_ast) + return nullptr; + clang::NamespaceDecl *src_namespace_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(namespace_decl); + + if (!src_namespace_decl) + return nullptr; + + Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, src_ast, src_namespace_decl); if (!copied_decl) - return NULL; + return nullptr; NamespaceDecl *copied_namespace_decl = dyn_cast(copied_decl); if (!copied_namespace_decl) - return NULL; + return nullptr; context.m_decls.push_back(copied_namespace_decl); diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index d2c4f02a960c..e6963eff4147 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -28,7 +28,7 @@ #include "lldb/Expression/Materializer.h" #include "lldb/Host/Endian.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" +#include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -863,7 +863,7 @@ ClangExpressionDeclMap::FindGlobalVariable Target &target, ModuleSP &module, const ConstString &name, - ClangNamespaceDecl *namespace_decl, + CompilerDeclContext *namespace_decl, TypeFromUser *type ) { @@ -882,7 +882,7 @@ ClangExpressionDeclMap::FindGlobalVariable { VariableSP var_sp = vars.GetVariableAtIndex(i); - if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetClangFullType())) + if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetFullCompilerType ())) return var_sp; } } @@ -947,7 +947,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context) if (log) log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s", current_id, - i->second.GetNamespaceDecl()->getNameAsString().c_str(), + i->second.GetName().AsCString(), i->first->GetFileSpec().GetFilename().GetCString()); FindExternalVisibleDecls(context, @@ -958,7 +958,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context) } else if (isa(context.m_decl_context)) { - ClangNamespaceDecl namespace_decl; + CompilerDeclContext namespace_decl; if (log) log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id); @@ -976,7 +976,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context) void ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module_sp, - ClangNamespaceDecl &namespace_decl, + CompilerDeclContext &namespace_decl, unsigned int current_id) { assert (m_ast_context); @@ -1013,23 +1013,20 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (frame == NULL) return; - SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction); + SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock); - if (!sym_ctx.function) - return; - - // Get the block that defines the function + // Find the block that defines the function represented by "sym_ctx" Block *function_block = sym_ctx.GetFunctionBlock(); if (!function_block) return; - clang::DeclContext *decl_context = function_block->GetClangDeclContext(); + CompilerDeclContext function_decl_ctx = function_block->GetDeclContext(); - if (!decl_context) + if (!function_decl_ctx) return; - clang::CXXMethodDecl *method_decl = llvm::dyn_cast(decl_context); + clang::CXXMethodDecl *method_decl = ClangASTContext::DeclContextGetAsCXXMethodDecl(function_decl_ctx); if (method_decl) { @@ -1103,13 +1100,13 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (!this_type) return; - CompilerType pointee_type = this_type->GetClangForwardType().GetPointeeType(); + CompilerType pointee_type = this_type->GetForwardCompilerType ().GetPointeeType(); if (pointee_type.IsValid()) { if (log) { - ASTDumper ast_dumper(this_type->GetClangFullType()); + ASTDumper ast_dumper(this_type->GetFullCompilerType ()); log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString()); } @@ -1117,7 +1114,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, AddOneType(context, class_user_type, current_id); - TypeFromUser this_user_type(this_type->GetClangFullType()); + TypeFromUser this_user_type(this_type->GetFullCompilerType ()); m_struct_vars->m_object_pointer_type = this_user_type; return; } @@ -1135,23 +1132,20 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (!frame) return; - SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction); + SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock); - if (!sym_ctx.function) - return; - - // Get the block that defines the function + // Find the block that defines the function represented by "sym_ctx" Block *function_block = sym_ctx.GetFunctionBlock(); if (!function_block) return; - clang::DeclContext *decl_context = function_block->GetClangDeclContext(); + CompilerDeclContext function_decl_ctx = function_block->GetDeclContext(); - if (!decl_context) + if (!function_decl_ctx) return; - clang::ObjCMethodDecl *method_decl = llvm::dyn_cast(decl_context); + clang::ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx); if (method_decl) { @@ -1220,7 +1214,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (!self_type) return; - CompilerType self_clang_type = self_type->GetClangFullType(); + CompilerType self_clang_type = self_type->GetFullCompilerType (); if (ClangASTContext::IsObjCClassType(self_clang_type)) { @@ -1235,7 +1229,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (log) { - ASTDumper ast_dumper(self_type->GetClangFullType()); + ASTDumper ast_dumper(self_type->GetFullCompilerType ()); log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString()); } @@ -1243,7 +1237,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, AddOneType(context, class_user_type, current_id); - TypeFromUser self_user_type(self_type->GetClangFullType()); + TypeFromUser self_user_type(self_type->GetFullCompilerType ()); m_struct_vars->m_object_pointer_type = self_user_type; return; @@ -1416,15 +1410,13 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (sym_ctx.function) { - clang::DeclContext *decl_ctx = sym_ctx.function->GetClangDeclContext(); + CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext(); if (!decl_ctx) continue; // Filter out class/instance methods. - if (dyn_cast(decl_ctx)) - continue; - if (dyn_cast(decl_ctx)) + if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr)) continue; AddOneFunction(context, sym_ctx.function, NULL, current_id); @@ -1632,7 +1624,7 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var, return false; } - CompilerType var_clang_type = var_type->GetClangFullType(); + CompilerType var_clang_type = var_type->GetFullCompilerType (); if (!var_clang_type) { @@ -1687,7 +1679,7 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var, *parser_type = TypeFromParser(type_to_use); if (var_location.GetContextType() == Value::eContextTypeInvalid) - var_location.SetClangType(type_to_use); + var_location.SetCompilerType(type_to_use); if (var_location.GetValueType() == Value::eValueTypeFileAddress) { @@ -1844,7 +1836,7 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target); //parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); - parser_vars->m_lldb_value.SetClangType(user_type); + parser_vars->m_lldb_value.SetCompilerType(user_type); parser_vars->m_lldb_value.GetScalar() = symbol_load_addr; parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress); @@ -1911,10 +1903,10 @@ ClangExpressionDeclMap::ResolveUnknownTypes() TypeFromUser user_type(copied_type, scratch_ast_context); // parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); - parser_vars->m_lldb_value.SetClangType(user_type); + parser_vars->m_lldb_value.SetCompilerType(user_type); parser_vars->m_parser_type = parser_type; - entity->SetClangType(user_type); + entity->SetCompilerType(user_type); entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType); } @@ -1995,7 +1987,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, return; } - function_clang_type = function_type->GetClangFullType(); + function_clang_type = function_type->GetFullCompilerType (); if (!function_clang_type) { @@ -2060,7 +2052,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, std::string decl_name(context.m_decl_name.getAsString()); entity->SetName(ConstString(decl_name.c_str())); - entity->SetClangType (function_clang_type); + entity->SetCompilerType (function_clang_type); entity->EnableParserVars(GetParserID()); ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID()); diff --git a/lldb/source/Expression/ClangExpressionVariable.cpp b/lldb/source/Expression/ClangExpressionVariable.cpp index 00da5b8a3d44..d3b4ba2fb430 100644 --- a/lldb/source/Expression/ClangExpressionVariable.cpp +++ b/lldb/source/Expression/ClangExpressionVariable.cpp @@ -81,22 +81,22 @@ ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info) } CompilerType -ClangExpressionVariable::GetClangType() +ClangExpressionVariable::GetCompilerType() { - return m_frozen_sp->GetClangType(); + return m_frozen_sp->GetCompilerType(); } void -ClangExpressionVariable::SetClangType(const CompilerType &clang_type) +ClangExpressionVariable::SetCompilerType(const CompilerType &clang_type) { - m_frozen_sp->GetValue().SetClangType(clang_type); + m_frozen_sp->GetValue().SetCompilerType(clang_type); } TypeFromUser ClangExpressionVariable::GetTypeFromUser() { - TypeFromUser tfu (m_frozen_sp->GetClangType()); + TypeFromUser tfu (m_frozen_sp->GetCompilerType()); return tfu; } diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index 572aec5aa5a7..3798c2120591 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -100,7 +100,7 @@ ClangFunction::ClangFunction assert (m_jit_process_wp.lock()); m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); - m_function_return_type = m_function_ptr->GetClangType().GetFunctionReturnType(); + m_function_return_type = m_function_ptr->GetCompilerType().GetFunctionReturnType(); } //---------------------------------------------------------------------- @@ -154,7 +154,7 @@ ClangFunction::CompileFunction (Stream &errors) CompilerType function_clang_type; if (m_function_ptr) { - function_clang_type = m_function_ptr->GetClangType(); + function_clang_type = m_function_ptr->GetCompilerType(); if (function_clang_type) { int num_func_args = function_clang_type.GetFunctionArgumentCount(); @@ -181,7 +181,7 @@ ClangFunction::CompileFunction (Stream &errors) } else { - CompilerType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetClangType (); + CompilerType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetCompilerType (); if (clang_qual_type) { type_name = clang_qual_type.GetTypeName().AsCString(""); @@ -391,7 +391,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, if (arg_value->GetValueType() == Value::eValueTypeHostAddress && arg_value->GetContextType() == Value::eContextTypeInvalid && - arg_value->GetClangType().IsPointerType()) + arg_value->GetCompilerType().IsPointerType()) continue; const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx); @@ -486,7 +486,7 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg if (error.Fail()) return false; - ret_value.SetClangType(m_function_return_type); + ret_value.SetCompilerType(m_function_return_type); ret_value.SetValueType(Value::eValueTypeScalar); return true; } diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 0db194c6807c..b479213ff524 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -160,7 +160,7 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) return; } - clang::DeclContext *decl_context = function_block->GetClangDeclContext(); + CompilerDeclContext decl_context = function_block->GetDeclContext(); if (!decl_context) { @@ -169,7 +169,7 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) return; } - if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast(decl_context)) + if (clang::CXXMethodDecl *method_decl = ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context)) { if (m_allow_cxx && method_decl->isInstance()) { @@ -200,7 +200,7 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) m_needs_object_ptr = true; } } - else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast(decl_context)) + else if (clang::ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(decl_context)) { if (m_allow_objc) { @@ -234,14 +234,14 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) m_in_static_method = true; } } - else if (clang::FunctionDecl *function_decl = llvm::dyn_cast(decl_context)) + else if (clang::FunctionDecl *function_decl = ClangASTContext::DeclContextGetAsFunctionDecl(decl_context)) { // We might also have a function that said in the debug information that it captured an // object pointer. The best way to deal with getting to the ivars at present is by pretending // that this is a method of a class in whatever runtime the debug info says the object pointer // belongs to. Do that here. - ClangASTMetadata *metadata = ClangASTContext::GetMetadata (&decl_context->getParentASTContext(), function_decl); + ClangASTMetadata *metadata = ClangASTContext::DeclContextGetMetaData (decl_context, function_decl); if (metadata && metadata->HasObjectPtr()) { lldb::LanguageType language = metadata->GetObjectPtrLanguage(); @@ -305,7 +305,7 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err) return; } - CompilerType self_clang_type = self_type->GetClangForwardType(); + CompilerType self_clang_type = self_type->GetForwardCompilerType (); if (!self_clang_type) { diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 3fb903694072..ec7319d45cf5 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -416,7 +416,7 @@ public: // Hard-coding to maximum size of a pointer since all variables are materialized by reference m_size = 8; m_alignment = 8; - m_is_reference = m_variable_sp->GetType()->GetClangForwardType().IsReferenceType(); + m_is_reference = m_variable_sp->GetType()->GetForwardCompilerType ().IsReferenceType(); } void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err) @@ -525,7 +525,7 @@ public: return; } - size_t bit_align = m_variable_sp->GetType()->GetClangLayoutType().GetTypeBitAlign(); + size_t bit_align = m_variable_sp->GetType()->GetLayoutCompilerType ().GetTypeBitAlign(); size_t byte_align = (bit_align + 7) / 8; if (!byte_align) diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 807e41cf87d6..da2bab77b7f5 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -333,7 +333,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread, if (!value) return false; - CompilerType clang_type = value->GetClangType(); + CompilerType clang_type = value->GetCompilerType(); if (clang_type) { bool is_signed = false; @@ -430,7 +430,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType()); - value.SetClangType (clang_type); + value.SetCompilerType (clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) @@ -511,7 +511,7 @@ ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index 407fa9cc2b5d..4a4e6d1d437d 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -322,7 +322,7 @@ ABIMacOSX_arm64::GetArgumentValues (Thread &thread, ValueList &values) const if (!value) return false; - CompilerType value_type = value->GetClangType(); + CompilerType value_type = value->GetCompilerType(); if (value_type) { bool is_signed = false; @@ -424,7 +424,7 @@ ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueO return error; } - CompilerType return_value_type = new_value_sp->GetClangType(); + CompilerType return_value_type = new_value_sp->GetCompilerType(); if (!return_value_type) { error.SetErrorString ("Null clang type for return value."); @@ -728,14 +728,12 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx, const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type); if (homogeneous_count > 0 && homogeneous_count <= 8) { - printf ("ClangASTContext::IsHomogeneousAggregate() => %u\n", homogeneous_count); // Make sure we have enough registers if (NSRN < 8 && (8-NSRN) >= homogeneous_count) { if (!base_type) return false; const size_t base_byte_size = base_type.GetByteSize(nullptr); - printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size); uint32_t data_offset = 0; for (uint32_t i=0; iGetClangType()); + CompilerType clang_type (val->GetCompilerType()); if (clang_type) { uint32_t cstr_length = 0; @@ -545,7 +545,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread, // We currently only support extracting values with Clang QualTypes. // Do we care about others? - CompilerType clang_type (value->GetClangType()); + CompilerType clang_type (value->GetCompilerType()); if (clang_type) { bool is_signed; @@ -582,7 +582,7 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -663,7 +663,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType()); - value.SetClangType (clang_type); + value.SetCompilerType (clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp index d3536493dfcb..a9b52a799b42 100644 --- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -333,7 +333,7 @@ ABISysV_arm::GetArgumentValues (Thread &thread, if (!value) return false; - CompilerType clang_type = value->GetClangType(); + CompilerType clang_type = value->GetCompilerType(); if (clang_type) { bool is_signed = false; @@ -426,7 +426,7 @@ ABISysV_arm::GetReturnValueObjectImpl (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType()); - value.SetClangType (clang_type); + value.SetCompilerType (clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) @@ -579,7 +579,7 @@ ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index e9b46983bf31..14b89ff3b5e1 100644 --- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -313,7 +313,7 @@ ABISysV_arm64::GetArgumentValues (Thread &thread, ValueList &values) const if (!value) return false; - CompilerType value_type = value->GetClangType(); + CompilerType value_type = value->GetCompilerType(); if (value_type) { bool is_signed = false; @@ -397,7 +397,7 @@ ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj return error; } - CompilerType return_value_type = new_value_sp->GetClangType(); + CompilerType return_value_type = new_value_sp->GetCompilerType(); if (!return_value_type) { error.SetErrorString ("Null clang type for return value."); @@ -705,14 +705,12 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx, const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type); if (homogeneous_count > 0 && homogeneous_count <= 8) { - printf ("ClangASTContext::IsHomogeneousAggregate() => %u\n", homogeneous_count); // Make sure we have enough registers if (NSRN < 8 && (8-NSRN) >= homogeneous_count) { if (!base_type) return false; const size_t base_byte_size = base_type.GetByteSize(nullptr); - printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size); uint32_t data_offset = 0; for (uint32_t i=0; iGetClangType()); + CompilerType clang_type (value->GetCompilerType()); if (clang_type) { bool is_signed; @@ -434,7 +434,7 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread, if (!return_clang_type) return return_valobj_sp; - value.SetClangType (return_clang_type); + value.SetCompilerType (return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index d401ef3a3a58..2c897fc7bec5 100644 --- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -325,7 +325,7 @@ ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObje return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -417,7 +417,7 @@ ABISysV_mips::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_cla if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL) return return_valobj_sp; - value.SetClangType(return_clang_type); + value.SetCompilerType(return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index 3d5b9d4f2cd3..8b143f914387 100644 --- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -290,7 +290,7 @@ ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -385,7 +385,7 @@ ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_c if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL) return return_valobj_sp; - value.SetClangType(return_clang_type); + value.SetCompilerType(return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index f6f446468899..cc2fee249294 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -436,7 +436,7 @@ ABISysV_ppc::GetArgumentValues (Thread &thread, // We currently only support extracting values with Clang QualTypes. // Do we care about others? - CompilerType clang_type = value->GetClangType(); + CompilerType clang_type = value->GetCompilerType(); if (!clang_type) return false; bool is_signed; @@ -476,7 +476,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -563,7 +563,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_clang_type) const + CompilerType &return_clang_type) const { ValueObjectSP return_valobj_sp; Value value; @@ -572,7 +572,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetClangType (return_clang_type); + value.SetCompilerType (return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index f5402263d877..72fafe34e552 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -436,7 +436,7 @@ ABISysV_ppc64::GetArgumentValues (Thread &thread, // We currently only support extracting values with Clang QualTypes. // Do we care about others? - CompilerType clang_type = value->GetClangType(); + CompilerType clang_type = value->GetCompilerType(); if (!clang_type) return false; bool is_signed; @@ -476,7 +476,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -563,7 +563,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj ValueObjectSP ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_clang_type) const + CompilerType &return_clang_type) const { ValueObjectSP return_valobj_sp; Value value; @@ -572,7 +572,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetClangType (return_clang_type); + value.SetCompilerType (return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 25853f8d452e..76cfdf15f337 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -502,7 +502,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread, // We currently only support extracting values with Clang QualTypes. // Do we care about others? - CompilerType clang_type = value->GetClangType(); + CompilerType clang_type = value->GetCompilerType(); if (!clang_type) return false; bool is_signed; @@ -542,7 +542,7 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb return error; } - CompilerType clang_type = new_value_sp->GetClangType(); + CompilerType clang_type = new_value_sp->GetCompilerType(); if (!clang_type) { error.SetErrorString ("Null clang type for return value."); @@ -642,7 +642,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread, return return_valobj_sp; //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetClangType (return_clang_type); + value.SetCompilerType (return_clang_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 31e1af55084a..d5cc2a6fe8a2 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -630,11 +630,11 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton, CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); CompilerType clang_uint32_type = clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint, 32); input_value.SetValueType (Value::eValueTypeScalar); - input_value.SetClangType (clang_uint32_type); + input_value.SetCompilerType (clang_uint32_type); // input_value.SetContext (Value::eContextTypeClangType, clang_uint32_type); argument_values.PushValue (input_value); argument_values.PushValue (input_value); - input_value.SetClangType (clang_void_ptr_type); + input_value.SetCompilerType (clang_void_ptr_type); // input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); argument_values.PushValue (input_value); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 908a53c935f7..375b9bb3894e 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -40,7 +40,7 @@ ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value) { const bool check_cxx = true; const bool check_objc = false; - return in_value.GetClangType().IsPossibleDynamicType (NULL, check_cxx, check_objc); + return in_value.GetCompilerType().IsPossibleDynamicType (NULL, check_cxx, check_objc); } bool @@ -189,7 +189,7 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, type_sp = class_types.GetTypeAtIndex(i); if (type_sp) { - if (ClangASTContext::IsCXXClassType(type_sp->GetClangFullType())) + if (ClangASTContext::IsCXXClassType(type_sp->GetFullCompilerType ())) { if (log) log->Printf ("0x%16.16" PRIx64 ": static-type = '%s' has multiple matching dynamic types, picking this one: uid={0x%" PRIx64 "}, type-name='%s'\n", @@ -221,8 +221,8 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, // the value we were handed. if (type_sp) { - if (ClangASTContext::AreTypesSame (in_value.GetClangType(), - type_sp->GetClangFullType())) + if (ClangASTContext::AreTypesSame (in_value.GetCompilerType(), + type_sp->GetFullCompilerType ())) { // The dynamic type we found was the same type, // so we don't have a dynamic type here... diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index f05f885d4f0b..81ae61841aeb 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -51,7 +51,7 @@ AppleObjCRuntime::AppleObjCRuntime(Process *process) : bool AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &valobj) { - CompilerType clang_type(valobj.GetClangType()); + CompilerType clang_type(valobj.GetCompilerType()); bool is_signed; // ObjC objects can only be pointers (or numbers that actually represents pointers // but haven't been typecast, because reasons..) @@ -89,7 +89,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon return false; Target *target = exe_ctx.GetTargetPtr(); - CompilerType clang_type = value.GetClangType(); + CompilerType clang_type = value.GetCompilerType(); if (clang_type) { if (!ClangASTContext::IsObjCObjectPointerType(clang_type)) @@ -106,7 +106,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon if (!opaque_type) opaque_type = ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); //value.SetContext(Value::eContextTypeClangType, opaque_type_ptr); - value.SetClangType (opaque_type); + value.SetCompilerType (opaque_type); } ValueList arg_value_list; @@ -118,7 +118,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon CompilerType return_clang_type = ast_context->GetCStringType(true); Value ret; // ret.SetContext(Value::eContextTypeClangType, return_clang_type); - ret.SetClangType (return_clang_type); + ret.SetCompilerType (return_clang_type); if (exe_ctx.GetFramePtr() == NULL) { @@ -229,7 +229,7 @@ AppleObjCRuntime::GetPrintForDebuggerAddr() bool AppleObjCRuntime::CouldHaveDynamicValue (ValueObject &in_value) { - return in_value.GetClangType().IsPossibleDynamicType (NULL, + return in_value.GetCompilerType().IsPossibleDynamicType (NULL, false, // do not check C++ true); // check ObjC } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 5d4ba3acacd0..4817d57a353f 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1139,7 +1139,7 @@ AppleObjCRuntimeV2::GetClassDescriptor (ValueObject& valobj) // if we get an invalid VO (which might still happen when playing around // with pointers returned by the expression parser, don't consider this // a valid ObjC object) - if (valobj.GetClangType().IsValid()) + if (valobj.GetCompilerType().IsValid()) { addr_t isa_pointer = valobj.GetPointerValue(); @@ -1276,13 +1276,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table Value value; value.SetValueType (Value::eValueTypeScalar); // value.SetContext (Value::eContextTypeClangType, clang_void_pointer_type); - value.SetClangType (clang_void_pointer_type); + value.SetCompilerType (clang_void_pointer_type); arguments.PushValue (value); arguments.PushValue (value); value.SetValueType (Value::eValueTypeScalar); // value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type); - value.SetClangType (clang_uint32_t_type); + value.SetCompilerType (clang_uint32_t_type); arguments.PushValue (value); m_get_class_info_function.reset(new ClangFunction (*m_process, @@ -1355,7 +1355,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table Value return_value; return_value.SetValueType (Value::eValueTypeScalar); //return_value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type); - return_value.SetClangType (clang_uint32_t_type); + return_value.SetCompilerType (clang_uint32_t_type); return_value.GetScalar() = 0; errors.Clear(); @@ -1530,13 +1530,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() Value value; value.SetValueType (Value::eValueTypeScalar); //value.SetContext (Value::eContextTypeClangType, clang_void_pointer_type); - value.SetClangType (clang_void_pointer_type); + value.SetCompilerType (clang_void_pointer_type); arguments.PushValue (value); arguments.PushValue (value); value.SetValueType (Value::eValueTypeScalar); //value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type); - value.SetClangType (clang_uint32_t_type); + value.SetCompilerType (clang_uint32_t_type); arguments.PushValue (value); m_get_shared_cache_class_info_function.reset(new ClangFunction (*m_process, @@ -1610,7 +1610,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() Value return_value; return_value.SetValueType (Value::eValueTypeScalar); //return_value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type); - return_value.SetClangType (clang_uint32_t_type); + return_value.SetCompilerType (clang_uint32_t_type); return_value.GetScalar() = 0; errors.Clear(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 40f8e89a57b1..3e5bb8c749ae 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -526,7 +526,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton, input_value.SetValueType (Value::eValueTypeScalar); //input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); - input_value.SetClangType (clang_void_ptr_type); + input_value.SetCompilerType (clang_void_ptr_type); argument_values.PushValue(input_value); bool success = abi->GetArgumentValues (exe_ctx.GetThreadRef(), argument_values); @@ -901,7 +901,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); void_ptr_value.SetValueType (Value::eValueTypeScalar); //void_ptr_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); - void_ptr_value.SetClangType (clang_void_ptr_type); + void_ptr_value.SetCompilerType (clang_void_ptr_type); int obj_index; int sel_index; @@ -1083,7 +1083,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto CompilerType clang_int_type = clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingSint, 32); flag_value.SetValueType (Value::eValueTypeScalar); //flag_value.SetContext (Value::eContextTypeClangType, clang_int_type); - flag_value.SetClangType (clang_int_type); + flag_value.SetCompilerType (clang_int_type); if (this_dispatch.stret_return) flag_value.GetScalar() = 1; diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 329db1c59495..e95a31c48451 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -26,7 +26,6 @@ #include "lldb/Core/UUID.h" #include "lldb/Host/Host.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index e744d13deec1..93a52d1206e8 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -24,7 +24,6 @@ #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Process.h" diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index 3949ad339dd8..d8af63426601 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -85,7 +85,6 @@ public: dw_attr_t attr; dw_form_t form; }; - typedef llvm::SmallVector collection; collection m_infos; }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 35095fcfccdb..c8ca9f99da31 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -461,7 +461,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, size_t num_types_added = 0; for (Type *type : type_set) { - CompilerType clang_type = type->GetClangForwardType(); + CompilerType clang_type = type->GetForwardCompilerType (); if (clang_type_set.find(clang_type) == clang_type_set.end()) { clang_type_set.insert(clang_type); @@ -1432,8 +1432,8 @@ SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu, return false; } -clang::DeclContext* -SymbolFileDWARF::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) +CompilerDeclContext +SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid) { if (UserIDMatches(type_uid)) { @@ -1446,15 +1446,15 @@ SymbolFileDWARF::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { TypeSystem *type_system = GetTypeSystemForLanguage(cu_sp->GetLanguageType()); if (type_system) - return type_system->GetClangDeclContextContainingTypeUID(this, type_uid); + return type_system->GetDeclContextForUIDFromDWARF(this, cu_sp.get(), die); } } } - return NULL; + return CompilerDeclContext(); } -clang::DeclContext* -SymbolFileDWARF::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) +CompilerDeclContext +SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid) { if (UserIDMatches(type_uid)) { @@ -1467,13 +1467,14 @@ SymbolFileDWARF::GetClangDeclContextForTypeUID (const lldb_private::SymbolContex { TypeSystem *type_system = GetTypeSystemForLanguage(cu_sp->GetLanguageType()); if (type_system) - return type_system->GetClangDeclContextForTypeUID(this, sc, type_uid); + return type_system->GetDeclContextContainingUIDFromDWARF(this, cu_sp.get(), die); } } } - return NULL; + return CompilerDeclContext(); } + Type* SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) { @@ -1537,7 +1538,7 @@ SymbolFileDWARF::ResolveTypeUID (DWARFCompileUnit* cu, const DWARFDebugInfoEntry // // want a function (method or static) from a class, the class must // // create itself and add it's own methods and class functions. // if (parent_type) -// parent_type->GetClangFullType(); +// parent_type->GetFullCompilerType (); // } } break; @@ -2134,24 +2135,18 @@ SymbolFileDWARF::Index () } bool -SymbolFileDWARF::NamespaceDeclMatchesThisSymbolFile (const ClangNamespaceDecl *namespace_decl) +SymbolFileDWARF::DeclContextMatchesThisSymbolFile (const lldb_private::CompilerDeclContext *decl_ctx) { - if (namespace_decl == NULL) + if (decl_ctx == nullptr || !decl_ctx->IsValid()) { // Invalid namespace decl which means we aren't matching only things // in this symbol file, so return true to indicate it matches this // symbol file. return true; } - - clang::ASTContext *namespace_ast = namespace_decl->GetASTContext(); - if (namespace_ast == NULL) - return true; // No AST in the "namespace_decl", return true since it - // could then match any symbol file, including this one - - if (namespace_ast == GetClangASTContext().getASTContext()) - return true; // The ASTs match, return true + if ((TypeSystem *)&GetClangASTContext() == decl_ctx->GetTypeSystem()) + return true; // The type systems match, return true // The namespace AST was valid, and it does not match... Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -2163,18 +2158,18 @@ SymbolFileDWARF::NamespaceDeclMatchesThisSymbolFile (const ClangNamespaceDecl *n } uint32_t -SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) +SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables) { Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)", + "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", parent_decl_ctx=%p, append=%u, max_matches=%u, variables)", name.GetCString(), - static_cast(namespace_decl), + static_cast(parent_decl_ctx), append, max_matches); - if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) + if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) return 0; DWARFDebugInfo* info = DebugInfo(); @@ -2245,12 +2240,16 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat { sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); - if (namespace_decl) + if (parent_decl_ctx) { TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); - if (!type_system->DIEIsInNamespace (namespace_decl, this, dwarf_cu, die)) - continue; + if (type_system) + { + CompilerDeclContext actual_parent_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (this, dwarf_cu, die); + if (!actual_parent_decl_ctx || actual_parent_decl_ctx != *parent_decl_ctx) + continue; + } } ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); @@ -2277,9 +2276,9 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat if (log && num_matches > 0) { GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables) => %u", + "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", parent_decl_ctx=%p, append=%u, max_matches=%u, variables) => %u", name.GetCString(), - static_cast(namespace_decl), + static_cast(parent_decl_ctx), append, max_matches, num_matches); } @@ -2614,9 +2613,34 @@ SymbolFileDWARF::FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, return true; } +bool +SymbolFileDWARF::DIEInDeclContext (const CompilerDeclContext *decl_ctx, + DWARFCompileUnit *cu, + const DWARFDebugInfoEntry *die) +{ + // If we have no parent decl context to match this DIE matches, and if the parent + // decl context isn't valid, we aren't trying to look for any particular decl + // context so any die matches. + if (decl_ctx == nullptr || !decl_ctx->IsValid()) + return true; + + if (cu && die) + { + TypeSystem *type_system = GetTypeSystemForLanguage(cu->GetLanguageType()); + + if (type_system) + { + CompilerDeclContext actual_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (this, cu, die); + if (actual_decl_ctx) + return actual_decl_ctx == *decl_ctx; + } + } + return false; +} + uint32_t -SymbolFileDWARF::FindFunctions (const ConstString &name, - const lldb_private::ClangNamespaceDecl *namespace_decl, +SymbolFileDWARF::FindFunctions (const ConstString &name, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, @@ -2644,7 +2668,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (!append) sc_list.Clear(); - if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) + if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) return 0; // If name is empty then we won't find anything. @@ -2685,13 +2709,8 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); if (die) { - if (namespace_decl) - { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); - - if (!type_system->DIEIsInNamespace (namespace_decl, this, dwarf_cu, die)) - continue; - } + if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + continue; // The containing decl contexts don't match if (resolved_dies.find(die) == resolved_dies.end()) { @@ -2709,7 +2728,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (name_type_mask & eFunctionNameTypeSelector) { - if (namespace_decl && *namespace_decl) + if (parent_decl_ctx && parent_decl_ctx->IsValid()) return 0; // no selectors in namespaces num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); @@ -2741,7 +2760,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, die_offsets.clear(); } - if (((name_type_mask & eFunctionNameTypeMethod) && !namespace_decl) || name_type_mask & eFunctionNameTypeBase) + if (((name_type_mask & eFunctionNameTypeMethod) && !parent_decl_ctx) || name_type_mask & eFunctionNameTypeBase) { // The apple_names table stores just the "base name" of C++ methods in the table. So we have to // extract the base name, look that up, and if there is any other information in the name we were @@ -2756,13 +2775,9 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); if (die) { - if (namespace_decl) - { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + continue; // The containing decl contexts don't match - if (!type_system->DIEIsInNamespace (namespace_decl, this, dwarf_cu, die)) - continue; - } // If we get to here, the die is good, and we should add it: if (resolved_dies.find(die) == resolved_dies.end()) @@ -2786,8 +2801,8 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (type) { - clang::DeclContext* decl_ctx = GetClangDeclContextContainingTypeUID (type->GetID()); - if (decl_ctx->isRecord()) + CompilerDeclContext decl_ctx = GetDeclContextContainingUID (type->GetID()); + if (decl_ctx.IsStructUnionOrClass()) { if (name_type_mask & eFunctionNameTypeBase) { @@ -2849,7 +2864,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (sc_list.GetSize() == 0) { ArchSpec arch; - if (!namespace_decl && + if (!parent_decl_ctx && GetObjectFile()->GetArchitecture(arch) && (arch.GetTriple().isOSFreeBSD() || arch.GetTriple().isOSLinux() || arch.GetMachine() == llvm::Triple::hexagon)) @@ -2886,13 +2901,8 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); if (die) { - if (namespace_decl) - { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); - - if (!type_system->DIEIsInNamespace (namespace_decl, this, dwarf_cu, die)) - continue; - } + if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + continue; // The containing decl contexts don't match // If we get to here, the die is good, and we should add it: if (resolved_dies.find(die) == resolved_dies.end()) @@ -2907,7 +2917,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (name_type_mask & eFunctionNameTypeMethod) { - if (namespace_decl && *namespace_decl) + if (parent_decl_ctx && parent_decl_ctx->IsValid()) return 0; // no methods in namespaces uint32_t num_base = m_function_method_index.Find(name, die_offsets); @@ -2929,7 +2939,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, die_offsets.clear(); } - if ((name_type_mask & eFunctionNameTypeSelector) && (!namespace_decl || !*namespace_decl)) + if ((name_type_mask & eFunctionNameTypeSelector) && (!parent_decl_ctx || !parent_decl_ctx->IsValid())) { FindFunctions (name, m_function_selector_index, include_inlines, sc_list); } @@ -3001,7 +3011,7 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool include_inli uint32_t SymbolFileDWARF::FindTypes (const SymbolContext& sc, const ConstString &name, - const lldb_private::ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeList& types) @@ -3014,16 +3024,16 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, if (log) { - if (namespace_decl) + if (parent_decl_ctx) GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list)", + "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = %p (\"%s\"), append=%u, max_matches=%u, type_list)", name.GetCString(), - static_cast(namespace_decl->GetNamespaceDecl()), - namespace_decl->GetQualifiedName().c_str(), + static_cast(parent_decl_ctx), + parent_decl_ctx->GetName().AsCString(""), append, max_matches); else GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list)", + "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = NULL, append=%u, max_matches=%u, type_list)", name.GetCString(), append, max_matches); } @@ -3032,7 +3042,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, if (!append) types.Clear(); - if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) + if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) return 0; DIEArray die_offsets; @@ -3068,13 +3078,8 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, if (die) { - if (namespace_decl) - { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); - - if (!type_system->DIEIsInNamespace (namespace_decl, this, dwarf_cu, die)) - continue; - } + if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + continue; // The containing decl contexts don't match Type *matching_type = ResolveType (dwarf_cu, die); if (matching_type) @@ -3098,20 +3103,20 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, const uint32_t num_matches = types.GetSize() - initial_types_size; if (log && num_matches) { - if (namespace_decl) + if (parent_decl_ctx) { GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list) => %u", + "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = %p (\"%s\"), append=%u, max_matches=%u, type_list) => %u", name.GetCString(), - static_cast(namespace_decl->GetNamespaceDecl()), - namespace_decl->GetQualifiedName().c_str(), + static_cast(parent_decl_ctx), + parent_decl_ctx->GetName().AsCString(""), append, max_matches, num_matches); } else { GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list) => %u", + "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = NULL, append=%u, max_matches=%u, type_list) => %u", name.GetCString(), append, max_matches, num_matches); @@ -3123,10 +3128,10 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, } -ClangNamespaceDecl +CompilerDeclContext SymbolFileDWARF::FindNamespace (const SymbolContext& sc, const ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl) + const CompilerDeclContext *parent_decl_ctx) { Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -3136,11 +3141,13 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")", name.GetCString()); } - - if (!NamespaceDeclMatchesThisSymbolFile(parent_namespace_decl)) - return ClangNamespaceDecl(); - ClangNamespaceDecl namespace_decl; + CompilerDeclContext namespace_decl_ctx; + + if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) + return namespace_decl_ctx; + + DWARFDebugInfo* info = DebugInfo(); if (info) { @@ -3177,23 +3184,16 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, if (die) { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + continue; // The containing decl contexts don't match - if (parent_namespace_decl) - { - if (type_system && !type_system->DIEIsInNamespace (parent_namespace_decl, this, dwarf_cu, die)) - continue; - } + TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); if (type_system) { - clang::NamespaceDecl *clang_namespace_decl = type_system->ResolveNamespaceDIE (this, dwarf_cu, die); - if (clang_namespace_decl) - { - namespace_decl.SetASTContext (GetClangASTContext().getASTContext()); - namespace_decl.SetNamespaceDecl (clang_namespace_decl); + namespace_decl_ctx = type_system->GetDeclContextForUIDFromDWARF(this, dwarf_cu, die); + if (namespace_decl_ctx) break; - } } } else @@ -3208,16 +3208,17 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, } } } - if (log && namespace_decl.GetNamespaceDecl()) + if (log && namespace_decl_ctx) { GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => clang::NamespaceDecl(%p) \"%s\"", + "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => CompilerDeclContext(%p/%p) \"%s\"", name.GetCString(), - static_cast(namespace_decl.GetNamespaceDecl()), - namespace_decl.GetQualifiedName().c_str()); + static_cast(namespace_decl_ctx.GetTypeSystem()), + static_cast(namespace_decl_ctx.GetOpaqueDeclContext()), + namespace_decl_ctx.GetName().AsCString("")); } - return namespace_decl; + return namespace_decl_ctx; } uint32_t diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 55c7ce613f13..c9aab353b70c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -90,62 +90,145 @@ public: static lldb_private::SymbolFile* CreateInstance (lldb_private::ObjectFile* obj_file); + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SymbolFileDWARF(lldb_private::ObjectFile* ofile); - ~SymbolFileDWARF() override; - uint32_t CalculateAbilities () override; - void InitializeObject() override; + SymbolFileDWARF(lldb_private::ObjectFile* ofile); + + ~SymbolFileDWARF() override; + + uint32_t + CalculateAbilities () override; + + void + InitializeObject() override; //------------------------------------------------------------------ // Compile Unit function calls //------------------------------------------------------------------ - uint32_t GetNumCompileUnits() override; - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc) override; - size_t ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc) override; - bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override; - bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList& support_files) override; - bool ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; - size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override; - size_t ParseTypes (const lldb_private::SymbolContext& sc) override; - size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc) override; + uint32_t + GetNumCompileUnits() override; - lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid) override; - bool CompleteType (lldb_private::CompilerType& clang_type) override; + lldb::CompUnitSP + ParseCompileUnitAtIndex(uint32_t index) override; - lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true); - lldb_private::Type* GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const; - void ClearDIEBeingParsed (const DWARFDebugInfoEntry* type_die); - clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) override; - clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) override; + lldb::LanguageType + ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc) override; + + size_t + ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc) override; + + bool + ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override; + + bool + ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, + lldb_private::FileSpecList& support_files) override; + + bool + ParseImportedModules (const lldb_private::SymbolContext &sc, + std::vector &imported_modules) override; + + size_t + ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override; + + size_t + ParseTypes (const lldb_private::SymbolContext& sc) override; + + size_t + ParseVariablesForContext (const lldb_private::SymbolContext& sc) override; + + lldb_private::Type * + ResolveTypeUID(lldb::user_id_t type_uid) override; + + bool + CompleteType (lldb_private::CompilerType& clang_type) override; + + lldb_private::Type * + ResolveType (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry* type_die, + bool assert_not_being_parsed = true); + + lldb_private::Type * + GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const; + + void + ClearDIEBeingParsed (const DWARFDebugInfoEntry* type_die); + + lldb_private::CompilerDeclContext + GetDeclContextForUID (lldb::user_id_t uid) override; + + lldb_private::CompilerDeclContext + GetDeclContextContainingUID (lldb::user_id_t uid) override; + + uint32_t + ResolveSymbolContext (const lldb_private::Address& so_addr, + uint32_t resolve_scope, + lldb_private::SymbolContext& sc) override; + + uint32_t + ResolveSymbolContext (const lldb_private::FileSpec& file_spec, + uint32_t line, + bool check_inlines, + uint32_t resolve_scope, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindGlobalVariables (const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + bool append, + uint32_t max_matches, + lldb_private::VariableList& variables) override; + + uint32_t + FindGlobalVariables (const lldb_private::RegularExpression& regex, + bool append, + uint32_t max_matches, + lldb_private::VariableList& variables) override; + + uint32_t + FindFunctions (const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + uint32_t name_type_mask, + bool include_inlines, + bool append, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindFunctions (const lldb_private::RegularExpression& regex, + bool include_inlines, + bool append, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindTypes (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + bool append, + uint32_t max_matches, + lldb_private::TypeList& types) override; - uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc) override; - uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list) override; - uint32_t FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override; - uint32_t FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override; - uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override; - uint32_t FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override; - uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types) override; lldb_private::TypeList * - GetTypeList () override; - size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, - lldb_private::TypeList &type_list) override; + GetTypeList () override; + + size_t + GetTypes (lldb_private::SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list) override; lldb_private::ClangASTContext & - GetClangASTContext () override; + GetClangASTContext () override; lldb_private::TypeSystem * - GetTypeSystemForLanguage (lldb::LanguageType language) override; + GetTypeSystemForLanguage (lldb::LanguageType language) override; - lldb_private::ClangNamespaceDecl - FindNamespace (const lldb_private::SymbolContext& sc, - const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl) override; + lldb_private::CompilerDeclContext + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx) override; //------------------------------------------------------------------ @@ -171,14 +254,22 @@ public: const lldb_private::DWARFDataExtractor& get_apple_objc_data (); - DWARFDebugAbbrev* DebugAbbrev(); - const DWARFDebugAbbrev* DebugAbbrev() const; + DWARFDebugAbbrev* + DebugAbbrev(); - DWARFDebugInfo* DebugInfo(); - const DWARFDebugInfo* DebugInfo() const; + const DWARFDebugAbbrev* + DebugAbbrev() const; - DWARFDebugRanges* DebugRanges(); - const DWARFDebugRanges* DebugRanges() const; + DWARFDebugInfo* + DebugInfo(); + + const DWARFDebugInfo* + DebugInfo() const; + + DWARFDebugRanges* + DebugRanges(); + const DWARFDebugRanges* + DebugRanges() const; const lldb_private::DWARFDataExtractor& GetCachedSectionData (uint32_t got_flag, @@ -189,7 +280,8 @@ public: SupportedVersion(uint16_t version); const DWARFDebugInfoEntry * - GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); + GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, + const DWARFDebugInfoEntry *die); lldb_private::Flags& GetFlags () @@ -207,7 +299,8 @@ public: HasForwardDeclForClangType (const lldb_private::CompilerType &clang_type); lldb_private::CompileUnit* - GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx = UINT32_MAX); + GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, + uint32_t cu_idx = UINT32_MAX); lldb::user_id_t MakeUserID (dw_offset_t die_offset) const @@ -216,7 +309,8 @@ public: } size_t - GetObjCMethodDIEOffsets (lldb_private::ConstString class_name, DIEArray &method_die_offsets); + GetObjCMethodDIEOffsets (lldb_private::ConstString class_name, + DIEArray &method_die_offsets); bool Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu); @@ -245,123 +339,174 @@ protected: flagsGotAppleObjCData = (1 << 14) }; - bool NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl); + bool + DeclContextMatchesThisSymbolFile (const lldb_private::CompilerDeclContext *decl_ctx); + + bool + DIEInDeclContext (const lldb_private::CompilerDeclContext *parent_decl_ctx, + DWARFCompileUnit *cu, + const DWARFDebugInfoEntry *die); DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF); - lldb::CompUnitSP ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx); - DWARFCompileUnit* GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); - DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu); - bool GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc); - lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); - size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, - lldb_private::Block *parent_block, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - lldb::addr_t subprogram_low_pc, - uint32_t depth); - size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); - lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new); - lldb_private::Type* ResolveTypeUID (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed); - lldb::VariableSP ParseVariableDIE( - const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - const lldb::addr_t func_low_pc); + lldb::CompUnitSP + ParseCompileUnit (DWARFCompileUnit* dwarf_cu, + uint32_t cu_idx); - size_t ParseVariables( - const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const lldb::addr_t func_low_pc, - const DWARFDebugInfoEntry *die, - bool parse_siblings, - bool parse_children, - lldb_private::VariableList* cc_variable_list = NULL); + DWARFCompileUnit* + GetDWARFCompileUnit (lldb_private::CompileUnit *comp_unit); + + DWARFCompileUnit* + GetNextUnparsedDWARFCompileUnit (DWARFCompileUnit* prev_cu); + + bool + GetFunction (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry* func_die, + lldb_private::SymbolContext& sc); + + lldb_private::Function * + ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die); + + size_t + ParseFunctionBlocks (const lldb_private::SymbolContext& sc, + lldb_private::Block *parent_block, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + lldb::addr_t subprogram_low_pc, + uint32_t depth); + + size_t + ParseTypes (const lldb_private::SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + bool parse_siblings, + bool parse_children); + + lldb::TypeSP + ParseType (const lldb_private::SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + bool *type_is_new); + + lldb_private::Type * + ResolveTypeUID (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry* die, + bool assert_not_being_parsed); + + lldb::VariableSP + ParseVariableDIE(const lldb_private::SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + const lldb::addr_t func_low_pc); + + size_t + ParseVariables(const lldb_private::SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const lldb::addr_t func_low_pc, + const DWARFDebugInfoEntry *die, + bool parse_siblings, + bool parse_children, + lldb_private::VariableList* cc_variable_list = NULL); + + bool + ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *parent_die); + + // Given a die_offset, figure out the symbol context representing that die. + bool + ResolveFunction (dw_offset_t offset, + DWARFCompileUnit *&dwarf_cu, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + bool + ResolveFunction (DWARFCompileUnit *cu, + const DWARFDebugInfoEntry *die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + bool + FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, + const DWARFCompileUnit *dwarf_cu, + uint32_t name_type_mask, + const char *partial_name, + const char *base_name_start, + const char *base_name_end); + + void + FindFunctions(const lldb_private::ConstString &name, + const NameToDIE &name_to_die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + void + FindFunctions (const lldb_private::RegularExpression ®ex, + const NameToDIE &name_to_die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + void + FindFunctions (const lldb_private::RegularExpression ®ex, + const DWARFMappedHash::MemoryTable &memory_table, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + lldb::TypeSP + FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx); + + lldb::TypeSP + FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name, + bool must_be_implementation); + + lldb::TypeSP + FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name, + bool header_definition_ok); + + lldb_private::Symbol * + GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); + + void + ParseFunctions (const DIEArray &die_offsets, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + lldb::TypeSP + GetTypeForDIE (DWARFCompileUnit *cu, + const DWARFDebugInfoEntry* die); + + uint32_t + FindTypes (std::vector die_offsets, + uint32_t max_matches, + lldb_private::TypeList& types); + + void + Index(); - bool ClassOrStructIsVirtual ( - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die); + void + DumpIndexes(); - // Given a die_offset, figure out the symbol context representing that die. - bool ResolveFunction (dw_offset_t offset, - DWARFCompileUnit *&dwarf_cu, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - bool ResolveFunction (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); + void + SetDebugMapModule (const lldb::ModuleSP &module_sp) + { + m_debug_map_module_wp = module_sp; + } - bool FunctionDieMatchesPartialName ( - const DWARFDebugInfoEntry* die, - const DWARFCompileUnit *dwarf_cu, - uint32_t name_type_mask, - const char *partial_name, - const char *base_name_start, - const char *base_name_end); - - void FindFunctions( - const lldb_private::ConstString &name, - const NameToDIE &name_to_die, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - void FindFunctions ( - const lldb_private::RegularExpression ®ex, - const NameToDIE &name_to_die, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - void FindFunctions ( - const lldb_private::RegularExpression ®ex, - const DWARFMappedHash::MemoryTable &memory_table, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - lldb::TypeSP FindDefinitionTypeForDWARFDeclContext ( - const DWARFDeclContext &die_decl_ctx); - - lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE ( - const DWARFDebugInfoEntry *die, - const lldb_private::ConstString &type_name, - bool must_be_implementation); - - lldb::TypeSP FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name, - bool header_definition_ok); - - lldb_private::Symbol * GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); - - void ParseFunctions (const DIEArray &die_offsets, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die); - - uint32_t FindTypes(std::vector die_offsets, uint32_t max_matches, lldb_private::TypeList& types); - - void Index(); - - void DumpIndexes(); - - void SetDebugMapModule (const lldb::ModuleSP &module_sp) - { - m_debug_map_module_wp = module_sp; - } - SymbolFileDWARFDebugMap * - GetDebugMapSymfile (); + GetDebugMapSymfile (); const DWARFDebugInfoEntry * - FindBlockContainingSpecification (dw_offset_t func_die_offset, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); + FindBlockContainingSpecification (dw_offset_t func_die_offset, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **dwarf_cu_handle); const DWARFDebugInfoEntry * - FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); + FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **dwarf_cu_handle); UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap (); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index e2ab962a948c..dc0c42e22a01 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -877,7 +877,7 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables ( const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, const std::vector &indexes, // Indexes into the symbol table that match "name" uint32_t max_matches, VariableList& variables @@ -894,7 +894,7 @@ SymbolFileDWARFDebugMap::PrivateFindGlobalVariables SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); if (oso_dwarf) { - if (oso_dwarf->FindGlobalVariables(name, namespace_decl, true, max_matches, variables)) + if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, true, max_matches, variables)) if (variables.GetSize() > max_matches) break; } @@ -904,7 +904,11 @@ SymbolFileDWARFDebugMap::PrivateFindGlobalVariables } uint32_t -SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) +SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, + const CompilerDeclContext *parent_decl_ctx, + bool append, + uint32_t max_matches, + VariableList& variables) { // If we aren't appending the results to this list, then clear the list @@ -919,7 +923,7 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const Cla ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name, - namespace_decl, + parent_decl_ctx, true, max_matches, variables); @@ -1097,7 +1101,12 @@ RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextLis } uint32_t -SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) +SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, + const CompilerDeclContext *parent_decl_ctx, + uint32_t name_type_mask, + bool include_inlines, + bool append, + SymbolContextList& sc_list) { Timer scoped_timer (__PRETTY_FUNCTION__, "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", @@ -1111,7 +1120,7 @@ SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNames ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { uint32_t sc_idx = sc_list.GetSize(); - if (oso_dwarf->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, true, sc_list)) + if (oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, true, sc_list)) { RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx); } @@ -1286,8 +1295,8 @@ SymbolFileDWARFDebugMap::FindTypes ( const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, - bool append, + const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, TypeList& types ) @@ -1302,12 +1311,12 @@ SymbolFileDWARFDebugMap::FindTypes { oso_dwarf = GetSymbolFile (sc); if (oso_dwarf) - return oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); + return oso_dwarf->FindTypes (sc, name, parent_decl_ctx, append, max_matches, types); } else { ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); + oso_dwarf->FindTypes (sc, name, parent_decl_ctx, append, max_matches, types); return false; }); } @@ -1326,24 +1335,24 @@ SymbolFileDWARFDebugMap::FindTypes //} -ClangNamespaceDecl +CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, - const ClangNamespaceDecl *parent_namespace_decl) + const CompilerDeclContext *parent_decl_ctx) { - ClangNamespaceDecl matching_namespace; + CompilerDeclContext matching_namespace; SymbolFileDWARF *oso_dwarf; if (sc.comp_unit) { oso_dwarf = GetSymbolFile (sc); if (oso_dwarf) - matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); + matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_decl_ctx); } else { ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); + matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_decl_ctx); return (bool)matching_namespace; }); @@ -1433,24 +1442,24 @@ SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompU } } -clang::DeclContext* -SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) +CompilerDeclContext +SymbolFileDWARFDebugMap::GetDeclContextForUID (lldb::user_id_t type_uid) { const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); if (oso_dwarf) - return oso_dwarf->GetClangDeclContextContainingTypeUID (type_uid); - return NULL; + return oso_dwarf->GetDeclContextForUID (type_uid); + return CompilerDeclContext(); } -clang::DeclContext* -SymbolFileDWARFDebugMap::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) +CompilerDeclContext +SymbolFileDWARFDebugMap::GetDeclContextContainingUID (lldb::user_id_t type_uid) { const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); if (oso_dwarf) - return oso_dwarf->GetClangDeclContextForTypeUID (sc, type_uid); - return NULL; + return oso_dwarf->GetDeclContextContainingUID (type_uid); + return CompilerDeclContext(); } bool diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 2fc5d047f544..fb4d1f882647 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -75,20 +75,20 @@ public: size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc) override; lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid) override; - clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) override; - clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) override; + lldb_private::CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) override; + lldb_private::CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t uid) override; bool CompleteType (lldb_private::CompilerType& clang_type) override; uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc) override; uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list) override; - uint32_t FindGlobalVariables (const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override; + uint32_t FindGlobalVariables (const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override; uint32_t FindGlobalVariables (const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override; - uint32_t FindFunctions (const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override; + uint32_t FindFunctions (const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override; uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override; - uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types) override; - lldb_private::ClangNamespaceDecl + uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, lldb_private::TypeList& types) override; + lldb_private::CompilerDeclContext FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl) override; + const lldb_private::CompilerDeclContext *parent_decl_ctx) override; size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, uint32_t type_mask, lldb_private::TypeList &type_list) override; @@ -244,7 +244,7 @@ protected: uint32_t PrivateFindGlobalVariables (const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *namespace_decl, + const lldb_private::CompilerDeclContext *parent_decl_ctx, const std::vector &name_symbol_indexes, uint32_t max_matches, lldb_private::VariableList& variables); diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 5308db393c0e..edbe7379a865 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -305,12 +305,6 @@ SymbolFileSymtab::CompleteType (lldb_private::CompilerType& clang_opaque_type) return false; } -ClangNamespaceDecl -SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl) -{ - return ClangNamespaceDecl(); -} - uint32_t SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) { @@ -327,63 +321,6 @@ SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve return resolved_flags; } -uint32_t -SymbolFileSymtab::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) -{ - return 0; -} - -uint32_t -SymbolFileSymtab::FindGlobalVariables(const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) -{ - return 0; -} - -uint32_t -SymbolFileSymtab::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) -{ - return 0; -} - -uint32_t -SymbolFileSymtab::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) -{ - Timer scoped_timer (__PRETTY_FUNCTION__, - "SymbolFileSymtab::FindFunctions (name = '%s')", - name.GetCString()); - // If we ever support finding STABS or COFF debug info symbols, - // we will need to add support here. We are not trying to find symbols - // here, just "lldb_private::Function" objects that come from complete - // debug information. Any symbol queries should go through the symbol - // table itself in the module's object file. - return 0; -} - -uint32_t -SymbolFileSymtab::FindFunctions(const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) -{ - Timer scoped_timer (__PRETTY_FUNCTION__, - "SymbolFileSymtab::FindFunctions (regex = '%s')", - regex.GetText()); - // If we ever support finding STABS or COFF debug info symbols, - // we will need to add support here. We are not trying to find symbols - // here, just "lldb_private::Function" objects that come from complete - // debug information. Any symbol queries should go through the symbol - // table itself in the module's object file. - return 0; -} - -uint32_t -SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, - const lldb_private::ConstString &name, - const ClangNamespaceDecl *namespace_decl, - bool append, - uint32_t max_matches, - lldb_private::TypeList& types) -{ - return 0; -} - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index 8ff2181a414d..624bf40914e1 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -87,34 +87,11 @@ public: virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); - virtual uint32_t - ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); - - virtual uint32_t - FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables); - - virtual uint32_t - FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables); - - virtual uint32_t - FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list); - - virtual uint32_t - FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list); - - virtual uint32_t - FindTypes (const lldb_private::SymbolContext& sc,const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types); - virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, uint32_t type_mask, lldb_private::TypeList &type_list); - virtual lldb_private::ClangNamespaceDecl - FindNamespace (const lldb_private::SymbolContext& sc, - const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl); - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index bd5cf2b44bb5..a882b7e3e878 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -298,25 +298,25 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Value return_buffer_ptr_value; return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); - return_buffer_ptr_value.SetClangType (clang_void_ptr_type); + return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); Value debug_value; debug_value.SetValueType (Value::eValueTypeScalar); - debug_value.SetClangType (clang_int_type); + debug_value.SetCompilerType (clang_int_type); CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); Value item_value; item_value.SetValueType (Value::eValueTypeScalar); - item_value.SetClangType (clang_uint64_type); + item_value.SetCompilerType (clang_uint64_type); Value page_to_free_value; page_to_free_value.SetValueType (Value::eValueTypeScalar); - page_to_free_value.SetClangType (clang_void_ptr_type); + page_to_free_value.SetCompilerType (clang_void_ptr_type); Value page_to_free_size_value; page_to_free_size_value.SetValueType (Value::eValueTypeScalar); - page_to_free_size_value.SetClangType (clang_uint64_type); + page_to_free_size_value.SetCompilerType (clang_uint64_type); Mutex::Locker locker(m_get_item_info_retbuffer_mutex); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index 98cf4ca8fdce..c3e68eaa0a6c 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -304,25 +304,25 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Value return_buffer_ptr_value; return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); - return_buffer_ptr_value.SetClangType (clang_void_ptr_type); + return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); Value debug_value; debug_value.SetValueType (Value::eValueTypeScalar); - debug_value.SetClangType (clang_int_type); + debug_value.SetCompilerType (clang_int_type); CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); Value queue_value; queue_value.SetValueType (Value::eValueTypeScalar); - queue_value.SetClangType (clang_uint64_type); + queue_value.SetCompilerType (clang_uint64_type); Value page_to_free_value; page_to_free_value.SetValueType (Value::eValueTypeScalar); - page_to_free_value.SetClangType (clang_void_ptr_type); + page_to_free_value.SetCompilerType (clang_void_ptr_type); Value page_to_free_size_value; page_to_free_size_value.SetValueType (Value::eValueTypeScalar); - page_to_free_size_value.SetClangType (clang_uint64_type); + page_to_free_size_value.SetCompilerType (clang_uint64_type); Mutex::Locker locker(m_get_pending_items_retbuffer_mutex); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index 0c76f4f1a9a5..1d9dac5b1610 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -311,21 +311,21 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Value return_buffer_ptr_value; return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); - return_buffer_ptr_value.SetClangType (clang_void_ptr_type); + return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); Value debug_value; debug_value.SetValueType (Value::eValueTypeScalar); - debug_value.SetClangType (clang_int_type); + debug_value.SetCompilerType (clang_int_type); Value page_to_free_value; page_to_free_value.SetValueType (Value::eValueTypeScalar); - page_to_free_value.SetClangType (clang_void_ptr_type); + page_to_free_value.SetCompilerType (clang_void_ptr_type); CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); Value page_to_free_size_value; page_to_free_size_value.SetValueType (Value::eValueTypeScalar); - page_to_free_size_value.SetClangType (clang_uint64_type); + page_to_free_size_value.SetCompilerType (clang_uint64_type); Mutex::Locker locker(m_get_queues_retbuffer_mutex); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index 78511e0777e6..2509b3ba0ef0 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -301,25 +301,25 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Value return_buffer_ptr_value; return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); - return_buffer_ptr_value.SetClangType (clang_void_ptr_type); + return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); Value debug_value; debug_value.SetValueType (Value::eValueTypeScalar); - debug_value.SetClangType (clang_int_type); + debug_value.SetCompilerType (clang_int_type); CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); Value thread_id_value; thread_id_value.SetValueType (Value::eValueTypeScalar); - thread_id_value.SetClangType (clang_uint64_type); + thread_id_value.SetCompilerType (clang_uint64_type); Value page_to_free_value; page_to_free_value.SetValueType (Value::eValueTypeScalar); - page_to_free_value.SetClangType (clang_void_ptr_type); + page_to_free_value.SetCompilerType (clang_void_ptr_type); Value page_to_free_size_value; page_to_free_size_value.SetValueType (Value::eValueTypeScalar); - page_to_free_size_value.SetClangType (clang_uint64_type); + page_to_free_size_value.SetCompilerType (clang_uint64_type); Mutex::Locker locker(m_get_thread_item_info_retbuffer_mutex); diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 94fa166bb265..dfe9217362bd 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -546,27 +546,24 @@ Block::AppendVariables return num_variables_added; } -clang::DeclContext * -Block::GetClangDeclContext() +CompilerDeclContext +Block::GetDeclContext() { - SymbolContext sc; + ModuleSP module_sp = CalculateSymbolContextModule (); + + if (module_sp) + { + SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); - CalculateSymbolContext (&sc); + if (sym_vendor) + { + SymbolFile *sym_file = sym_vendor->GetSymbolFile(); - if (!sc.module_sp) - return nullptr; - - SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); - - if (!sym_vendor) - return nullptr; - - SymbolFile *sym_file = sym_vendor->GetSymbolFile(); - - if (!sym_file) - return nullptr; - - return sym_file->GetClangDeclContextForTypeUID (sc, m_uid); + if (sym_file) + return sym_file->GetDeclContextForUID (GetID()); + } + } + return CompilerDeclContext(); } void diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt index e14537033238..19ca0d08d837 100644 --- a/lldb/source/Symbol/CMakeLists.txt +++ b/lldb/source/Symbol/CMakeLists.txt @@ -6,7 +6,7 @@ add_lldb_library(lldbSymbol ClangASTImporter.cpp ClangExternalASTSourceCallbacks.cpp ClangExternalASTSourceCommon.cpp - ClangNamespaceDecl.cpp + CompilerDeclContext.cpp CompilerType.cpp CompileUnit.cpp CompactUnwindInfo.cpp diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 418c266ff9f1..1de5cb6cec06 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2188,64 +2188,6 @@ ClangASTContext::GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl) return llvm::dyn_cast(objc_method_decl); } - -bool -ClangASTContext::GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx, - lldb::LanguageType &language, - bool &is_instance_method, - ConstString &language_object_name) -{ - language_object_name.Clear(); - language = eLanguageTypeUnknown; - is_instance_method = false; - - if (decl_ctx) - { - if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast(decl_ctx)) - { - if (method_decl->isStatic()) - { - is_instance_method = false; - } - else - { - language_object_name.SetCString("this"); - is_instance_method = true; - } - language = eLanguageTypeC_plus_plus; - return true; - } - else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast(decl_ctx)) - { - // Both static and instance methods have a "self" object in objective C - language_object_name.SetCString("self"); - if (method_decl->isInstanceMethod()) - { - is_instance_method = true; - } - else - { - is_instance_method = false; - } - language = eLanguageTypeObjC; - return true; - } - else if (clang::FunctionDecl *function_decl = llvm::dyn_cast(decl_ctx)) - { - ClangASTMetadata *metadata = GetMetadata (&decl_ctx->getParentASTContext(), function_decl); - if (metadata && metadata->HasObjectPtr()) - { - language_object_name.SetCString (metadata->GetObjectPtrName()); - language = eLanguageTypeObjC; - is_instance_method = true; - } - return true; - } - } - return false; -} - - bool ClangASTContext::SetTagTypeKind (clang::QualType tag_qual_type, int kind) const { @@ -2290,6 +2232,12 @@ ClangASTContext::SetDefaultAccessForRecordFields (clang::RecordDecl* record_decl return false; } +clang::DeclContext * +ClangASTContext::GetDeclContextForType (const CompilerType& type) +{ + return GetDeclContextForType(GetQualType(type)); +} + clang::DeclContext * ClangASTContext::GetDeclContextForType (clang::QualType type) { @@ -2300,24 +2248,6 @@ ClangASTContext::GetDeclContextForType (clang::QualType type) const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { - case clang::Type::UnaryTransform: break; - case clang::Type::FunctionNoProto: break; - case clang::Type::FunctionProto: break; - case clang::Type::IncompleteArray: break; - case clang::Type::VariableArray: break; - case clang::Type::ConstantArray: break; - case clang::Type::DependentSizedArray: break; - case clang::Type::ExtVector: break; - case clang::Type::DependentSizedExtVector: break; - case clang::Type::Vector: break; - case clang::Type::Builtin: break; - case clang::Type::BlockPointer: break; - case clang::Type::Pointer: break; - case clang::Type::LValueReference: break; - case clang::Type::RValueReference: break; - case clang::Type::MemberPointer: break; - case clang::Type::Complex: break; - case clang::Type::ObjCObject: break; case clang::Type::ObjCInterface: return llvm::cast(qual_type.getTypePtr())->getInterface(); case clang::Type::ObjCObjectPointer: return GetDeclContextForType (llvm::cast(qual_type.getTypePtr())->getPointeeType()); case clang::Type::Record: return llvm::cast(qual_type)->getDecl(); @@ -2325,26 +2255,8 @@ ClangASTContext::GetDeclContextForType (clang::QualType type) case clang::Type::Typedef: return GetDeclContextForType (llvm::cast(qual_type)->getDecl()->getUnderlyingType()); case clang::Type::Elaborated: return GetDeclContextForType (llvm::cast(qual_type)->getNamedType()); case clang::Type::Paren: return GetDeclContextForType (llvm::cast(qual_type)->desugar()); - case clang::Type::TypeOfExpr: break; - case clang::Type::TypeOf: break; - case clang::Type::Decltype: break; - //case clang::Type::QualifiedName: break; - case clang::Type::TemplateSpecialization: break; - case clang::Type::DependentTemplateSpecialization: break; - case clang::Type::TemplateTypeParm: break; - case clang::Type::SubstTemplateTypeParm: break; - case clang::Type::SubstTemplateTypeParmPack:break; - case clang::Type::PackExpansion: break; - case clang::Type::UnresolvedUsing: break; - case clang::Type::Attributed: break; - case clang::Type::Auto: break; - 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; + default: + break; } // No DeclContext in this type... return nullptr; @@ -2517,14 +2429,14 @@ ClangASTContext::IsArrayType (void* type, case clang::Type::ConstantArray: if (element_type_ptr) - element_type_ptr->SetClangType (getASTContext(), llvm::cast(qual_type)->getElementType()); + element_type_ptr->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getElementType()); if (size) *size = llvm::cast(qual_type)->getSize().getLimitedValue(ULLONG_MAX); return true; case clang::Type::IncompleteArray: if (element_type_ptr) - element_type_ptr->SetClangType (getASTContext(), llvm::cast(qual_type)->getElementType()); + element_type_ptr->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getElementType()); if (size) *size = 0; if (is_incomplete) @@ -2533,14 +2445,14 @@ ClangASTContext::IsArrayType (void* type, case clang::Type::VariableArray: if (element_type_ptr) - element_type_ptr->SetClangType (getASTContext(), llvm::cast(qual_type)->getElementType()); + element_type_ptr->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getElementType()); if (size) *size = 0; return true; case clang::Type::DependentSizedArray: if (element_type_ptr) - element_type_ptr->SetClangType (getASTContext(), llvm::cast(qual_type)->getElementType()); + element_type_ptr->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getElementType()); if (size) *size = 0; return true; @@ -2923,19 +2835,19 @@ ClangASTContext::IsPointerType (void* type, CompilerType *pointee_type) return false; case clang::Type::ObjCObjectPointer: if (pointee_type) - pointee_type->SetClangType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::BlockPointer: if (pointee_type) - pointee_type->SetClangType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::Pointer: if (pointee_type) - pointee_type->SetClangType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::MemberPointer: if (pointee_type) - pointee_type->SetClangType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType (getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::Typedef: return IsPointerType (llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), pointee_type); @@ -2974,27 +2886,27 @@ ClangASTContext::IsPointerOrReferenceType (void* type, CompilerType *pointee_typ return false; case clang::Type::ObjCObjectPointer: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::BlockPointer: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::Pointer: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::MemberPointer: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; case clang::Type::LValueReference: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->desugar()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->desugar()); return true; case clang::Type::RValueReference: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->desugar()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->desugar()); return true; case clang::Type::Typedef: return IsPointerOrReferenceType(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), pointee_type); @@ -3024,13 +2936,13 @@ ClangASTContext::IsReferenceType (void* type, CompilerType *pointee_type, bool* { case clang::Type::LValueReference: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->desugar()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->desugar()); if (is_rvalue) *is_rvalue = false; return true; case clang::Type::RValueReference: if (pointee_type) - pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->desugar()); + pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->desugar()); if (is_rvalue) *is_rvalue = true; return true; @@ -3191,7 +3103,7 @@ ClangASTContext::IsPossibleDynamicType (void* type, CompilerType *dynamic_pointe if (check_objc && llvm::cast(qual_type)->getKind() == clang::BuiltinType::ObjCId) { if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(this, type); + dynamic_pointee_type->SetCompilerType(this, type); return true; } break; @@ -3200,7 +3112,7 @@ ClangASTContext::IsPossibleDynamicType (void* type, CompilerType *dynamic_pointe if (check_objc) { if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); + dynamic_pointee_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getPointeeType()); return true; } break; @@ -3251,7 +3163,7 @@ ClangASTContext::IsPossibleDynamicType (void* type, CompilerType *dynamic_pointe case clang::BuiltinType::UnknownAny: case clang::BuiltinType::Void: if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(getASTContext(), pointee_qual_type); + dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type); return true; case clang::BuiltinType::NullPtr: @@ -3327,7 +3239,7 @@ ClangASTContext::IsPossibleDynamicType (void* type, CompilerType *dynamic_pointe if (success) { if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(getASTContext(), pointee_qual_type); + dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type); return true; } } @@ -3339,7 +3251,7 @@ ClangASTContext::IsPossibleDynamicType (void* type, CompilerType *dynamic_pointe if (check_objc) { if (dynamic_pointee_type) - dynamic_pointee_type->SetClangType(getASTContext(), pointee_qual_type); + dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type); return true; } break; @@ -3442,7 +3354,7 @@ ClangASTContext::IsObjCObjectPointerType (const CompilerType& type, CompilerType if (obj_pointer_type == nullptr) class_type_ptr->Clear(); else - class_type_ptr->SetClangType (type.GetTypeSystem(), clang::QualType(obj_pointer_type->getInterfaceType(), 0).getAsOpaquePtr()); + class_type_ptr->SetCompilerType (type.GetTypeSystem(), clang::QualType(obj_pointer_type->getInterfaceType(), 0).getAsOpaquePtr()); } } return true; @@ -3535,13 +3447,13 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCClass: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), getASTContext()->ObjCBuiltinClassTy); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), getASTContext()->ObjCBuiltinClassTy); builtin_type_flags |= eTypeIsPointer | eTypeIsObjC; break; case clang::BuiltinType::ObjCSel: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), getASTContext()->CharTy); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), getASTContext()->CharTy); builtin_type_flags |= eTypeIsPointer | eTypeIsObjC; break; @@ -3585,7 +3497,7 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::Type::BlockPointer: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), qual_type->getPointeeType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType()); return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock; case clang::Type::Complex: @@ -3609,7 +3521,7 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::Type::IncompleteArray: case clang::Type::VariableArray: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), llvm::cast(qual_type.getTypePtr())->getElementType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast(qual_type.getTypePtr())->getElementType()); return eTypeHasChildren | eTypeIsArray; case clang::Type::DependentName: return 0; @@ -3619,7 +3531,7 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::Type::Enum: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), llvm::cast(qual_type)->getDecl()->getIntegerType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast(qual_type)->getDecl()->getIntegerType()); return eTypeIsEnumeration | eTypeHasValue; case clang::Type::Elaborated: @@ -3634,14 +3546,14 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::Type::LValueReference: case clang::Type::RValueReference: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), llvm::cast(qual_type.getTypePtr())->getPointeeType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast(qual_type.getTypePtr())->getPointeeType()); return eTypeHasChildren | eTypeIsReference | eTypeHasValue; case clang::Type::MemberPointer: return eTypeIsPointer | eTypeIsMember | eTypeHasValue; case clang::Type::ObjCObjectPointer: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), qual_type->getPointeeType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType()); return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer | eTypeHasValue; case clang::Type::ObjCObject: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass; @@ -3649,7 +3561,7 @@ ClangASTContext::GetTypeInfo (void* type, CompilerType *pointee_or_element_clang case clang::Type::Pointer: if (pointee_or_element_clang_type) - pointee_or_element_clang_type->SetClangType(getASTContext(), qual_type->getPointeeType()); + pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType()); return eTypeHasChildren | eTypeIsPointer | eTypeHasValue; case clang::Type::Record: @@ -4224,7 +4136,7 @@ ClangASTContext::GetNonReferenceType (void* type) CompilerType ClangASTContext::CreateTypedefType (const CompilerType& type, const char *typedef_name, - clang::DeclContext *decl_ctx) + const CompilerDeclContext &compiler_decl_ctx) { if (type && typedef_name && typedef_name[0]) { @@ -4233,8 +4145,11 @@ ClangASTContext::CreateTypedefType (const CompilerType& type, return CompilerType(); clang::ASTContext* clang_ast = ast->getASTContext(); clang::QualType qual_type (GetQualType(type)); + + clang::DeclContext *decl_ctx = ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx); if (decl_ctx == nullptr) decl_ctx = ast->getASTContext()->getTranslationUnitDecl(); + clang::TypedefDecl *decl = clang::TypedefDecl::Create (*clang_ast, decl_ctx, clang::SourceLocation(), @@ -4313,11 +4228,9 @@ ClangASTContext::RemoveFastQualifiers (const CompilerType& type) //---------------------------------------------------------------------- CompilerType -ClangASTContext::GetBasicTypeFromAST (void* type, lldb::BasicType basic_type) +ClangASTContext::GetBasicTypeFromAST (lldb::BasicType basic_type) { - if (type) - return ClangASTContext::GetBasicType(getASTContext(), basic_type); - return CompilerType(); + return ClangASTContext::GetBasicType(getASTContext(), basic_type); } //---------------------------------------------------------------------- // Exploring the type @@ -4925,122 +4838,31 @@ ClangASTContext::GetBasicTypeEnumeration (void* type) return eBasicTypeInvalid; } +void +ClangASTContext::ForEachEnumerator (void* type, std::function const &callback) +{ + const clang::EnumType *enum_type = llvm::dyn_cast(GetCanonicalQualType(type)); + if (enum_type) + { + const clang::EnumDecl *enum_decl = enum_type->getDecl(); + if (enum_decl) + { + CompilerType integer_type(this, enum_decl->getIntegerType().getAsOpaquePtr()); + + clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; + for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) + { + ConstString name(enum_pos->getNameAsString().c_str()); + if (!callback (integer_type, name, enum_pos->getInitVal())) + break; + } + } + } +} + #pragma mark Aggregate Types -uint32_t -ClangASTContext::GetNumDirectBaseClasses (const CompilerType& type) -{ - if (!type) - return 0; - ClangASTContext *ast = type.GetTypeSystem()->AsClangASTContext(); - if (!ast) - return 0; - - uint32_t count = 0; - clang::QualType qual_type(GetCanonicalQualType(type)); - const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (type_class) - { - case clang::Type::Record: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl) - count = cxx_record_decl->getNumBases(); - } - break; - - case clang::Type::ObjCObjectPointer: - count = GetNumDirectBaseClasses(ast->GetPointeeType(type.GetOpaqueQualType())); - break; - - case clang::Type::ObjCObject: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); - if (objc_class_type) - { - clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); - - if (class_interface_decl && class_interface_decl->getSuperClass()) - count = 1; - } - } - break; - case clang::Type::ObjCInterface: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::ObjCInterfaceType *objc_interface_type = qual_type->getAs(); - if (objc_interface_type) - { - clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); - - if (class_interface_decl && class_interface_decl->getSuperClass()) - count = 1; - } - } - break; - - - case clang::Type::Typedef: - count = GetNumDirectBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->getDecl()->getUnderlyingType())); - break; - - case clang::Type::Elaborated: - count = GetNumDirectBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->getNamedType())); - break; - - case clang::Type::Paren: - return GetNumDirectBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->desugar())); - - default: - break; - } - return count; -} - -uint32_t -ClangASTContext::GetNumVirtualBaseClasses (const CompilerType& type) -{ - if (!type) - return 0; - ClangASTContext *ast = type.GetTypeSystem()->AsClangASTContext(); - if (!ast) - return 0; - - uint32_t count = 0; - clang::QualType qual_type(GetCanonicalQualType(type)); - const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (type_class) - { - case clang::Type::Record: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl) - count = cxx_record_decl->getNumVBases(); - } - break; - - case clang::Type::Typedef: - count = GetNumVirtualBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->getDecl()->getUnderlyingType())); - break; - - case clang::Type::Elaborated: - count = GetNumVirtualBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->getNamedType())); - break; - - case clang::Type::Paren: - count = GetNumVirtualBaseClasses(CompilerType (ast->getASTContext(), llvm::cast(qual_type)->desugar())); - break; - - default: - break; - } - return count; -} - uint32_t ClangASTContext::GetNumFields (void* type) { @@ -5118,167 +4940,6 @@ ClangASTContext::GetNumFields (void* type) return count; } -CompilerType -ClangASTContext::GetDirectBaseClassAtIndex (const CompilerType& type, size_t idx, uint32_t *bit_offset_ptr) -{ - if (!type) - return CompilerType(); - ClangASTContext *ast = type.GetTypeSystem()->AsClangASTContext(); - if (!ast) - return CompilerType(); - - clang::QualType qual_type(GetCanonicalQualType(type)); - const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (type_class) - { - case clang::Type::Record: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl) - { - uint32_t curr_idx = 0; - 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) - { - if (curr_idx == idx) - { - if (bit_offset_ptr) - { - const clang::ASTRecordLayout &record_layout = ast->getASTContext()->getASTRecordLayout(cxx_record_decl); - const clang::CXXRecordDecl *base_class_decl = llvm::cast(base_class->getType()->getAs()->getDecl()); - if (base_class->isVirtual()) - *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; - else - *bit_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8; - } - return CompilerType (ast, base_class->getType().getAsOpaquePtr()); - } - } - } - } - break; - - case clang::Type::ObjCObjectPointer: - return GetDirectBaseClassAtIndex(ast->GetPointeeType(type.GetOpaqueQualType()), idx, bit_offset_ptr); - - case clang::Type::ObjCObject: - if (idx == 0 && ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); - if (objc_class_type) - { - clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); - - if (class_interface_decl) - { - clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); - if (superclass_interface_decl) - { - if (bit_offset_ptr) - *bit_offset_ptr = 0; - return CompilerType (ast->getASTContext(), ast->getASTContext()->getObjCInterfaceType(superclass_interface_decl)); - } - } - } - } - break; - case clang::Type::ObjCInterface: - if (idx == 0 && ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::ObjCObjectType *objc_interface_type = qual_type->getAs(); - if (objc_interface_type) - { - clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); - - if (class_interface_decl) - { - clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); - if (superclass_interface_decl) - { - if (bit_offset_ptr) - *bit_offset_ptr = 0; - return CompilerType (ast->getASTContext(), ast->getASTContext()->getObjCInterfaceType(superclass_interface_decl)); - } - } - } - } - break; - - - case clang::Type::Typedef: - return GetDirectBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()), idx, bit_offset_ptr); - - case clang::Type::Elaborated: - return GetDirectBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->getNamedType().getAsOpaquePtr()), idx, bit_offset_ptr); - - case clang::Type::Paren: - return GetDirectBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->desugar().getAsOpaquePtr()), idx, bit_offset_ptr); - - default: - break; - } - return CompilerType(); -} - -CompilerType -ClangASTContext::GetVirtualBaseClassAtIndex (const CompilerType& type, size_t idx, uint32_t *bit_offset_ptr) -{ - if (!type) - return CompilerType(); - ClangASTContext *ast = type.GetTypeSystem()->AsClangASTContext(); - if (!ast) - return CompilerType(); - - clang::QualType qual_type(GetCanonicalQualType(type)); - const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (type_class) - { - case clang::Type::Record: - if (ast->GetCompleteType(type.GetOpaqueQualType())) - { - const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl) - { - uint32_t curr_idx = 0; - 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) - { - if (curr_idx == idx) - { - if (bit_offset_ptr) - { - const clang::ASTRecordLayout &record_layout = ast->getASTContext()->getASTRecordLayout(cxx_record_decl); - const clang::CXXRecordDecl *base_class_decl = llvm::cast(base_class->getType()->getAs()->getDecl()); - *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; - - } - return CompilerType (ast, base_class->getType().getAsOpaquePtr()); - } - } - } - } - break; - - case clang::Type::Typedef: - return GetVirtualBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()), idx, bit_offset_ptr); - - case clang::Type::Elaborated: - return GetVirtualBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->getNamedType().getAsOpaquePtr()), idx, bit_offset_ptr); - - case clang::Type::Paren: - return GetVirtualBaseClassAtIndex (CompilerType (ast, llvm::cast(qual_type)->desugar().getAsOpaquePtr()), idx, bit_offset_ptr); - - default: - break; - } - return CompilerType(); -} - static clang_type_t GetObjCFieldAtIndex (clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, @@ -5457,6 +5118,261 @@ ClangASTContext::GetFieldAtIndex (void* type, size_t idx, return CompilerType(); } +uint32_t +ClangASTContext::GetNumDirectBaseClasses (void *type) +{ + uint32_t count = 0; + clang::QualType qual_type(GetCanonicalQualType(type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Record: + if (GetCompleteType(type)) + { + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + count = cxx_record_decl->getNumBases(); + } + break; + + case clang::Type::ObjCObjectPointer: + count = GetPointeeType(type).GetNumDirectBaseClasses(); + break; + + case clang::Type::ObjCObject: + if (GetCompleteType(type)) + { + const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); + if (objc_class_type) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + + if (class_interface_decl && class_interface_decl->getSuperClass()) + count = 1; + } + } + break; + case clang::Type::ObjCInterface: + if (GetCompleteType(type)) + { + const clang::ObjCInterfaceType *objc_interface_type = qual_type->getAs(); + if (objc_interface_type) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); + + if (class_interface_decl && class_interface_decl->getSuperClass()) + count = 1; + } + } + break; + + + case clang::Type::Typedef: + count = GetNumDirectBaseClasses(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + break; + + case clang::Type::Elaborated: + count = GetNumDirectBaseClasses(llvm::cast(qual_type)->getNamedType().getAsOpaquePtr()); + break; + + case clang::Type::Paren: + return GetNumDirectBaseClasses(llvm::cast(qual_type)->desugar().getAsOpaquePtr()); + + default: + break; + } + return count; + +} + +uint32_t +ClangASTContext::GetNumVirtualBaseClasses (void *type) +{ + uint32_t count = 0; + clang::QualType qual_type(GetCanonicalQualType(type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Record: + if (GetCompleteType(type)) + { + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + count = cxx_record_decl->getNumVBases(); + } + break; + + case clang::Type::Typedef: + count = GetNumVirtualBaseClasses(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + break; + + case clang::Type::Elaborated: + count = GetNumVirtualBaseClasses(llvm::cast(qual_type)->getNamedType().getAsOpaquePtr()); + break; + + case clang::Type::Paren: + count = GetNumVirtualBaseClasses(llvm::cast(qual_type)->desugar().getAsOpaquePtr()); + break; + + default: + break; + } + return count; + +} + +CompilerType +ClangASTContext::GetDirectBaseClassAtIndex (void *type, size_t idx, uint32_t *bit_offset_ptr) +{ + clang::QualType qual_type(GetCanonicalQualType(type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Record: + if (GetCompleteType(type)) + { + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + { + uint32_t curr_idx = 0; + 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) + { + if (curr_idx == idx) + { + if (bit_offset_ptr) + { + const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(cxx_record_decl); + const clang::CXXRecordDecl *base_class_decl = llvm::cast(base_class->getType()->getAs()->getDecl()); + if (base_class->isVirtual()) + *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; + else + *bit_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8; + } + return CompilerType (this, base_class->getType().getAsOpaquePtr()); + } + } + } + } + break; + + case clang::Type::ObjCObjectPointer: + return GetPointeeType(type).GetDirectBaseClassAtIndex(idx, bit_offset_ptr); + + case clang::Type::ObjCObject: + if (idx == 0 && GetCompleteType(type)) + { + const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType(); + if (objc_class_type) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + + if (class_interface_decl) + { + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + if (superclass_interface_decl) + { + if (bit_offset_ptr) + *bit_offset_ptr = 0; + return CompilerType (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl)); + } + } + } + } + break; + case clang::Type::ObjCInterface: + if (idx == 0 && GetCompleteType(type)) + { + const clang::ObjCObjectType *objc_interface_type = qual_type->getAs(); + if (objc_interface_type) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface(); + + if (class_interface_decl) + { + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + if (superclass_interface_decl) + { + if (bit_offset_ptr) + *bit_offset_ptr = 0; + return CompilerType (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl)); + } + } + } + } + break; + + + case clang::Type::Typedef: + return GetDirectBaseClassAtIndex (llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), idx, bit_offset_ptr); + + case clang::Type::Elaborated: + return GetDirectBaseClassAtIndex (llvm::cast(qual_type)->getNamedType().getAsOpaquePtr(), idx, bit_offset_ptr); + + case clang::Type::Paren: + return GetDirectBaseClassAtIndex (llvm::cast(qual_type)->desugar().getAsOpaquePtr(), idx, bit_offset_ptr); + + default: + break; + } + return CompilerType(); +} + +CompilerType +ClangASTContext::GetVirtualBaseClassAtIndex (void *type, + size_t idx, + uint32_t *bit_offset_ptr) +{ + clang::QualType qual_type(GetCanonicalQualType(type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Record: + if (GetCompleteType(type)) + { + const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + { + uint32_t curr_idx = 0; + 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) + { + if (curr_idx == idx) + { + if (bit_offset_ptr) + { + const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(cxx_record_decl); + const clang::CXXRecordDecl *base_class_decl = llvm::cast(base_class->getType()->getAs()->getDecl()); + *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8; + + } + return CompilerType (this, base_class->getType().getAsOpaquePtr()); + } + } + } + } + break; + + case clang::Type::Typedef: + return GetVirtualBaseClassAtIndex (llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), idx, bit_offset_ptr); + + case clang::Type::Elaborated: + return GetVirtualBaseClassAtIndex (llvm::cast(qual_type)->getNamedType().getAsOpaquePtr(), idx, bit_offset_ptr); + + case clang::Type::Paren: + return GetVirtualBaseClassAtIndex (llvm::cast(qual_type)->desugar().getAsOpaquePtr(), idx, bit_offset_ptr); + + default: + break; + } + return CompilerType(); + +} + // If a pointer to a pointee type (the clang_type arg) says that it has no // children, then we either need to trust it, or override it and return a // different result. For example, an "int *" has one child that is an integer, @@ -5564,19 +5480,20 @@ ClangASTContext::GetNumPointeeChildren (clang::QualType type) CompilerType -ClangASTContext::GetChildClangTypeAtIndex (void* type, ExecutionContext *exe_ctx, - size_t idx, - bool transparent_pointers, - bool omit_empty_base_classes, - bool ignore_array_bounds, - std::string& child_name, - uint32_t &child_byte_size, - int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, - bool &child_is_deref_of_parent, - ValueObject *valobj) +ClangASTContext::GetChildClangTypeAtIndex (void* type, + ExecutionContext *exe_ctx, + size_t idx, + bool transparent_pointers, + bool omit_empty_base_classes, + bool ignore_array_bounds, + std::string& child_name, + uint32_t &child_byte_size, + int32_t &child_byte_offset, + uint32_t &child_bitfield_bit_size, + uint32_t &child_bitfield_bit_offset, + bool &child_is_base_class, + bool &child_is_deref_of_parent, + ValueObject *valobj) { if (!type) return CompilerType(); @@ -8973,7 +8890,7 @@ ClangASTContext::ParseTemplateDIE (SymbolFileDWARF *dwarf, const dw_offset_t type_die_offset = form_value.Reference(); lldb_type = dwarf->ResolveTypeUID(type_die_offset); if (lldb_type) - clang_type = lldb_type->GetClangForwardType(); + clang_type = lldb_type->GetForwardCompilerType (); } break; @@ -9386,6 +9303,28 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, return false; } +CompilerDeclContext +ClangASTContext::GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *cu, + const DWARFDebugInfoEntry* die) +{ + clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (dwarf, cu, die); + if (clang_decl_ctx) + return CompilerDeclContext(this, clang_decl_ctx); + return CompilerDeclContext(); +} + +CompilerDeclContext +ClangASTContext::GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, + DWARFCompileUnit *cu, + const DWARFDebugInfoEntry* die) +{ + clang::DeclContext *clang_decl_ctx = GetClangDeclContextContainingDIE (dwarf, cu, die, nullptr); + if (clang_decl_ctx) + return CompilerDeclContext(this, clang_decl_ctx); + return CompilerDeclContext(); +} + void ClangASTContext::CompleteTagDecl (void *baton, clang::TagDecl *decl) { @@ -10015,7 +9954,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, accessibility = eAccessPublic; ClangASTContext::AddVariableToRecordType (class_clang_type, name, - var_type->GetClangLayoutType(), + var_type->GetLayoutCompilerType (), accessibility); } break; @@ -10149,7 +10088,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, last_field_info.Clear(); } - CompilerType member_clang_type = member_type->GetClangLayoutType(); + CompilerType member_clang_type = member_type->GetLayoutCompilerType (); { // Older versions of clang emit array[0] and array[1] in the same way (). @@ -10221,7 +10160,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, metadata.SetUserID (dwarf->MakeUserID(die->GetOffset())); delayed_properties.push_back(DelayedAddObjCClassProperty(class_clang_type, prop_name, - member_type->GetClangLayoutType(), + member_type->GetLayoutCompilerType (), ivar_decl, prop_setter_name, prop_getter_name, @@ -10335,7 +10274,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, break; } - CompilerType base_class_clang_type = base_class_type->GetClangFullType(); + CompilerType base_class_clang_type = base_class_type->GetFullCompilerType (); assert (base_class_clang_type); if (class_language == eLanguageTypeObjC) { @@ -10520,10 +10459,10 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, Type *type = dwarf->ResolveTypeUID(param_type_die_offset); if (type) { - function_param_types.push_back (type->GetClangForwardType()); + function_param_types.push_back (type->GetForwardCompilerType ()); clang::ParmVarDecl *param_var_decl = CreateParameterDeclaration (name, - type->GetClangForwardType(), + type->GetForwardCompilerType (), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); @@ -10650,91 +10589,198 @@ ClangASTContext::ParseChildArrayInfo (const SymbolContext& sc, } } -clang::DeclContext* -ClangASTContext::GetClangDeclContextContainingTypeUID (SymbolFileDWARF *dwarf, lldb::user_id_t type_uid) +//clang::DeclContext* +//ClangASTContext::GetClangDeclContextContainingTypeUID (SymbolFileDWARF *dwarf, lldb::user_id_t type_uid) +//{ +// DWARFDebugInfo* debug_info = dwarf->DebugInfo(); +// if (debug_info && dwarf->UserIDMatches(type_uid)) +// { +// DWARFCompileUnitSP cu_sp; +// const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); +// if (die) +// return GetClangDeclContextContainingDIE (dwarf, cu_sp.get(), die, NULL); +// } +// return NULL; +//} +// +//---------------------------------------------------------------------- +// CompilerDeclContext functions +//---------------------------------------------------------------------- + +bool +ClangASTContext::DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) { - DWARFDebugInfo* debug_info = dwarf->DebugInfo(); - if (debug_info && dwarf->UserIDMatches(type_uid)) - { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); - if (die) - return GetClangDeclContextContainingDIE (dwarf, cu_sp.get(), die, NULL); - } - return NULL; + if (opaque_decl_ctx) + return ((clang::DeclContext *)opaque_decl_ctx)->isRecord(); + else + return false; } -clang::DeclContext* -ClangASTContext::GetClangDeclContextForTypeUID (SymbolFileDWARF *dwarf, const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) +ConstString +ClangASTContext::DeclContextGetName (void *opaque_decl_ctx) { - if (dwarf->UserIDMatches(type_uid)) - return GetClangDeclContextForDIEOffset (dwarf, sc, type_uid); - return NULL; + if (opaque_decl_ctx) + { + clang::NamedDecl *named_decl = llvm::dyn_cast((clang::DeclContext *)opaque_decl_ctx); + if (named_decl) + return ConstString(named_decl->getName()); + } + return ConstString(); +} + +bool +ClangASTContext::DeclContextIsClassMethod (void *opaque_decl_ctx, + lldb::LanguageType *language_ptr, + bool *is_instance_method_ptr, + ConstString *language_object_name_ptr) +{ + if (opaque_decl_ctx) + { + clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx; + if (ObjCMethodDecl *objc_method = llvm::dyn_cast(decl_ctx)) + { + if (is_instance_method_ptr) + *is_instance_method_ptr = objc_method->isInstanceMethod(); + if (language_ptr) + *language_ptr = eLanguageTypeObjC; + if (language_object_name_ptr) + language_object_name_ptr->SetCString("self"); + return true; + } + else if (CXXMethodDecl *cxx_method = llvm::dyn_cast(decl_ctx)) + { + if (is_instance_method_ptr) + *is_instance_method_ptr = cxx_method->isInstance(); + if (language_ptr) + *language_ptr = eLanguageTypeC_plus_plus; + if (language_object_name_ptr) + language_object_name_ptr->SetCString("this"); + return true; + } + else if (clang::FunctionDecl *function_decl = llvm::dyn_cast(decl_ctx)) + { + ClangASTMetadata *metadata = GetMetadata (&decl_ctx->getParentASTContext(), function_decl); + if (metadata && metadata->HasObjectPtr()) + { + if (is_instance_method_ptr) + *is_instance_method_ptr = true; + if (language_ptr) + *language_ptr = eLanguageTypeObjC; + if (language_object_name_ptr) + language_object_name_ptr->SetCString (metadata->GetObjectPtrName()); + return true; + } + } + } + return false; +} + +clang::DeclContext * +ClangASTContext::DeclContextGetAsDeclContext (const CompilerDeclContext &dc) +{ + if (dc.IsClang()) + return (clang::DeclContext *)dc.GetOpaqueDeclContext(); + return nullptr; +} + + +ObjCMethodDecl * +ClangASTContext::DeclContextGetAsObjCMethodDecl (const CompilerDeclContext &dc) +{ + if (dc.IsClang()) + return llvm::dyn_cast((clang::DeclContext *)dc.GetOpaqueDeclContext()); + return nullptr; +} + +CXXMethodDecl * +ClangASTContext::DeclContextGetAsCXXMethodDecl (const CompilerDeclContext &dc) +{ + if (dc.IsClang()) + return llvm::dyn_cast((clang::DeclContext *)dc.GetOpaqueDeclContext()); + return nullptr; +} + +clang::FunctionDecl * +ClangASTContext::DeclContextGetAsFunctionDecl (const CompilerDeclContext &dc) +{ + if (dc.IsClang()) + return llvm::dyn_cast((clang::DeclContext *)dc.GetOpaqueDeclContext()); + return nullptr; +} + +clang::NamespaceDecl * +ClangASTContext::DeclContextGetAsNamespaceDecl (const CompilerDeclContext &dc) +{ + if (dc.IsClang()) + return llvm::dyn_cast((clang::DeclContext *)dc.GetOpaqueDeclContext()); + return nullptr; +} + +ClangASTMetadata * +ClangASTContext::DeclContextGetMetaData (const CompilerDeclContext &dc, const void *object) +{ + clang::ASTContext *ast = DeclContextGetClangASTContext (dc); + if (ast) + return ClangASTContext::GetMetadata (ast, object); + return nullptr; +} + +clang::ASTContext * +ClangASTContext::DeclContextGetClangASTContext (const CompilerDeclContext &dc) +{ + TypeSystem *type_system = dc.GetTypeSystem(); + if (type_system) + { + ClangASTContext *ast = type_system->AsClangASTContext(); + if (ast) + return ast->getASTContext(); + } + return nullptr; } clang::DeclContext * ClangASTContext::GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, - const SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) { - clang::DeclContext *clang_decl_ctx = GetCachedClangDeclContextForDIE (die); - if (clang_decl_ctx) - return clang_decl_ctx; - // If this DIE has a specification, or an abstract origin, then trace to those. - - dw_offset_t die_offset = die->GetAttributeValueAsReference(dwarf, cu, DW_AT_specification, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) - return GetClangDeclContextForDIEOffset (dwarf, sc, die_offset); - - die_offset = die->GetAttributeValueAsReference(dwarf, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) - return GetClangDeclContextForDIEOffset (dwarf, sc, die_offset); - - Log *log = nullptr; //(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); - if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage(log, "SymbolFileDWARF::GetClangDeclContextForDIE (die = 0x%8.8x) %s '%s'", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), die->GetName(dwarf, cu)); - // This is the DIE we want. Parse it, then query our map. - bool assert_not_being_parsed = true; - dwarf->ResolveTypeUID (cu, die, assert_not_being_parsed); - - clang_decl_ctx = GetCachedClangDeclContextForDIE (die); - - return clang_decl_ctx; -} - - -clang::DeclContext * -ClangASTContext::GetClangDeclContextContainingDIEOffset (SymbolFileDWARF *dwarf, - dw_offset_t die_offset) -{ - if (die_offset != DW_INVALID_OFFSET) + if (die) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = dwarf->DebugInfo()->GetDIEPtr(die_offset, &cu_sp); - return GetClangDeclContextContainingDIE (dwarf, cu_sp.get(), die, NULL); - } - return NULL; -} + clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die); + if (decl_ctx) + return decl_ctx; -clang::DeclContext * -ClangASTContext::GetClangDeclContextForDIEOffset (SymbolFileDWARF *dwarf, - const SymbolContext &sc, - dw_offset_t die_offset) -{ - if (die_offset != DW_INVALID_OFFSET) - { - DWARFDebugInfo* debug_info = dwarf->DebugInfo(); - if (debug_info) + bool try_parsing_type = true; + switch (die->Tag()) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(die_offset, &cu_sp); - if (die) - return GetClangDeclContextForDIE (dwarf, sc, cu_sp.get(), die); + case DW_TAG_compile_unit: + decl_ctx = m_clang_tu_decl; + try_parsing_type = false; + break; + + case DW_TAG_namespace: + decl_ctx = ResolveNamespaceDIE (dwarf, cu, die); + try_parsing_type = false; + break; + + default: + break; + } + + if (decl_ctx == nullptr && try_parsing_type) + { + Type* type = dwarf->ResolveType (cu, die); + if (type) + decl_ctx = GetCachedClangDeclContextForDIE (die); + } + + if (decl_ctx) + { + LinkDeclContextToDIE (decl_ctx, die); + return decl_ctx; } } - return NULL; + return nullptr; } clang::NamespaceDecl * @@ -10783,7 +10829,7 @@ ClangASTContext::ResolveNamespaceDIE (SymbolFileDWARF *dwarf, return namespace_decl; } } - return NULL; + return nullptr; } clang::DeclContext * @@ -10802,40 +10848,9 @@ ClangASTContext::GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf, if (decl_ctx_die) { - - DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find (decl_ctx_die); - if (pos != m_die_to_decl_ctx.end()) - return pos->second; - - switch (decl_ctx_die->Tag()) - { - case DW_TAG_compile_unit: - return m_clang_tu_decl; - - case DW_TAG_namespace: - return ResolveNamespaceDIE (dwarf, cu, decl_ctx_die); - - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: - { - Type* type = dwarf->ResolveType (cu, decl_ctx_die); - if (type) - { - clang::DeclContext *decl_ctx = GetDeclContextForType(type->GetClangForwardType()); - if (decl_ctx) - { - LinkDeclContextToDIE (decl_ctx, decl_ctx_die); - if (decl_ctx) - return decl_ctx; - } - } - } - break; - - default: - break; - } + clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (dwarf, cu, decl_ctx_die); + if (clang_decl_ctx) + return clang_decl_ctx; } return m_clang_tu_decl; } @@ -11356,7 +11371,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } assert (tag_decl_kind != -1); bool clang_type_was_created = false; - clang_type.SetClangType(this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); + clang_type.SetCompilerType(this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); if (!clang_type) { const DWARFDebugInfoEntry *decl_ctx_die; @@ -11567,14 +11582,14 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); CompilerType enumerator_clang_type; - clang_type.SetClangType (this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); + clang_type.SetCompilerType (this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); if (!clang_type) { if (encoding_uid != DW_INVALID_OFFSET) { Type *enumerator_type = dwarf->ResolveTypeUID(encoding_uid); if (enumerator_type) - enumerator_clang_type = enumerator_type->GetClangFullType(); + enumerator_clang_type = enumerator_type->GetFullCompilerType (); } if (!enumerator_clang_type) @@ -11742,7 +11757,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, func_type = dwarf->ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetClangForwardType(); + return_clang_type = func_type->GetForwardCompilerType (); else return_clang_type = GetBasicType(eBasicTypeVoid); @@ -11790,7 +11805,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (type_name_cstr) { bool type_handled = false; - if (tag == DW_TAG_subprogram) + if (tag == DW_TAG_subprogram || + tag == DW_TAG_inlined_subroutine) { ObjCLanguageRuntime::MethodName objc_method (type_name_cstr, true); if (objc_method.IsValid(true)) @@ -11803,7 +11819,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (complete_objc_class_type_sp) { - CompilerType type_clang_forward_type = complete_objc_class_type_sp->GetClangForwardType(); + CompilerType type_clang_forward_type = complete_objc_class_type_sp->GetForwardCompilerType (); if (ClangASTContext::IsObjCObjectOrInterfaceType(type_clang_forward_type)) class_opaque_type = type_clang_forward_type; } @@ -11897,12 +11913,12 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // prototype off of, so we need this type to be completed so that the // m_die_to_decl_ctx for the method in the specification has a valid // clang decl context. - class_type->GetClangForwardType(); + class_type->GetForwardCompilerType (); // If we have a specification, then the function type should have been // made with the specification and not with this die. DWARFCompileUnitSP spec_cu_sp; const DWARFDebugInfoEntry* spec_die = dwarf->DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp); - clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, sc, dwarf_cu, spec_die); + clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, dwarf_cu, spec_die); if (spec_clang_decl_ctx) { LinkDeclContextToDIE(spec_clang_decl_ctx, die); @@ -11921,11 +11937,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // prototype off of, so we need this type to be completed so that the // m_die_to_decl_ctx for the method in the abstract origin has a valid // clang decl context. - class_type->GetClangForwardType(); + class_type->GetForwardCompilerType (); DWARFCompileUnitSP abs_cu_sp; const DWARFDebugInfoEntry* abs_die = dwarf->DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); - clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, sc, dwarf_cu, abs_die); + clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, dwarf_cu, abs_die); if (abs_clang_decl_ctx) { LinkDeclContextToDIE (abs_clang_decl_ctx, die); @@ -11940,7 +11956,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } else { - CompilerType class_opaque_type = class_type->GetClangForwardType(); + CompilerType class_opaque_type = class_type->GetForwardCompilerType (); if (ClangASTContext::IsCXXClassType(class_opaque_type)) { if (class_opaque_type.IsBeingDefined ()) @@ -12022,7 +12038,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // Now we get the full type to force our class type to complete itself // using the clang::ExternalASTSource protocol which will parse all // base classes and all methods (including the method for this DIE). - class_type->GetClangFullType(); + class_type->GetFullCompilerType (); // The type for this DIE should have been filled in the function call above type_ptr = dwarf->m_die_to_type[die]; @@ -12161,7 +12177,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, ParseChildArrayInfo(sc, dwarf, dwarf_cu, die, first_index, element_orders, byte_stride, bit_stride); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); - CompilerType array_element_type = element_type->GetClangForwardType(); + CompilerType array_element_type = element_type->GetForwardCompilerType (); uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; if (element_orders.size() > 0) { @@ -12228,8 +12244,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, Type *pointee_type = dwarf->ResolveTypeUID(type_die_offset); Type *class_type = dwarf->ResolveTypeUID(containing_type_die_offset); - CompilerType pointee_clang_type = pointee_type->GetClangForwardType(); - CompilerType class_clang_type = class_type->GetClangLayoutType(); + CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType (); + CompilerType class_clang_type = class_type->GetLayoutCompilerType (); clang_type = ClangASTContext::CreateMemberPointerType(pointee_clang_type, class_clang_type); @@ -12312,7 +12328,7 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, // We need to complete the class type so we can get all of the method types // parsed so we can then unique those types to their equivalent counterparts // in "dst_cu" and "dst_class_die" - class_type->GetClangFullType(); + class_type->GetFullCompilerType (); const DWARFDebugInfoEntry *src_die; const DWARFDebugInfoEntry *dst_die; @@ -12601,53 +12617,3 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, return (failures.Size() != 0); } - -bool -ClangASTContext::DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl, - SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die) -{ - // No namespace specified, so the answer is - if (namespace_decl == NULL) - return true; - - Log *log = nullptr; //(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); - - const DWARFDebugInfoEntry *decl_ctx_die = NULL; - clang::DeclContext *die_clang_decl_ctx = GetClangDeclContextContainingDIE (dwarf, cu, die, &decl_ctx_die); - if (decl_ctx_die) - { - clang::NamespaceDecl *clang_namespace_decl = namespace_decl->GetNamespaceDecl(); - - if (clang_namespace_decl) - { - if (decl_ctx_die->Tag() != DW_TAG_namespace) - { - if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage(log, "Found a match, but its parent is not a namespace"); - return false; - } - - if (clang_namespace_decl == die_clang_decl_ctx) - return true; - else - return false; - } - else - { - // We have a namespace_decl that was not NULL but it contained - // a NULL "clang::NamespaceDecl", so this means the global namespace - // So as long the contained decl context DIE isn't a namespace - // we should be ok. - if (decl_ctx_die->Tag() != DW_TAG_namespace) - return true; - } - } - - if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage(log, "Found a match, but its parent doesn't exist"); - - return false; -} - diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index 038f26cf91a6..3db4c11e0b4a 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -16,7 +16,6 @@ #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Utility/LLDBAssert.h" using namespace lldb_private; diff --git a/lldb/source/Symbol/ClangNamespaceDecl.cpp b/lldb/source/Symbol/ClangNamespaceDecl.cpp deleted file mode 100644 index 568b0263f0fe..000000000000 --- a/lldb/source/Symbol/ClangNamespaceDecl.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===-- ClangNamespaceDecl.cpp ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Symbol/ClangNamespaceDecl.h" - -#include "clang/AST/Decl.h" - -namespace lldb_private { - -std::string -ClangNamespaceDecl::GetQualifiedName () const -{ - if (m_namespace_decl) - return m_namespace_decl->getQualifiedNameAsString(); - return std::string(); -} - - -} diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp b/lldb/source/Symbol/CompilerDeclContext.cpp new file mode 100644 index 000000000000..948ee74c6530 --- /dev/null +++ b/lldb/source/Symbol/CompilerDeclContext.cpp @@ -0,0 +1,64 @@ +//===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Symbol/CompilerDeclContext.h" +#include "lldb/Symbol/TypeSystem.h" + +using namespace lldb_private; + +bool +CompilerDeclContext::IsClang () const +{ + return IsValid() && m_type_system->AsClangASTContext() != nullptr; +} + +ConstString +CompilerDeclContext::GetName () const +{ + if (IsValid()) + return m_type_system->DeclContextGetName(m_opaque_decl_ctx); + else + return ConstString(); +} + +bool +CompilerDeclContext::IsStructUnionOrClass () const +{ + if (IsValid()) + return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx); + else + return false; +} + +bool +CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr, + bool *is_instance_method_ptr, + ConstString *language_object_name_ptr) +{ + if (IsValid()) + return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx, + language_ptr, + is_instance_method_ptr, + language_object_name_ptr); + else + return false; +} + +bool +lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) +{ + return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); +} + + +bool +lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) +{ + return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); +} diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 89d3ddb5b820..fba5fc823732 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -397,14 +397,14 @@ CompilerType::GetTypeClass () const } void -CompilerType::SetClangType (TypeSystem* type_system, void* type) +CompilerType::SetCompilerType (TypeSystem* type_system, void* type) { m_type_system = type_system; m_type = type; } void -CompilerType::SetClangType (clang::ASTContext *ast, clang::QualType qual_type) +CompilerType::SetCompilerType (clang::ASTContext *ast, clang::QualType qual_type) { m_type_system = ClangASTContext::GetASTContext(ast); m_type = qual_type.getAsOpaquePtr(); @@ -536,15 +536,6 @@ CompilerType::GetTypedefedType () const return CompilerType(); } -//CompilerType -//CompilerType::RemoveFastQualifiers () const -//{ -// if (IsValid()) -// return m_type_system->RemoveFastQualifiers(m_type); -// return CompilerType(); -//} - - //---------------------------------------------------------------------- // Create related types using the current type's AST //---------------------------------------------------------------------- @@ -553,7 +544,7 @@ CompilerType CompilerType::GetBasicTypeFromAST (lldb::BasicType basic_type) const { if (IsValid()) - return m_type_system->GetBasicTypeFromAST(m_type, basic_type); + return m_type_system->GetBasicTypeFromAST(basic_type); return CompilerType(); } //---------------------------------------------------------------------- @@ -620,6 +611,12 @@ CompilerType::GetBasicTypeEnumeration () const return eBasicTypeInvalid; } +void +CompilerType::ForEachEnumerator (std::function const &callback) const +{ + if (IsValid()) + return m_type_system->ForEachEnumerator (m_type, callback); +} uint32_t @@ -642,6 +639,38 @@ CompilerType::GetFieldAtIndex (size_t idx, return m_type_system->GetFieldAtIndex(m_type, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr); } +uint32_t +CompilerType::GetNumDirectBaseClasses () const +{ + if (IsValid()) + return m_type_system->GetNumDirectBaseClasses (m_type); + return 0; +} + +uint32_t +CompilerType::GetNumVirtualBaseClasses () const +{ + if (IsValid()) + return m_type_system->GetNumVirtualBaseClasses (m_type); + return 0; +} + +CompilerType +CompilerType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const +{ + if (IsValid()) + return m_type_system->GetDirectBaseClassAtIndex (m_type, idx, bit_offset_ptr); + return CompilerType(); +} + +CompilerType +CompilerType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const +{ + if (IsValid()) + return m_type_system->GetVirtualBaseClassAtIndex (m_type, idx, bit_offset_ptr); + return CompilerType(); +} + uint32_t CompilerType::GetIndexOfFieldWithName (const char* name, CompilerType* field_clang_type_ptr, diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 4224cdad4bb9..a70f083671b2 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -489,27 +489,24 @@ Function::GetDisplayName () const return m_mangled.GetDisplayDemangledName(GetLanguage()); } -clang::DeclContext * -Function::GetClangDeclContext() +CompilerDeclContext +Function::GetDeclContext() { - SymbolContext sc; - - CalculateSymbolContext (&sc); - - if (!sc.module_sp) - return nullptr; - - SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); - - if (!sym_vendor) - return nullptr; - - SymbolFile *sym_file = sym_vendor->GetSymbolFile(); - - if (!sym_file) - return nullptr; - - return sym_file->GetClangDeclContextForTypeUID (sc, m_uid); + ModuleSP module_sp = CalculateSymbolContextModule (); + + if (module_sp) + { + SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); + + if (sym_vendor) + { + SymbolFile *sym_file = sym_vendor->GetSymbolFile(); + + if (sym_file) + return sym_file->GetDeclContextForUID (GetID()); + } + } + return CompilerDeclContext(); } Type* @@ -546,11 +543,11 @@ Function::GetType() const } CompilerType -Function::GetClangType() +Function::GetCompilerType() { Type *function_type = GetType(); if (function_type) - return function_type->GetClangFullType(); + return function_type->GetFullCompilerType (); return CompilerType(); } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 19b460c313fe..d66cc700d4cb 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -649,22 +649,13 @@ SymbolContext::GetFunctionMethodInfo (lldb::LanguageType &language, { - Block *function_block = GetFunctionBlock (); + Block *function_block = GetFunctionBlock(); if (function_block) { - clang::DeclContext *decl_context = function_block->GetClangDeclContext(); - - if (decl_context) - { - return ClangASTContext::GetClassMethodInfoForDeclContext (decl_context, - language, - is_instance_method, - language_object_name); - } + CompilerDeclContext decl_ctx = function_block->GetDeclContext(); + if (decl_ctx) + return decl_ctx.IsClassMethod(&language, &is_instance_method, &language_object_name); } - language = eLanguageTypeUnknown; - is_instance_method = false; - language_object_name.Clear(); return false; } diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 14871e766647..357cfbcd131c 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -15,6 +15,8 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamString.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/TypeList.h" +#include "lldb/Symbol/VariableList.h" using namespace lldb_private; @@ -94,3 +96,52 @@ SymbolFile::GetTypeSystemForLanguage (lldb::LanguageType language) return m_obj_file->GetModule()->GetTypeSystemForLanguage (language); } +uint32_t +SymbolFile::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) +{ + sc_list.Clear(); + return 0; +} + + +uint32_t +SymbolFile::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables) +{ + if (!append) + variables.Clear(); + return 0; +} + + +uint32_t +SymbolFile::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) +{ + if (!append) + variables.Clear(); + return 0; +} + +uint32_t +SymbolFile::FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) +{ + if (!append) + sc_list.Clear(); + return 0; +} + +uint32_t +SymbolFile::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) +{ + if (!append) + sc_list.Clear(); + return 0; +} + +uint32_t +SymbolFile::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeList& types) +{ + if (!append) + types.Clear(); + return 0; +} + diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index 752edd1af71b..f0b03cf54013 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -293,14 +293,14 @@ SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bo } size_t -SymbolVendor::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, VariableList& variables) +SymbolVendor::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables) { ModuleSP module_sp(GetModule()); if (module_sp) { lldb_private::Mutex::Locker locker(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables); + return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables); } return 0; } @@ -319,14 +319,14 @@ SymbolVendor::FindGlobalVariables (const RegularExpression& regex, bool append, } size_t -SymbolVendor::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) +SymbolVendor::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) { ModuleSP module_sp(GetModule()); if (module_sp) { lldb_private::Mutex::Locker locker(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list); + return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list); } return 0; } @@ -346,14 +346,14 @@ SymbolVendor::FindFunctions(const RegularExpression& regex, bool include_inlines size_t -SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, TypeList& types) +SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeList& types) { ModuleSP module_sp(GetModule()); if (module_sp) { lldb_private::Mutex::Locker locker(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types); + return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types); } if (!append) types.Clear(); @@ -375,18 +375,18 @@ SymbolVendor::GetTypes (SymbolContextScope *sc_scope, return 0; } -ClangNamespaceDecl -SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl) +CompilerDeclContext +SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx) { - ClangNamespaceDecl namespace_decl; + CompilerDeclContext namespace_decl_ctx; ModuleSP module_sp(GetModule()); if (module_sp) { lldb_private::Mutex::Locker locker(module_sp->GetMutex()); if (m_sym_file_ap.get()) - namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl); + namespace_decl_ctx = m_sym_file_ap->FindNamespace (sc, name, parent_decl_ctx); } - return namespace_decl; + return namespace_decl_ctx; } void diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 3cd04bf0e5b9..6cd4cf3d34f1 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -178,7 +178,7 @@ Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name) if (m_clang_type.IsValid()) { *s << ", clang_type = \""; - GetClangForwardType().DumpTypeDescription(s); + GetForwardCompilerType ().DumpTypeDescription(s); *s << '"'; } else if (m_encoding_uid != LLDB_INVALID_UID) @@ -226,7 +226,7 @@ Type::Dump (Stream *s, bool show_context) if (m_clang_type.IsValid()) { *s << ", clang_type = " << m_clang_type.GetOpaqueQualType() << ' '; - GetClangForwardType().DumpTypeDescription (s); + GetForwardCompilerType ().DumpTypeDescription (s); } else if (m_encoding_uid != LLDB_INVALID_UID) { @@ -256,7 +256,7 @@ const ConstString & Type::GetName() { if (!m_name) - m_name = GetClangForwardType().GetConstTypeName(); + m_name = GetForwardCompilerType ().GetConstTypeName(); return m_name; } @@ -291,7 +291,7 @@ Type::DumpValue s->PutCString(") "); } - GetClangForwardType().DumpValue (exe_ctx, + GetForwardCompilerType ().DumpValue (exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data, @@ -336,7 +336,7 @@ Type::GetByteSize() if (encoding_type) m_byte_size = encoding_type->GetByteSize(); if (m_byte_size == 0) - m_byte_size = GetClangLayoutType().GetByteSize(nullptr); + m_byte_size = GetLayoutCompilerType ().GetByteSize(nullptr); } break; @@ -355,13 +355,13 @@ Type::GetByteSize() uint32_t Type::GetNumChildren (bool omit_empty_base_classes) { - return GetClangForwardType().GetNumChildren(omit_empty_base_classes); + return GetForwardCompilerType ().GetNumChildren(omit_empty_base_classes); } bool Type::IsAggregateType () { - return GetClangForwardType().IsAggregateType(); + return GetForwardCompilerType ().IsAggregateType(); } lldb::TypeSP @@ -382,7 +382,7 @@ Type::GetTypedefType() lldb::Format Type::GetFormat () { - return GetClangForwardType().GetFormat(); + return GetForwardCompilerType ().GetFormat(); } @@ -391,7 +391,7 @@ lldb::Encoding Type::GetEncoding (uint64_t &count) { // Make sure we resolve our type if it already hasn't been. - return GetClangForwardType().GetEncoding(count); + return GetForwardCompilerType ().GetEncoding(count); } bool @@ -502,7 +502,7 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state) { case eEncodingIsUID: { - CompilerType encoding_clang_type = encoding_type->GetClangForwardType(); + CompilerType encoding_clang_type = encoding_type->GetForwardCompilerType (); if (encoding_clang_type.IsValid()) { m_clang_type = encoding_clang_type; @@ -512,34 +512,34 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state) break; case eEncodingIsConstUID: - m_clang_type = ClangASTContext::AddConstModifier(encoding_type->GetClangForwardType()); + m_clang_type = ClangASTContext::AddConstModifier(encoding_type->GetForwardCompilerType ()); break; case eEncodingIsRestrictUID: - m_clang_type = ClangASTContext::AddRestrictModifier(encoding_type->GetClangForwardType()); + m_clang_type = ClangASTContext::AddRestrictModifier(encoding_type->GetForwardCompilerType ()); break; case eEncodingIsVolatileUID: - m_clang_type = ClangASTContext::AddVolatileModifier(encoding_type->GetClangForwardType()); + m_clang_type = ClangASTContext::AddVolatileModifier(encoding_type->GetForwardCompilerType ()); break; case eEncodingIsTypedefUID: - m_clang_type = ClangASTContext::CreateTypedefType (encoding_type->GetClangForwardType(), + m_clang_type = ClangASTContext::CreateTypedefType (encoding_type->GetForwardCompilerType (), GetName().AsCString(), - GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID())); + GetSymbolFile()->GetDeclContextContainingUID(GetID())); m_name.Clear(); break; case eEncodingIsPointerUID: - m_clang_type = encoding_type->GetClangForwardType().GetPointerType(); + m_clang_type = encoding_type->GetForwardCompilerType ().GetPointerType(); break; case eEncodingIsLValueReferenceUID: - m_clang_type = ClangASTContext::GetLValueReferenceType(encoding_type->GetClangForwardType()); + m_clang_type = ClangASTContext::GetLValueReferenceType(encoding_type->GetForwardCompilerType ()); break; case eEncodingIsRValueReferenceUID: - m_clang_type = ClangASTContext::GetRValueReferenceType(encoding_type->GetClangForwardType()); + m_clang_type = ClangASTContext::GetRValueReferenceType(encoding_type->GetForwardCompilerType ()); break; default: @@ -572,7 +572,7 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state) case eEncodingIsTypedefUID: m_clang_type = ClangASTContext::CreateTypedefType (void_clang_type, GetName().AsCString(), - GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID())); + GetSymbolFile()->GetDeclContextContainingUID(GetID())); break; case eEncodingIsPointerUID: @@ -656,21 +656,21 @@ Type::GetEncodingMask () } CompilerType -Type::GetClangFullType () +Type::GetFullCompilerType () { ResolveClangType(eResolveStateFull); return m_clang_type; } CompilerType -Type::GetClangLayoutType () +Type::GetLayoutCompilerType () { ResolveClangType(eResolveStateLayout); return m_clang_type; } CompilerType -Type::GetClangForwardType () +Type::GetForwardCompilerType () { ResolveClangType (eResolveStateForward); return m_clang_type; @@ -693,64 +693,14 @@ Type::Compare(const Type &a, const Type &b) if (a_uid > b_uid) return 1; return 0; -// if (a.getQualType() == b.getQualType()) -// return 0; -} - - -#if 0 // START REMOVE -// Move this into CompilerType -void * -Type::CreateClangPointerType (Type *type) -{ - assert(type); - return GetClangASTContext().CreatePointerType(type->GetClangForwardType()); -} - -void * -Type::CreateClangTypedefType (Type *typedef_type, Type *base_type) -{ - assert(typedef_type && base_type); - return GetClangASTContext().CreateTypedefType (typedef_type->GetName().AsCString(), - base_type->GetClangForwardType(), - typedef_type->GetSymbolFile()->GetClangDeclContextContainingTypeUID(typedef_type->GetID())); -} - -void * -Type::CreateClangLValueReferenceType (Type *type) -{ - assert(type); - return GetClangASTContext().CreateLValueReferenceType(type->GetClangForwardType()); -} - -void * -Type::CreateClangRValueReferenceType (Type *type) -{ - assert(type); - return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType()); -} -#endif // END REMOVE - -bool -Type::IsRealObjCClass() -{ - // For now we are just skipping ObjC classes that get made by hand from the runtime, because - // those don't have any information. We could extend this to only return true for "full - // definitions" if we can figure that out. - - if (ClangASTContext::IsObjCObjectOrInterfaceType(m_clang_type) && GetByteSize() != 0) - return true; - else - return false; } ConstString Type::GetQualifiedName () { - return GetClangForwardType().GetConstTypeName(); + return GetForwardCompilerType ().GetConstTypeName(); } - bool Type::GetTypeScopeAndBasename (const char* &name_cstr, std::string &scope, @@ -1417,19 +1367,13 @@ TypeMemberFunctionImpl::GetArgumentAtIndex (size_t idx) const return CompilerType(); } -TypeEnumMemberImpl::TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl, - const lldb_private::CompilerType& integer_type) : - m_integer_type_sp(), - m_name(), - m_value(), - m_valid(false) +TypeEnumMemberImpl::TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp, + const ConstString &name, + const llvm::APSInt &value) : + m_integer_type_sp(integer_type_sp), + m_name(name), + m_value(value), + m_valid((bool)name && (bool)integer_type_sp) { - 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/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp index 05ef73a74755..ba34c470ad3c 100644 --- a/lldb/source/Symbol/TypeList.cpp +++ b/lldb/source/Symbol/TypeList.cpp @@ -216,7 +216,7 @@ TypeList::RemoveMismatchedTypes (const std::string &type_scope, if (type_class != eTypeClassAny) { - match_type_class = the_type->GetClangForwardType().GetTypeClass (); + match_type_class = the_type->GetForwardCompilerType ().GetTypeClass (); if ((match_type_class & type_class) == 0) continue; } @@ -305,7 +305,7 @@ TypeList::RemoveMismatchedTypes (TypeClass type_class) for (pos = m_types.begin(); pos != end; ++pos) { Type* the_type = pos->second.get(); - TypeClass match_type_class = the_type->GetClangForwardType().GetTypeClass (); + TypeClass match_type_class = the_type->GetForwardCompilerType ().GetTypeClass (); if (match_type_class & type_class) matching_types.insert (*pos); } diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 88a6cd54b1b2..3cc4054c3f61 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -584,13 +584,13 @@ PrivateAutoCompleteMembers (StackFrame *frame, { // We are in a type parsing child members - const uint32_t num_bases = ClangASTContext::GetNumDirectBaseClasses(clang_type); + const uint32_t num_bases = clang_type.GetNumDirectBaseClasses(); if (num_bases > 0) { for (uint32_t i = 0; i < num_bases; ++i) { - CompilerType base_class_type (ClangASTContext::GetDirectBaseClassAtIndex(clang_type, i, nullptr)); + CompilerType base_class_type = clang_type.GetDirectBaseClassAtIndex(i, nullptr); PrivateAutoCompleteMembers (frame, partial_member_name, @@ -602,13 +602,13 @@ PrivateAutoCompleteMembers (StackFrame *frame, } } - const uint32_t num_vbases = ClangASTContext::GetNumVirtualBaseClasses(clang_type); + const uint32_t num_vbases = clang_type.GetNumVirtualBaseClasses(); if (num_vbases > 0) { for (uint32_t i = 0; i < num_vbases; ++i) { - CompilerType vbase_class_type (ClangASTContext::GetVirtualBaseClassAtIndex(clang_type, i,nullptr)); + CompilerType vbase_class_type = clang_type.GetVirtualBaseClassAtIndex(i,nullptr); PrivateAutoCompleteMembers (frame, partial_member_name, @@ -888,7 +888,7 @@ PrivateAutoComplete (StackFrame *frame, Type *variable_type = variable->GetType(); if (variable_type) { - CompilerType variable_clang_type (variable_type->GetClangForwardType()); + CompilerType variable_clang_type (variable_type->GetForwardCompilerType ()); PrivateAutoComplete (frame, remaining_partial_path, prefix_path + token, // Anything that has been resolved already will be in here diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index df986f6de56b..464efef436ee 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -136,7 +136,7 @@ ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name) { TypeSP type_sp (types.GetTypeAtIndex(i)); - if (ClangASTContext::IsObjCObjectOrInterfaceType(type_sp->GetClangForwardType())) + if (ClangASTContext::IsObjCObjectOrInterfaceType(type_sp->GetForwardCompilerType ())) { if (type_sp->IsCompleteObjCClass()) { @@ -549,7 +549,7 @@ ObjCLanguageRuntime::GetClassDescriptor (ValueObject& valobj) // if we get an invalid VO (which might still happen when playing around // with pointers returned by the expression parser, don't consider this // a valid ObjC object) - if (valobj.GetClangType().IsValid()) + if (valobj.GetCompilerType().IsValid()) { addr_t isa_pointer = valobj.GetPointerValue(); if (isa_pointer != LLDB_INVALID_ADDRESS) diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 3e6703531e7b..e7baad19ffd4 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -713,7 +713,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, { // Make sure we aren't trying to deref an objective // C ivar if this is not allowed - const uint32_t pointer_type_flags = valobj_sp->GetClangType().GetTypeInfo (NULL); + const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo (NULL); if ((pointer_type_flags & eTypeIsObjC) && (pointer_type_flags & eTypeIsPointer)) { @@ -827,7 +827,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, if (end && *end == ']' && *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go { - if (valobj_sp->GetClangType().IsPointerToScalarType() && deref) + if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) { // what we have is *ptr[low]. the most similar C++ syntax is to deref ptr // and extract bit low out of it. reading array item low @@ -845,7 +845,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, valobj_sp = temp; deref = false; } - else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref) + else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref) { // what we have is *arr[low]. the most similar C++ syntax is to get arr[0] // (an operation that is equivalent to deref-ing arr) @@ -870,9 +870,9 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, { bool is_objc_pointer = true; - if (valobj_sp->GetClangType().GetMinimumLanguage() != eLanguageTypeObjC) + if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC) is_objc_pointer = false; - else if (!valobj_sp->GetClangType().IsPointerType()) + else if (!valobj_sp->GetCompilerType().IsPointerType()) is_objc_pointer = false; if (no_synth_child && is_objc_pointer) @@ -929,7 +929,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, } } } - else if (valobj_sp->GetClangType().IsArrayType (NULL, NULL, &is_incomplete_array)) + else if (valobj_sp->GetCompilerType().IsArrayType (NULL, NULL, &is_incomplete_array)) { // Pass false to dynamic_value here so we can tell the difference between // no dynamic value and no member of this type... @@ -946,7 +946,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, var_expr_path_strm.GetString().c_str()); } } - else if (valobj_sp->GetClangType().IsScalarType()) + else if (valobj_sp->GetCompilerType().IsScalarType()) { // this is a bitfield asking to display just one bit child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true); @@ -1029,7 +1029,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, final_index = temp; } - if (valobj_sp->GetClangType().IsPointerToScalarType() && deref) + if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) { // what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr // and extract bits low thru high out of it. reading array items low thru high @@ -1047,7 +1047,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, valobj_sp = temp; deref = false; } - else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref) + else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref) { // what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0] // (an operation that is equivalent to deref-ing arr) diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index a1e695686965..2b82804db0d0 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1923,7 +1923,7 @@ Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return Type *function_type = sc.function->GetType(); if (function_type) { - CompilerType return_type = sc.function->GetClangType().GetFunctionReturnType(); + CompilerType return_type = sc.function->GetCompilerType().GetFunctionReturnType(); if (return_type) { StreamString s; diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp index 0cdc4c726bb1..6c4028e279f4 100644 --- a/lldb/source/Target/ThreadPlanStepOut.cpp +++ b/lldb/source/Target/ThreadPlanStepOut.cpp @@ -533,7 +533,7 @@ ThreadPlanStepOut::CalculateReturnValue () if (m_immediate_step_from_function != NULL) { - CompilerType return_clang_type = m_immediate_step_from_function->GetClangType().GetFunctionReturnType(); + CompilerType return_clang_type = m_immediate_step_from_function->GetCompilerType().GetFunctionReturnType(); if (return_clang_type) { lldb::ABISP abi_sp = m_thread.GetProcess()->GetABI(); diff --git a/lldb/source/Target/ThreadPlanTracer.cpp b/lldb/source/Target/ThreadPlanTracer.cpp index 406708f8c396..3a18c86d4f6d 100644 --- a/lldb/source/Target/ThreadPlanTracer.cpp +++ b/lldb/source/Target/ThreadPlanTracer.cpp @@ -240,7 +240,7 @@ ThreadPlanAssemblyTracer::Log () Value value; value.SetValueType (Value::eValueTypeScalar); // value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType()); - value.SetClangType (intptr_type); + value.SetCompilerType (intptr_type); value_list.PushValue (value); }