[Lldb-commits] [lldb] r247953 - TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 18 12:41:12 PDT 2015
Hi Greg,
This has broken TestCppValueCast on Windows. Ironically, it has also
*fixed* TestCxxWcharT on Windows. In any case, here is the important line
from the log file of TestCppValueCast.
Traceback (most recent call last):
File "D:\src\llvm\tools\lldb\test\lldbtest.py", line 483, in wrapper
return func(self, *args, **kwargs)
File "D:\src\llvm\tools\lldb\test\lldbtest.py", line 551, in wrapper
return func(self, *args, **kwargs)
File
"D:\src\llvm\tools\lldb\test\lang\cpp\dynamic-value\TestCppValueCast.py",
line 49, in test_value_cast_with_dwarf_and_regular_inheritance
self.do_sbvalue_cast(self.exe_name)
File
"D:\src\llvm\tools\lldb\test\lang\cpp\dynamic-value\TestCppValueCast.py",
line 99, in do_sbvalue_cast
self.assertTrue(tellerA.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error,
0) == 20)
AssertionError: False is not True
Is it possible your patch has an error?
On Thu, Sep 17, 2015 at 3:25 PM Greg Clayton via lldb-commits <
lldb-commits at lists.llvm.org> wrote:
> Author: gclayton
> Date: Thu Sep 17 17:23:34 2015
> New Revision: 247953
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247953&view=rev
> Log:
> TypeSystem is now a plugin interface and removed any "ClangASTContext
> &Class::GetClangASTContext()" functions.
>
> This cleans up type systems to be more pluggable. Prior to this we had
> issues:
> - Module, SymbolFile, and many others has "ClangASTContext
> &GetClangASTContext()" functions. All have been switched over to use
> "TypeSystem *GetTypeSystemForLanguage()"
> - Cleaned up any places that were using the GetClangASTContext() functions
> to use TypeSystem
> - Cleaned up Module so that it no longer has dedicated type system member
> variables:
> lldb::ClangASTContextUP m_ast; ///< The Clang AST context
> for this module.
> lldb::GoASTContextUP m_go_ast; ///< The Go AST context
> for this module.
>
> Now we have a type system map:
>
> typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
> TypeSystemMap m_type_system_map; ///< A map of any
> type systems associated with this module
> - Many places in code were using ClangASTContext static functions to place
> with CompilerType objects and add modifiers (const, volatile, restrict) and
> to make typedefs, L and R value references and more. These have been made
> into CompilerType functions that are abstract:
>
> class CompilerType
> {
> ...
>
>
> //----------------------------------------------------------------------
> // Return a new CompilerType that is a L value reference to this type
> if
> // this type is valid and the type system supports L value references,
> // else return an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> GetLValueReferenceType () const;
>
>
> //----------------------------------------------------------------------
> // Return a new CompilerType that is a R value reference to this type
> if
> // this type is valid and the type system supports R value references,
> // else return an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> GetRValueReferenceType () const;
>
>
> //----------------------------------------------------------------------
> // Return a new CompilerType adds a const modifier to this type if
> // this type is valid and the type system supports const modifiers,
> // else return an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> AddConstModifier () const;
>
>
> //----------------------------------------------------------------------
> // Return a new CompilerType adds a volatile modifier to this type if
> // this type is valid and the type system supports volatile modifiers,
> // else return an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> AddVolatileModifier () const;
>
>
> //----------------------------------------------------------------------
> // Return a new CompilerType adds a restrict modifier to this type if
> // this type is valid and the type system supports restrict modifiers,
> // else return an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> AddRestrictModifier () const;
>
>
> //----------------------------------------------------------------------
> // Create a typedef to this type using "name" as the name of the
> typedef
> // this type is valid and the type system supports typedefs, else
> return
> // an invalid type.
>
> //----------------------------------------------------------------------
> CompilerType
> CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx)
> const;
>
> };
>
> Other changes include:
> - Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and
> CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with
> "CompilerType
> TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
> size_t bit_size);"
> - Fixed code in Type.h to not request the full type for a type for no good
> reason, just request the forward type and let the type expand as needed
>
>
>
> Modified:
> lldb/trunk/include/lldb/Core/Module.h
> lldb/trunk/include/lldb/Core/PluginManager.h
> lldb/trunk/include/lldb/Symbol/ClangASTContext.h
> lldb/trunk/include/lldb/Symbol/CompilerType.h
> lldb/trunk/include/lldb/Symbol/GoASTContext.h
> lldb/trunk/include/lldb/Symbol/SymbolFile.h
> lldb/trunk/include/lldb/Symbol/Type.h
> lldb/trunk/include/lldb/Symbol/TypeSystem.h
> lldb/trunk/include/lldb/lldb-forward.h
> lldb/trunk/include/lldb/lldb-private-interfaces.h
> lldb/trunk/source/API/SBModule.cpp
> lldb/trunk/source/API/SBType.cpp
> lldb/trunk/source/API/SystemInitializerFull.cpp
> lldb/trunk/source/Commands/CommandObjectArgs.cpp
> lldb/trunk/source/Core/Module.cpp
> lldb/trunk/source/Core/PluginManager.cpp
> lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
> lldb/trunk/source/Core/ValueObjectRegister.cpp
> lldb/trunk/source/DataFormatters/FormatManager.cpp
> lldb/trunk/source/DataFormatters/VectorType.cpp
> lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
> lldb/trunk/source/Expression/ClangExpressionParser.cpp
> lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
> lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
> lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
> lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
> lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
> lldb/trunk/source/Symbol/ClangASTContext.cpp
> lldb/trunk/source/Symbol/CompilerType.cpp
> lldb/trunk/source/Symbol/GoASTContext.cpp
> lldb/trunk/source/Symbol/SymbolFile.cpp
> lldb/trunk/source/Symbol/Type.cpp
> lldb/trunk/source/Symbol/TypeSystem.cpp
> lldb/trunk/source/Symbol/Variable.cpp
> lldb/trunk/source/Target/ThreadPlanTracer.cpp
>
> Modified: lldb/trunk/include/lldb/Core/Module.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/Module.h (original)
> +++ lldb/trunk/include/lldb/Core/Module.h Thu Sep 17 17:23:34 2015
> @@ -944,9 +944,6 @@ public:
> bool
> GetIsDynamicLinkEditor ();
>
> - ClangASTContext &
> - GetClangASTContext ();
> -
> TypeSystem *
> GetTypeSystemForLanguage (lldb::LanguageType language);
>
> @@ -1101,6 +1098,7 @@ public:
> bool &match_name_after_lookup);
>
> protected:
> + typedef std::map<lldb::LanguageType, lldb::TypeSystemSP>
> TypeSystemMap;
> //------------------------------------------------------------------
> // Member Variables
> //------------------------------------------------------------------
> @@ -1119,15 +1117,13 @@ protected:
> lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the
> symbol vendor for this module.
> std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone
> calls Module::SetSymbolFileFileSpec() and changes the symbol file,
> ///< we need to
> keep all old symbol files around in case anyone has type references to them
> - lldb::ClangASTContextUP m_ast; ///< The Clang AST
> context for this module.
> - lldb::GoASTContextUP m_go_ast; ///< The Go AST context
> for this module.
> + TypeSystemMap m_type_system_map; ///< A map of any
> type systems associated with this module
> PathMappingList m_source_mappings; ///< Module specific
> source remappings for when you have debug info for a module that doesn't
> match where the sources currently are
> lldb::SectionListUP m_sections_ap; ///< Unified section list
> for module that is used by the ObjectFile and and ObjectFile instances for
> the debug info
>
> std::atomic<bool> m_did_load_objfile;
> std::atomic<bool> m_did_load_symbol_vendor;
> std::atomic<bool> m_did_parse_uuid;
> - std::atomic<bool> m_did_init_ast;
> mutable bool m_file_has_changed:1,
> m_first_file_changed_log:1; /// See if
> the module was modified after it was initially opened.
>
>
> Modified: lldb/trunk/include/lldb/Core/PluginManager.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/PluginManager.h (original)
> +++ lldb/trunk/include/lldb/Core/PluginManager.h Thu Sep 17 17:23:34 2015
> @@ -419,6 +419,22 @@ public:
> static InstrumentationRuntimeCreateInstance
> GetInstrumentationRuntimeCreateCallbackForPluginName (const
> ConstString &name);
>
> + //------------------------------------------------------------------
> + // TypeSystem
> + //------------------------------------------------------------------
> + static bool
> + RegisterPlugin (const ConstString &name,
> + const char *description,
> + TypeSystemCreateInstance create_callback);
> +
> + static bool
> + UnregisterPlugin (TypeSystemCreateInstance create_callback);
> +
> + static TypeSystemCreateInstance
> + GetTypeSystemCreateCallbackAtIndex (uint32_t idx);
> +
> + static TypeSystemCreateInstance
> + GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
>
> //------------------------------------------------------------------
> // Some plug-ins might register a DebuggerInitializeCallback
>
> Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
> +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 17 17:23:34
> 2015
> @@ -55,7 +55,28 @@ public:
> ClangASTContext (const char *triple = NULL);
>
> ~ClangASTContext() override;
> -
> +
> + //------------------------------------------------------------------
> + // PluginInterface functions
> + //------------------------------------------------------------------
> + ConstString
> + GetPluginName() override;
> +
> + uint32_t
> + GetPluginVersion() override;
> +
> + static ConstString
> + GetPluginNameStatic ();
> +
> + static lldb::TypeSystemSP
> + CreateInstance (lldb::LanguageType language, const
> lldb_private::ArchSpec &arch);
> +
> + static void
> + Initialize ();
> +
> + static void
> + Terminate ();
> +
> static ClangASTContext*
> GetASTContext (clang::ASTContext* ast_ctx);
>
> @@ -153,7 +174,7 @@ public:
> //------------------------------------------------------------------
> CompilerType
> GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding,
> - uint32_t bit_size);
> + size_t bit_size) override;
>
> static CompilerType
> GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast,
> @@ -448,13 +469,7 @@ public:
> //------------------------------------------------------------------
> // Integer type functions
> //------------------------------------------------------------------
> -
> - CompilerType
> - GetIntTypeFromBitSize (size_t bit_size, bool is_signed) override
> - {
> - return GetIntTypeFromBitSize (getASTContext(), bit_size,
> is_signed);
> - }
> -
> +
> static CompilerType
> GetIntTypeFromBitSize (clang::ASTContext *ast,
> size_t bit_size, bool is_signed);
> @@ -471,12 +486,6 @@ public:
> //------------------------------------------------------------------
> // Floating point functions
> //------------------------------------------------------------------
> -
> - CompilerType
> - GetFloatTypeFromBitSize (size_t bit_size) override
> - {
> - return GetFloatTypeFromBitSize (getASTContext(), bit_size);
> - }
>
> static CompilerType
> GetFloatTypeFromBitSize (clang::ASTContext *ast,
> @@ -673,7 +682,10 @@ public:
>
> bool
> IsVoidType (void *type) override;
> -
> +
> + bool
> + SupportsLanguage (lldb::LanguageType language) override;
> +
> static bool
> GetCXXClassName (const CompilerType& type, std::string &class_name);
>
> @@ -710,15 +722,6 @@ public:
> // Creating related types
>
> //----------------------------------------------------------------------
>
> - static CompilerType
> - AddConstModifier (const CompilerType& type);
> -
> - static CompilerType
> - AddRestrictModifier (const CompilerType& type);
> -
> - static CompilerType
> - AddVolatileModifier (const CompilerType& type);
> -
> // Using the current type, create a new typedef to that type using
> "typedef_name"
> // as the name and "decl_ctx" as the decl context.
> static CompilerType
> @@ -752,9 +755,6 @@ public:
> TypeMemberFunctionImpl
> GetMemberFunctionAtIndex (void *type, size_t idx) override;
>
> - static CompilerType
> - GetLValueReferenceType (const CompilerType& type);
> -
> CompilerType
> GetNonReferenceType (void *type) override;
>
> @@ -763,10 +763,25 @@ public:
>
> CompilerType
> GetPointerType (void *type) override;
> -
> - static CompilerType
> - GetRValueReferenceType (const CompilerType& type);
> -
> +
> + CompilerType
> + GetLValueReferenceType (void *type) override;
> +
> + CompilerType
> + GetRValueReferenceType (void *type) override;
> +
> + CompilerType
> + AddConstModifier (void *type) override;
> +
> + CompilerType
> + AddVolatileModifier (void *type) override;
> +
> + CompilerType
> + AddRestrictModifier (void *type) override;
> +
> + CompilerType
> + CreateTypedef (void *type, const char *name, const
> CompilerDeclContext &decl_ctx) override;
> +
> // If the current object represents a typedef type, get the
> underlying type
> CompilerType
> GetTypedefedType (void *type) override;
> @@ -804,7 +819,10 @@ public:
>
> uint32_t
> GetNumChildren (void *type, bool omit_empty_base_classes) override;
> -
> +
> + CompilerType
> + GetBuiltinTypeByName (const ConstString &name) override;
> +
> lldb::BasicType
> GetBasicTypeEnumeration (void *type) override;
>
>
> Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
> +++ lldb/trunk/include/lldb/Symbol/CompilerType.h Thu Sep 17 17:23:34 2015
> @@ -272,15 +272,75 @@ public:
> TypeMemberFunctionImpl
> GetMemberFunctionAtIndex (size_t idx);
>
> +
> //----------------------------------------------------------------------
> + // If this type is a reference to a type (L value or R value
> reference),
> + // return a new type with the reference removed, else return the
> current
> + // type itself.
> +
> //----------------------------------------------------------------------
> CompilerType
> GetNonReferenceType () const;
>
> +
> //----------------------------------------------------------------------
> + // If this type is a pointer type, return the type that the pointer
> + // points to, else return an invalid type.
> +
> //----------------------------------------------------------------------
> CompilerType
> GetPointeeType () const;
>
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType that is a pointer to this type
> +
> //----------------------------------------------------------------------
> CompilerType
> GetPointerType () const;
>
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType that is a L value reference to this type
> if
> + // this type is valid and the type system supports L value references,
> + // else return an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + GetLValueReferenceType () const;
> +
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType that is a R value reference to this type
> if
> + // this type is valid and the type system supports R value references,
> + // else return an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + GetRValueReferenceType () const;
> +
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType adds a const modifier to this type if
> + // this type is valid and the type system supports const modifiers,
> + // else return an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + AddConstModifier () const;
> +
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType adds a volatile modifier to this type if
> + // this type is valid and the type system supports volatile modifiers,
> + // else return an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + AddVolatileModifier () const;
> +
> +
> //----------------------------------------------------------------------
> + // Return a new CompilerType adds a restrict modifier to this type if
> + // this type is valid and the type system supports restrict modifiers,
> + // else return an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + AddRestrictModifier () const;
> +
> +
> //----------------------------------------------------------------------
> + // Create a typedef to this type using "name" as the name of the
> typedef
> + // this type is valid and the type system supports typedefs, else
> return
> + // an invalid type.
> +
> //----------------------------------------------------------------------
> + CompilerType
> + CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx)
> const;
> +
> // If the current object represents a typedef type, get the
> underlying type
> CompilerType
> GetTypedefedType () const;
>
> Modified: lldb/trunk/include/lldb/Symbol/GoASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/GoASTContext.h (original)
> +++ lldb/trunk/include/lldb/Symbol/GoASTContext.h Thu Sep 17 17:23:34 2015
> @@ -27,6 +27,28 @@ class GoASTContext : public TypeSystem
> GoASTContext();
> ~GoASTContext();
>
> + //------------------------------------------------------------------
> + // PluginInterface functions
> + //------------------------------------------------------------------
> + ConstString
> + GetPluginName() override;
> +
> + uint32_t
> + GetPluginVersion() override;
> +
> + static ConstString
> + GetPluginNameStatic ();
> +
> + static lldb::TypeSystemSP
> + CreateInstance (lldb::LanguageType language, const
> lldb_private::ArchSpec &arch);
> +
> + static void
> + Initialize ();
> +
> + static void
> + Terminate ();
> +
> +
> DWARFASTParser *GetDWARFParser() override;
>
> void
> @@ -101,7 +123,7 @@ class GoASTContext : public TypeSystem
> CompilerType CreateBaseType(int go_kind, const ConstString
> &type_name_const_str, uint64_t byte_size);
>
> // For interface, map, chan.
> - CompilerType CreateTypedef(int kind, const ConstString &name,
> CompilerType impl);
> + CompilerType CreateTypedefType(int kind, const ConstString &name,
> CompilerType impl);
>
> CompilerType CreateVoidType(const ConstString &name);
> CompilerType CreateFunctionType(const lldb_private::ConstString
> &name, CompilerType *params, size_t params_count,
> @@ -124,37 +146,39 @@ class GoASTContext : public TypeSystem
> static bool IsDirectIface(uint8_t kind);
> static bool IsPointerKind(uint8_t kind);
>
> - virtual bool IsArrayType(void *type, CompilerType *element_type,
> uint64_t *size, bool *is_incomplete) override;
> + bool IsArrayType(void *type, CompilerType *element_type, uint64_t
> *size, bool *is_incomplete) override;
>
> - virtual bool IsAggregateType(void *type) override;
> + bool IsAggregateType(void *type) override;
>
> - virtual bool IsCharType(void *type) override;
> + bool IsCharType(void *type) override;
>
> - virtual bool IsCompleteType(void *type) override;
> + bool IsCompleteType(void *type) override;
>
> - virtual bool IsDefined(void *type) override;
> + bool IsDefined(void *type) override;
>
> - virtual bool IsFloatingPointType(void *type, uint32_t &count, bool
> &is_complex) override;
> + bool IsFloatingPointType(void *type, uint32_t &count, bool
> &is_complex) override;
>
> - virtual bool IsFunctionType(void *type, bool *is_variadic_ptr = NULL)
> override;
> + bool IsFunctionType(void *type, bool *is_variadic_ptr = NULL)
> override;
>
> - virtual size_t GetNumberOfFunctionArguments(void *type) override;
> + size_t GetNumberOfFunctionArguments(void *type) override;
>
> - virtual CompilerType GetFunctionArgumentAtIndex(void *type, const
> size_t index) override;
> + CompilerType GetFunctionArgumentAtIndex(void *type, const size_t
> index) override;
>
> - virtual bool IsFunctionPointerType(void *type) override;
> + bool IsFunctionPointerType(void *type) override;
>
> - virtual bool IsIntegerType(void *type, bool &is_signed) override;
> + bool IsIntegerType(void *type, bool &is_signed) override;
>
> - virtual bool IsPossibleDynamicType(void *type,
> + bool IsPossibleDynamicType(void *type,
> CompilerType *target_type, // Can
> pass NULL
> bool check_cplusplus, bool
> check_objc) override;
>
> - virtual bool IsPointerType(void *type, CompilerType *pointee_type =
> NULL) override;
> + bool IsPointerType(void *type, CompilerType *pointee_type = NULL)
> override;
> +
> + bool IsScalarType(void *type) override;
>
> - virtual bool IsScalarType(void *type) override;
> + bool IsVoidType(void *type) override;
>
> - virtual bool IsVoidType(void *type) override;
> + bool SupportsLanguage (lldb::LanguageType language) override;
>
>
> //----------------------------------------------------------------------
> // Type Completion
> @@ -217,9 +241,9 @@ class GoASTContext : public TypeSystem
> virtual uint32_t GetNumChildren(void *type, bool
> omit_empty_base_classes) override;
>
> virtual lldb::BasicType GetBasicTypeEnumeration(void *type) override;
> - virtual CompilerType GetIntTypeFromBitSize (size_t bit_size, bool
> is_signed) override;
> - virtual CompilerType GetFloatTypeFromBitSize (size_t bit_size)
> override;
>
> + virtual CompilerType GetBuiltinTypeForEncodingAndBitSize
> (lldb::Encoding encoding,
> + size_t
> bit_size) override;
>
> virtual uint32_t GetNumFields(void *type) override;
>
>
> Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
> +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Thu Sep 17 17:23:34 2015
> @@ -147,8 +147,6 @@ public:
> virtual size_t GetTypes (lldb_private::SymbolContextScope
> *sc_scope,
> uint32_t type_mask,
> lldb_private::TypeList &type_list)
> = 0;
> - virtual ClangASTContext &
> - GetClangASTContext ();
>
> virtual lldb_private::TypeSystem *
> GetTypeSystemForLanguage (lldb::LanguageType
> language);
>
> Modified: lldb/trunk/include/lldb/Symbol/Type.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/Type.h (original)
> +++ lldb/trunk/include/lldb/Symbol/Type.h Thu Sep 17 17:23:34 2015
> @@ -14,7 +14,6 @@
> #include "lldb/Core/ClangForward.h"
> #include "lldb/Core/ConstString.h"
> #include "lldb/Core/UserID.h"
> -#include "lldb/Symbol/ClangASTContext.h"
> #include "lldb/Symbol/CompilerType.h"
> #include "lldb/Symbol/Declaration.h"
>
> @@ -254,9 +253,6 @@ public:
> CompilerType
> GetForwardCompilerType ();
>
> - ClangASTContext &
> - GetClangASTContext ();
> -
> static int
> Compare(const Type &a, const Type &b);
>
> @@ -422,7 +418,7 @@ public:
> GetPointerType () const
> {
> if (type_sp)
> - return type_sp->GetLayoutCompilerType ().GetPointerType();
> + return type_sp->GetForwardCompilerType().GetPointerType();
> return clang_type.GetPointerType();
> }
>
> @@ -430,7 +426,7 @@ public:
> GetPointeeType () const
> {
> if (type_sp)
> - return type_sp->GetFullCompilerType ().GetPointeeType();
> + return type_sp->GetForwardCompilerType ().GetPointeeType();
> return clang_type.GetPointeeType();
> }
>
> @@ -438,39 +434,43 @@ public:
> GetReferenceType () const
> {
> if (type_sp)
> - return
> ClangASTContext::GetLValueReferenceType(type_sp->GetLayoutCompilerType ());
> - return ClangASTContext::GetLValueReferenceType(clang_type);
> + return type_sp->GetForwardCompilerType
> ().GetLValueReferenceType();
> + else
> + return clang_type.GetLValueReferenceType();
> }
>
> CompilerType
> GetTypedefedType () const
> {
> if (type_sp)
> - return type_sp->GetFullCompilerType ().GetTypedefedType();
> - return clang_type.GetTypedefedType();
> + return type_sp->GetForwardCompilerType ().GetTypedefedType();
> + else
> + return clang_type.GetTypedefedType();
> }
>
> CompilerType
> GetDereferencedType () const
> {
> if (type_sp)
> - return type_sp->GetFullCompilerType ().GetNonReferenceType();
> - return clang_type.GetNonReferenceType();
> + return type_sp->GetForwardCompilerType
> ().GetNonReferenceType();
> + else
> + return clang_type.GetNonReferenceType();
> }
>
> CompilerType
> GetUnqualifiedType () const
> {
> if (type_sp)
> - return type_sp->GetLayoutCompilerType
> ().GetFullyUnqualifiedType();
> - return clang_type.GetFullyUnqualifiedType();
> + return type_sp->GetForwardCompilerType
> ().GetFullyUnqualifiedType();
> + else
> + return clang_type.GetFullyUnqualifiedType();
> }
>
> CompilerType
> GetCanonicalType () const
> {
> if (type_sp)
> - return type_sp->GetFullCompilerType ().GetCanonicalType();
> + return type_sp->GetForwardCompilerType ().GetCanonicalType();
> return clang_type.GetCanonicalType();
> }
>
>
> Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
> +++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Thu Sep 17 17:23:34 2015
> @@ -14,6 +14,7 @@
> #include <string>
> #include "lldb/lldb-private.h"
> #include "lldb/Core/ClangForward.h"
> +#include "lldb/Core/PluginInterface.h"
> #include "lldb/Expression/Expression.h"
> #include "lldb/Symbol/CompilerDeclContext.h"
> #include "clang/AST/CharUnits.h"
> @@ -28,7 +29,7 @@ namespace lldb_private {
> //----------------------------------------------------------------------
> // Interface for representing the Type Systems in different languages.
> //----------------------------------------------------------------------
> -class TypeSystem
> +class TypeSystem : public PluginInterface
> {
> public:
>
> //----------------------------------------------------------------------
> @@ -71,6 +72,9 @@ public:
>
> LLVMCastKind getKind() const { return m_kind; }
>
> + static lldb::TypeSystemSP
> + CreateInstance (lldb::LanguageType language, const
> lldb_private::ArchSpec &arch);
> +
>
> //----------------------------------------------------------------------
> // Constructors and Destructors
>
> //----------------------------------------------------------------------
> @@ -182,7 +186,11 @@ public:
>
> virtual bool
> IsVoidType (void *type) = 0;
> -
> +
> + // TypeSystems can support more than one language
> + virtual bool
> + SupportsLanguage (lldb::LanguageType language) = 0;
> +
>
> //----------------------------------------------------------------------
> // Type Completion
>
> //----------------------------------------------------------------------
> @@ -245,7 +253,25 @@ public:
>
> virtual CompilerType
> GetPointerType (void *type) = 0;
> -
> +
> + virtual CompilerType
> + GetLValueReferenceType (void *type);
> +
> + virtual CompilerType
> + GetRValueReferenceType (void *type);
> +
> + virtual CompilerType
> + AddConstModifier (void *type);
> +
> + virtual CompilerType
> + AddVolatileModifier (void *type);
> +
> + virtual CompilerType
> + AddRestrictModifier (void *type);
> +
> + virtual CompilerType
> + CreateTypedef (void *type, const char *name, const
> CompilerDeclContext &decl_ctx);
> +
>
> //----------------------------------------------------------------------
> // Exploring the type
>
> //----------------------------------------------------------------------
> @@ -261,7 +287,10 @@ public:
>
> virtual uint32_t
> GetNumChildren (void *type, bool omit_empty_base_classes) = 0;
> -
> +
> + virtual CompilerType
> + GetBuiltinTypeByName (const ConstString &name);
> +
> virtual lldb::BasicType
> GetBasicTypeEnumeration (void *type) = 0;
>
> @@ -417,10 +446,8 @@ public:
> GetBasicTypeFromAST (lldb::BasicType basic_type) = 0;
>
> virtual CompilerType
> - GetIntTypeFromBitSize (size_t bit_size, bool is_signed) = 0;
> -
> - virtual CompilerType
> - GetFloatTypeFromBitSize (size_t bit_size) = 0;
> + GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
> + size_t bit_size) = 0;
>
> virtual bool
> IsBeingDefined (void *type) = 0;
>
> Modified: lldb/trunk/include/lldb/lldb-forward.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/lldb-forward.h (original)
> +++ lldb/trunk/include/lldb/lldb-forward.h Thu Sep 17 17:23:34 2015
> @@ -426,6 +426,7 @@ namespace lldb {
> typedef std::shared_ptr<lldb_private::TypeMemberFunctionImpl>
> TypeMemberFunctionImplSP;
> typedef std::shared_ptr<lldb_private::TypeEnumMemberImpl>
> TypeEnumMemberImplSP;
> typedef std::shared_ptr<lldb_private::TypeFilterImpl>
> TypeFilterImplSP;
> + typedef std::shared_ptr<lldb_private::TypeSystem> TypeSystemSP;
> typedef std::shared_ptr<lldb_private::TypeFormatImpl>
> TypeFormatImplSP;
> typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl>
> TypeNameSpecifierImplSP;
> typedef std::shared_ptr<lldb_private::TypeSummaryImpl>
> TypeSummaryImplSP;
>
> Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
> +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Thu Sep 17 17:23:34
> 2015
> @@ -46,6 +46,7 @@ namespace lldb_private
> typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance) (const
> lldb::ProcessSP &process_sp);
> typedef lldb::InstrumentationRuntimeType
> (*InstrumentationRuntimeGetType) ();
> typedef lldb::InstrumentationRuntimeSP
> (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
> + typedef lldb::TypeSystemSP (*TypeSystemCreateInstance)
> (lldb::LanguageType language, const lldb_private::ArchSpec &arch);
> typedef int (*ComparisonFunction)(const void *, const void *);
> typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
>
>
> Modified: lldb/trunk/source/API/SBModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/API/SBModule.cpp (original)
> +++ lldb/trunk/source/API/SBModule.cpp Thu Sep 17 17:23:34 2015
> @@ -20,10 +20,10 @@
> #include "lldb/Core/StreamString.h"
> #include "lldb/Core/ValueObjectList.h"
> #include "lldb/Core/ValueObjectVariable.h"
> -#include "lldb/Symbol/ClangASTContext.h"
> #include "lldb/Symbol/ObjectFile.h"
> #include "lldb/Symbol/SymbolVendor.h"
> #include "lldb/Symbol/Symtab.h"
> +#include "lldb/Symbol/TypeSystem.h"
> #include "lldb/Symbol/VariableList.h"
> #include "lldb/Target/Target.h"
>
> @@ -521,7 +521,11 @@ SBModule::FindFirstType (const char *nam
> sb_type = SBType (module_sp->FindFirstType(sc, name,
> exact_match));
>
> if (!sb_type.IsValid())
> - sb_type = SBType (ClangASTContext::GetBasicType
> (module_sp->GetClangASTContext().getASTContext(), name));
> + {
> + TypeSystem *type_system =
> module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
> + if (type_system)
> + sb_type = SBType
> (type_system->GetBuiltinTypeByName(name));
> + }
> }
> return sb_type;
> }
> @@ -531,7 +535,11 @@ SBModule::GetBasicType(lldb::BasicType t
> {
> ModuleSP module_sp (GetSP ());
> if (module_sp)
> - return SBType (ClangASTContext::GetBasicType
> (module_sp->GetClangASTContext().getASTContext(), type));
> + {
> + TypeSystem *type_system =
> module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
> + if (type_system)
> + return SBType (type_system->GetBasicTypeFromAST(type));
> + }
> return SBType();
> }
>
> @@ -564,9 +572,13 @@ SBModule::FindTypes (const char *type)
> }
> else
> {
> - SBType sb_type(ClangASTContext::GetBasicType
> (module_sp->GetClangASTContext().getASTContext(), name));
> - if (sb_type.IsValid())
> - retval.Append(sb_type);
> + TypeSystem *type_system =
> module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
> + if (type_system)
> + {
> + CompilerType compiler_type =
> type_system->GetBuiltinTypeByName(name);
> + if (compiler_type)
> + retval.Append(SBType(compiler_type));
> + }
> }
> }
>
>
> Modified: lldb/trunk/source/API/SBType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/API/SBType.cpp (original)
> +++ lldb/trunk/source/API/SBType.cpp Thu Sep 17 17:23:34 2015
> @@ -16,6 +16,7 @@
> #include "lldb/Core/Stream.h"
> #include "lldb/Symbol/CompilerType.h"
> #include "lldb/Symbol/Type.h"
> +#include "lldb/Symbol/TypeSystem.h"
>
> #include "llvm/ADT/APSInt.h"
> #include "clang/AST/Decl.h"
>
> Modified: lldb/trunk/source/API/SystemInitializerFull.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/API/SystemInitializerFull.cpp (original)
> +++ lldb/trunk/source/API/SystemInitializerFull.cpp Thu Sep 17 17:23:34
> 2015
> @@ -24,6 +24,8 @@
> #include "lldb/Host/Host.h"
> #include "lldb/Initialization/SystemInitializerCommon.h"
> #include "lldb/Interpreter/CommandInterpreter.h"
> +#include "lldb/Symbol/ClangASTContext.h"
> +#include "lldb/Symbol/GoASTContext.h"
>
> #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
> #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
> @@ -251,6 +253,9 @@ SystemInitializerFull::Initialize()
> llvm::InitializeAllTargetMCs();
> llvm::InitializeAllDisassemblers();
>
> + ClangASTContext::Initialize();
> + GoASTContext::Initialize();
> +
> ABIMacOSX_i386::Initialize();
> ABIMacOSX_arm::Initialize();
> ABIMacOSX_arm64::Initialize();
> @@ -359,6 +364,10 @@ SystemInitializerFull::Terminate()
>
> // Terminate and unload and loaded system or user LLDB plug-ins
> PluginManager::Terminate();
> +
> + ClangASTContext::Terminate();
> + GoASTContext::Terminate();
> +
> ABIMacOSX_i386::Terminate();
> ABIMacOSX_arm::Terminate();
> ABIMacOSX_arm64::Terminate();
>
> Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Thu Sep 17 17:23:34
> 2015
> @@ -146,8 +146,14 @@ CommandObjectArgs::DoExecute (Args& args
> result.SetStatus (eReturnStatusFailed);
> return false;
> }
> -
> - ClangASTContext &ast_context = thread_module_sp->GetClangASTContext();
> +
> + TypeSystem *type_system =
> thread_module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
> + if (type_system == nullptr)
> + {
> + result.AppendError ("Unable to create C type system.");
> + result.SetStatus (eReturnStatusFailed);
> + return false;
> + }
>
> ValueList value_list;
>
> @@ -156,7 +162,7 @@ CommandObjectArgs::DoExecute (Args& args
> const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index);
> Value value;
> value.SetValueType(Value::eValueTypeScalar);
> - CompilerType clang_type;
> + CompilerType compiler_type;
>
> char *int_pos;
> if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int")))
> @@ -198,10 +204,9 @@ CommandObjectArgs::DoExecute (Args& args
> result.SetStatus (eReturnStatusFailed);
> return false;
> }
> + compiler_type =
> type_system->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
>
> - clang_type =
> ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
> -
> - if (!clang_type.IsValid())
> + if (!compiler_type.IsValid())
> {
> result.AppendErrorWithFormat ("Couldn't get Clang type
> for format %s (%s integer, width %d).\n",
> arg_type_cstr,
> @@ -215,9 +220,9 @@ CommandObjectArgs::DoExecute (Args& args
> else if (strchr (arg_type_cstr, '*'))
> {
> if (!strcmp (arg_type_cstr, "void*"))
> - clang_type =
> ast_context.GetBasicType(eBasicTypeVoid).GetPointerType();
> + compiler_type =
> type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
> else if (!strcmp (arg_type_cstr, "char*"))
> - clang_type = ast_context.GetCStringType (false);
> + compiler_type =
> type_system->GetBasicTypeFromAST(eBasicTypeChar).GetPointerType();
> else
> {
> result.AppendErrorWithFormat ("Invalid format: %s.\n",
> arg_type_cstr);
> @@ -232,7 +237,7 @@ CommandObjectArgs::DoExecute (Args& args
> return false;
> }
>
> - value.SetCompilerType (clang_type);
> + value.SetCompilerType (compiler_type);
> value_list.PushValue(value);
> }
>
>
> Modified: lldb/trunk/source/Core/Module.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Module.cpp (original)
> +++ lldb/trunk/source/Core/Module.cpp Thu Sep 17 17:23:34 2015
> @@ -15,6 +15,7 @@
> #include "lldb/Core/Log.h"
> #include "lldb/Core/ModuleList.h"
> #include "lldb/Core/ModuleSpec.h"
> +#include "lldb/Core/PluginManager.h"
> #include "lldb/Core/RegularExpression.h"
> #include "lldb/Core/Section.h"
> #include "lldb/Core/StreamString.h"
> @@ -23,17 +24,16 @@
> #include "lldb/Host/Symbols.h"
> #include "lldb/Interpreter/CommandInterpreter.h"
> #include "lldb/Interpreter/ScriptInterpreter.h"
> -#include "lldb/Symbol/ClangASTContext.h"
> #include "lldb/Symbol/CompileUnit.h"
> -#include "lldb/Symbol/GoASTContext.h"
> #include "lldb/Symbol/ObjectFile.h"
> #include "lldb/Symbol/SymbolContext.h"
> +#include "lldb/Symbol/SymbolFile.h"
> #include "lldb/Symbol/SymbolVendor.h"
> +#include "lldb/Symbol/TypeSystem.h"
> #include "lldb/Target/Language.h"
> #include "lldb/Target/Process.h"
> #include "lldb/Target/SectionLoadList.h"
> #include "lldb/Target/Target.h"
> -#include "lldb/Symbol/SymbolFile.h"
> #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
> #include "Plugins/Language/ObjC/ObjCLanguage.h"
>
> @@ -148,14 +148,12 @@ Module::Module (const ModuleSpec &module
> m_object_mod_time (),
> m_objfile_sp (),
> m_symfile_ap (),
> - m_ast (new ClangASTContext),
> - m_go_ast(),
> + m_type_system_map(),
> m_source_mappings (),
> m_sections_ap(),
> m_did_load_objfile (false),
> m_did_load_symbol_vendor (false),
> m_did_parse_uuid (false),
> - m_did_init_ast (false),
> m_file_has_changed (false),
> m_first_file_changed_log (false)
> {
> @@ -253,14 +251,12 @@ Module::Module(const FileSpec& file_spec
> m_object_mod_time (),
> m_objfile_sp (),
> m_symfile_ap (),
> - m_ast (new ClangASTContext),
> - m_go_ast(),
> + m_type_system_map(),
> m_source_mappings (),
> m_sections_ap(),
> m_did_load_objfile (false),
> m_did_load_symbol_vendor (false),
> m_did_parse_uuid (false),
> - m_did_init_ast (false),
> m_file_has_changed (false),
> m_first_file_changed_log (false)
> {
> @@ -300,14 +296,12 @@ Module::Module () :
> m_object_mod_time (),
> m_objfile_sp (),
> m_symfile_ap (),
> - m_ast (new ClangASTContext),
> - m_go_ast(),
> + m_type_system_map(),
> m_source_mappings (),
> m_sections_ap(),
> m_did_load_objfile (false),
> m_did_load_symbol_vendor (false),
> m_did_parse_uuid (false),
> - m_did_init_ast (false),
> m_file_has_changed (false),
> m_first_file_changed_log (false)
> {
> @@ -424,64 +418,26 @@ Module::GetUUID()
> TypeSystem *
> Module::GetTypeSystemForLanguage (LanguageType language)
> {
> - if (language == eLanguageTypeGo)
> - {
> - Mutex::Locker locker (m_mutex);
> - if (!m_go_ast)
> - {
> - ObjectFile * objfile = GetObjectFile();
> - ArchSpec object_arch;
> - if (objfile && objfile->GetArchitecture(object_arch))
> - {
> - m_go_ast.reset(new GoASTContext);
> -
> m_go_ast->SetAddressByteSize(object_arch.GetAddressByteSize());
> - }
> - }
> - return m_go_ast.get();
> - }
> - else if (language != eLanguageTypeSwift)
> - {
> - // For now assume all languages except swift use the
> ClangASTContext for types
> - return &GetClangASTContext();
> - }
> - return nullptr;
> -}
> + Mutex::Locker locker (m_mutex);
> + TypeSystemMap::iterator pos = m_type_system_map.find(language);
> + if (pos != m_type_system_map.end())
> + return pos->second.get();
>
> -ClangASTContext &
> -Module::GetClangASTContext ()
> -{
> - if (m_did_init_ast.load() == false)
> + for (const auto &pair : m_type_system_map)
> {
> - Mutex::Locker locker (m_mutex);
> - if (m_did_init_ast.load() == false)
> + if (pair.second && pair.second->SupportsLanguage(language))
> {
> - ObjectFile * objfile = GetObjectFile();
> - ArchSpec object_arch;
> - if (objfile && objfile->GetArchitecture(object_arch))
> - {
> - m_did_init_ast = true;
> -
> - // LLVM wants this to be set to iOS or MacOSX; if we're
> working on
> - // a bare-boards type image, change the triple for llvm's
> benefit.
> - if (object_arch.GetTriple().getVendor() ==
> llvm::Triple::Apple
> - && object_arch.GetTriple().getOS() ==
> llvm::Triple::UnknownOS)
> - {
> - if (object_arch.GetTriple().getArch() ==
> llvm::Triple::arm ||
> - object_arch.GetTriple().getArch() ==
> llvm::Triple::aarch64 ||
> - object_arch.GetTriple().getArch() ==
> llvm::Triple::thumb)
> - {
> - object_arch.GetTriple().setOS(llvm::Triple::IOS);
> - }
> - else
> - {
> -
> object_arch.GetTriple().setOS(llvm::Triple::MacOSX);
> - }
> - }
> - m_ast->SetArchitecture (object_arch);
> - }
> + // Add a new mapping for "language" to point to an already
> existing
> + // TypeSystem that supports this language
> + m_type_system_map[language] = pair.second;
> + return pair.second.get();
> }
> }
> - return *m_ast;
> +
> + // Cache even if we get a shared pointer that contains null type
> system back
> + lldb::TypeSystemSP type_system_sp = TypeSystem::CreateInstance
> (language, GetArchitecture());
> + m_type_system_map[language] = type_system_sp;
> + return type_system_sp.get();
> }
>
> void
>
> Modified: lldb/trunk/source/Core/PluginManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/PluginManager.cpp (original)
> +++ lldb/trunk/source/Core/PluginManager.cpp Thu Sep 17 17:23:34 2015
> @@ -2516,6 +2516,108 @@ PluginManager::GetInstrumentationRuntime
> return NULL;
> }
>
> +#pragma mark TypeSystem
> +
> +
> +struct TypeSystemInstance
> +{
> + TypeSystemInstance() :
> + name(),
> + description(),
> + create_callback(NULL)
> + {
> + }
> +
> + ConstString name;
> + std::string description;
> + TypeSystemCreateInstance create_callback;
> +};
> +
> +typedef std::vector<TypeSystemInstance> TypeSystemInstances;
> +
> +static Mutex &
> +GetTypeSystemMutex ()
> +{
> + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
> + return g_instances_mutex;
> +}
> +
> +static TypeSystemInstances &
> +GetTypeSystemInstances ()
> +{
> + static TypeSystemInstances g_instances;
> + return g_instances;
> +}
> +
> +bool
> +PluginManager::RegisterPlugin (const ConstString &name,
> + const char *description,
> + TypeSystemCreateInstance create_callback)
> +{
> + if (create_callback)
> + {
> + TypeSystemInstance instance;
> + assert ((bool)name);
> + instance.name = name;
> + if (description && description[0])
> + instance.description = description;
> + instance.create_callback = create_callback;
> + Mutex::Locker locker (GetTypeSystemMutex ());
> + GetTypeSystemInstances ().push_back (instance);
> + }
> + return false;
> +}
> +
> +bool
> +PluginManager::UnregisterPlugin (TypeSystemCreateInstance create_callback)
> +{
> + if (create_callback)
> + {
> + Mutex::Locker locker (GetTypeSystemMutex ());
> + TypeSystemInstances &instances = GetTypeSystemInstances ();
> +
> + TypeSystemInstances::iterator pos, end = instances.end();
> + for (pos = instances.begin(); pos != end; ++ pos)
> + {
> + if (pos->create_callback == create_callback)
> + {
> + instances.erase(pos);
> + return true;
> + }
> + }
> + }
> + return false;
> +}
> +
> +TypeSystemCreateInstance
> +PluginManager::GetTypeSystemCreateCallbackAtIndex (uint32_t idx)
> +{
> + Mutex::Locker locker (GetTypeSystemMutex ());
> + TypeSystemInstances &instances = GetTypeSystemInstances ();
> + if (idx < instances.size())
> + return instances[idx].create_callback;
> + return NULL;
> +}
> +
> +TypeSystemCreateInstance
> +PluginManager::GetTypeSystemCreateCallbackForPluginName (const
> ConstString &name)
> +{
> + if (name)
> + {
> + Mutex::Locker locker (GetTypeSystemMutex ());
> + TypeSystemInstances &instances = GetTypeSystemInstances ();
> +
> + TypeSystemInstances::iterator pos, end = instances.end();
> + for (pos = instances.begin(); pos != end; ++ pos)
> + {
> + if (name == pos->name)
> + return pos->create_callback;
> + }
> + }
> + return NULL;
> +}
> +
> +
> #pragma mark PluginManager
>
> void
>
> Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
> +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Thu Sep 17 17:23:34
> 2015
> @@ -154,7 +154,7 @@ FixupTypeAndOrName (const TypeAndOrName&
> if (parent.IsPointerType())
> corrected_type = orig_type.GetPointerType ();
> else if (parent.IsPointerOrReferenceType())
> - corrected_type =
> ClangASTContext::GetLValueReferenceType(orig_type);
> + corrected_type = orig_type.GetLValueReferenceType();
> ret.SetCompilerType(corrected_type);
> }
> else /*if (m_dynamic_type_info.HasName())*/
>
> Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
> +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Thu Sep 17 17:23:34 2015
> @@ -319,8 +319,10 @@ ValueObjectRegister::GetCompilerTypeImpl
> Module *exe_module = target->GetExecutableModulePointer();
> if (exe_module)
> {
> - m_clang_type =
> exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize
> (m_reg_info.encoding,
> -
> m_reg_info.byte_size * 8);
> + TypeSystem *type_system =
> exe_module->GetTypeSystemForLanguage (eLanguageTypeC);
> + if (type_system)
> + m_clang_type =
> type_system->GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
> +
> m_reg_info.byte_size * 8);
> }
> }
> }
>
> Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
> +++ lldb/trunk/source/DataFormatters/FormatManager.cpp Thu Sep 17 17:23:34
> 2015
> @@ -229,7 +229,7 @@ FormatManager::GetPossibleMatches (Value
> if (non_ref_type.IsTypedefType())
> {
> CompilerType deffed_referenced_type =
> non_ref_type.GetTypedefedType();
> - deffed_referenced_type = is_rvalue_ref ?
> ClangASTContext::GetRValueReferenceType(deffed_referenced_type) :
> ClangASTContext::GetLValueReferenceType(deffed_referenced_type);
> + deffed_referenced_type = is_rvalue_ref ?
> deffed_referenced_type.GetRValueReferenceType() :
> deffed_referenced_type.GetLValueReferenceType();
> GetPossibleMatches(valobj,
> deffed_referenced_type,
> reason |
> lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
>
> Modified: lldb/trunk/source/DataFormatters/VectorType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/DataFormatters/VectorType.cpp (original)
> +++ lldb/trunk/source/DataFormatters/VectorType.cpp Thu Sep 17 17:23:34
> 2015
> @@ -31,7 +31,7 @@ GetCompilerTypeForFormat (lldb::Format f
> {
> case lldb::eFormatAddressInfo:
> case lldb::eFormatPointer:
> - return
> type_system->GetIntTypeFromBitSize(8*type_system->GetPointerByteSize(),
> false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 8*type_system->GetPointerByteSize());
>
> case lldb::eFormatBoolean:
> return type_system->GetBasicTypeFromAST(lldb::eBasicTypeBool);
> @@ -70,37 +70,37 @@ GetCompilerTypeForFormat (lldb::Format f
> return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar);
>
> case lldb::eFormatVectorOfFloat32:
> - return type_system->GetFloatTypeFromBitSize(32);
> + return
> type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 32);
>
> case lldb::eFormatVectorOfFloat64:
> - return type_system->GetFloatTypeFromBitSize(64);
> + return
> type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 64);
>
> case lldb::eFormatVectorOfSInt16:
> - return type_system->GetIntTypeFromBitSize(16, true);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingSint, 16);
>
> case lldb::eFormatVectorOfSInt32:
> - return type_system->GetIntTypeFromBitSize(32, true);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingSint, 32);
>
> case lldb::eFormatVectorOfSInt64:
> - return type_system->GetIntTypeFromBitSize(64, true);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingSint, 64);
>
> case lldb::eFormatVectorOfSInt8:
> - return type_system->GetIntTypeFromBitSize(8, true);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingSint, 8);
>
> case lldb::eFormatVectorOfUInt128:
> - return type_system->GetIntTypeFromBitSize(128, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 128);
>
> case lldb::eFormatVectorOfUInt16:
> - return type_system->GetIntTypeFromBitSize(16, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 16);
>
> case lldb::eFormatVectorOfUInt32:
> - return type_system->GetIntTypeFromBitSize(32, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 32);
>
> case lldb::eFormatVectorOfUInt64:
> - return type_system->GetIntTypeFromBitSize(64, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 64);
>
> case lldb::eFormatVectorOfUInt8:
> - return type_system->GetIntTypeFromBitSize(8, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 8);
>
> case lldb::eFormatDefault:
> return element_type;
> @@ -113,7 +113,7 @@ GetCompilerTypeForFormat (lldb::Format f
> case lldb::eFormatOSType:
> case lldb::eFormatVoid:
> default:
> - return type_system->GetIntTypeFromBitSize(8, false);
> + return type_system->GetBuiltinTypeForEncodingAndBitSize
> (eEncodingUint, 8);
> }
> }
>
>
> Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
> +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Sep 17
> 17:23:34 2015
> @@ -1678,7 +1678,17 @@ ClangExpressionDeclMap::GetVariableValue
> return false;
> }
>
> - ASTContext *ast = var_type->GetClangASTContext().getASTContext();
> + ClangASTContext *clang_ast =
> llvm::dyn_cast_or_null<ClangASTContext>(var_type->GetForwardCompilerType().GetTypeSystem());
> +
> + if (!clang_ast)
> + {
> + if (log)
> + log->PutCString("Skipped a definition because it has no Clang
> AST");
> + return false;
> + }
> +
> +
> + ASTContext *ast = clang_ast->getASTContext();
>
> if (!ast)
> {
> @@ -1785,7 +1795,7 @@ ClangExpressionDeclMap::AddOneVariable (
> if (is_reference)
> var_decl = context.AddVarDecl(pt);
> else
> - var_decl =
> context.AddVarDecl(ClangASTContext::GetLValueReferenceType(pt));
> + var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
>
> std::string decl_name(context.m_decl_name.getAsString());
> ConstString entity_name(decl_name.c_str());
> @@ -1829,7 +1839,7 @@ ClangExpressionDeclMap::AddOneVariable(N
> return;
> }
>
> - NamedDecl *var_decl =
> context.AddVarDecl(ClangASTContext::GetLValueReferenceType(parser_type));
> + NamedDecl *var_decl =
> context.AddVarDecl(parser_type.GetLValueReferenceType());
>
>
> llvm::cast<ClangExpressionVariable>(pvar_sp.get())->EnableParserVars(GetParserID());
> ClangExpressionVariable::ParserVars *parser_vars =
> llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetParserVars(GetParserID());
> @@ -1861,8 +1871,8 @@ ClangExpressionDeclMap::AddOneGenericVar
>
> ASTContext *scratch_ast_context =
> target->GetScratchClangASTContext()->getASTContext();
>
> - TypeFromUser user_type
> (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(scratch_ast_context,
> eBasicTypeVoid).GetPointerType()));
> - TypeFromParser parser_type
> (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(m_ast_context,
> eBasicTypeVoid).GetPointerType()));
> + TypeFromUser user_type
> (ClangASTContext::GetBasicType(scratch_ast_context,
> eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
> + TypeFromParser parser_type
> (ClangASTContext::GetBasicType(m_ast_context,
> eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
> NamedDecl *var_decl = context.AddVarDecl(parser_type);
>
> std::string decl_name(context.m_decl_name.getAsString());
>
> Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
> +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Sep 17
> 17:23:34 2015
> @@ -28,6 +28,7 @@
> #include "lldb/Expression/IRInterpreter.h"
> #include "lldb/Host/File.h"
> #include "lldb/Host/HostInfo.h"
> +#include "lldb/Symbol/ClangASTContext.h"
> #include "lldb/Symbol/SymbolVendor.h"
> #include "lldb/Target/ExecutionContext.h"
> #include "lldb/Target/ObjCLanguageRuntime.h"
>
> Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
> +++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Thu Sep
> 17 17:23:34 2015
> @@ -13,7 +13,8 @@
> #include "lldb/Host/HostInfo.h"
> #include "lldb/Core/Log.h"
> #include "lldb/Core/Timer.h"
> -
> +#include "lldb/Symbol/GoASTContext.h"
> +#include "lldb/Symbol/ClangASTContext.h"
> #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
> #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
> #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
> @@ -103,6 +104,9 @@ SystemInitializerCommon::Initialize()
> process_gdb_remote::ProcessGDBRemoteLog::Initialize();
>
> // Initialize plug-ins
> + ClangASTContext::Initialize();
> + GoASTContext::Initialize();
> +
> ObjectContainerBSDArchive::Initialize();
> ObjectFileELF::Initialize();
> ObjectFilePECOFF::Initialize();
> @@ -166,6 +170,9 @@ SystemInitializerCommon::Terminate()
> PlatformRemoteiOS::Terminate();
> PlatformiOSSimulator::Terminate();
>
> + ClangASTContext::Terminate();
> + GoASTContext::Terminate();
> +
> EmulateInstructionARM::Terminate();
> EmulateInstructionMIPS::Terminate();
> EmulateInstructionMIPS64::Terminate();
>
> Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Thu Sep 17 17:23:34
> 2015
> @@ -763,7 +763,7 @@ GetNSPathStore2Type (Target &target)
> return CompilerType();
>
> CompilerType voidstar =
> ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
> - CompilerType uint32 = ast_ctx->GetIntTypeFromBitSize(32, false);
> + CompilerType uint32 =
> ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
>
> return ast_ctx->GetOrCreateStructForIdentifier(g_type_name, {
> {"isa",voidstar},
>
> Modified: lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp Thu Sep 17
> 17:23:34 2015
> @@ -30,8 +30,8 @@ lldb_private::formatters::CMTimeSummaryP
> return false;
>
> // fetch children by offset to compensate for potential lack of debug
> info
> - auto int64_ty = type_system->GetIntTypeFromBitSize(64, true);
> - auto int32_ty = type_system->GetIntTypeFromBitSize(32, true);
> + auto int64_ty =
> type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64);
> + auto int32_ty =
> type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 32);
>
> auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true));
> auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty,
> true));
>
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp?rev=247953&r1=247952&r2=247953&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
> (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp Thu
> Sep 17 17:23:34 2015
> @@ -177,7 +177,7 @@ DWARFASTParserGo::ParseTypeFromDWARF(con
> return type->shared_from_this();
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150918/22c0dd72/attachment-0001.html>
More information about the lldb-commits
mailing list