[Lldb-commits] [lldb] r280151 - Add SBType::GetArrayType() such that - given a type - one can make an array (of a given size) of that type
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 30 14:29:56 PDT 2016
Is there going to be a test for this?
On Tue, Aug 30, 2016 at 1:48 PM Enrico Granata via lldb-commits <
lldb-commits at lists.llvm.org> wrote:
> Author: enrico
> Date: Tue Aug 30 15:39:58 2016
> New Revision: 280151
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280151&view=rev
> Log:
> Add SBType::GetArrayType() such that - given a type - one can make an
> array (of a given size) of that type
>
> This is currently only implemented for the clang-based TypeSystem, but
> other languages are welcome to jump in!
>
>
> Modified:
> lldb/trunk/include/lldb/API/SBType.h
> lldb/trunk/include/lldb/Symbol/ClangASTContext.h
> lldb/trunk/include/lldb/Symbol/CompilerType.h
> lldb/trunk/include/lldb/Symbol/TypeSystem.h
> lldb/trunk/scripts/interface/SBType.i
> lldb/trunk/source/API/SBType.cpp
> lldb/trunk/source/Symbol/ClangASTContext.cpp
> lldb/trunk/source/Symbol/CompilerType.cpp
> lldb/trunk/source/Symbol/TypeSystem.cpp
>
> Modified: lldb/trunk/include/lldb/API/SBType.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/API/SBType.h (original)
> +++ lldb/trunk/include/lldb/API/SBType.h Tue Aug 30 15:39:58 2016
> @@ -189,6 +189,9 @@ public:
> GetArrayElementType ();
>
> lldb::SBType
> + GetArrayType (uint64_t size);
> +
> + lldb::SBType
> GetVectorElementType ();
>
> lldb::SBType
>
> Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
> +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Aug 30 15:39:58
> 2016
> @@ -790,6 +790,9 @@ public:
> GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t
> *stride) override;
>
> CompilerType
> + GetArrayType (lldb::opaque_compiler_type_t type, uint64_t size)
> override;
> +
> + CompilerType
> GetCanonicalType (lldb::opaque_compiler_type_t type) override;
>
> CompilerType
>
> Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
> +++ lldb/trunk/include/lldb/Symbol/CompilerType.h Tue Aug 30 15:39:58 2016
> @@ -269,6 +269,9 @@ public:
> GetArrayElementType(uint64_t *stride = nullptr) const;
>
> CompilerType
> + GetArrayType (uint64_t size) const;
> +
> + CompilerType
> GetCanonicalType () const;
>
> CompilerType
>
> Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
> +++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Tue Aug 30 15:39:58 2016
> @@ -274,6 +274,9 @@ public:
> GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t
> *stride) = 0;
>
> virtual CompilerType
> + GetArrayType (lldb::opaque_compiler_type_t type, uint64_t size);
> +
> + virtual CompilerType
> GetCanonicalType (lldb::opaque_compiler_type_t type) = 0;
>
> // Returns -1 if this isn't a function of if the function doesn't
> have a prototype
>
> Modified: lldb/trunk/scripts/interface/SBType.i
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBType.i?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/scripts/interface/SBType.i (original)
> +++ lldb/trunk/scripts/interface/SBType.i Tue Aug 30 15:39:58 2016
> @@ -247,6 +247,9 @@ public:
>
> lldb::SBType
> GetArrayElementType ();
> +
> + lldb::SBType
> + GetArrayType (uint64_t size);
>
> lldb::SBType
> GetVectorElementType ();
>
> Modified: lldb/trunk/source/API/SBType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/API/SBType.cpp (original)
> +++ lldb/trunk/source/API/SBType.cpp Tue Aug 30 15:39:58 2016
> @@ -229,6 +229,14 @@ SBType::GetArrayElementType()
> }
>
> SBType
> +SBType::GetArrayType (uint64_t size)
> +{
> + if (!IsValid())
> + return SBType();
> + return SBType(TypeImplSP(new
> TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))));
> +}
> +
> +SBType
> SBType::GetVectorElementType ()
> {
> SBType type_sb;
>
> Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
> +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Aug 30 15:39:58 2016
> @@ -4566,6 +4566,24 @@ ClangASTContext::GetArrayElementType (ll
> }
>
> CompilerType
> +ClangASTContext::GetArrayType (lldb::opaque_compiler_type_t type,
> uint64_t size)
> +{
> + if (type)
> + {
> + clang::QualType qual_type(GetCanonicalQualType(type));
> + if (clang::ASTContext *ast_ctx = getASTContext())
> + {
> + if (size == 0)
> + return CompilerType (ast_ctx,
> ast_ctx->getConstantArrayType(qual_type, llvm::APInt(64, size),
> clang::ArrayType::ArraySizeModifier::Normal, 0));
> + else
> + return CompilerType (ast_ctx,
> ast_ctx->getIncompleteArrayType(qual_type,
> clang::ArrayType::ArraySizeModifier::Normal, 0));
> + }
> + }
> +
> + return CompilerType();
> +}
> +
> +CompilerType
> ClangASTContext::GetCanonicalType (lldb::opaque_compiler_type_t type)
> {
> if (type)
>
> Modified: lldb/trunk/source/Symbol/CompilerType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerType.cpp?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Symbol/CompilerType.cpp (original)
> +++ lldb/trunk/source/Symbol/CompilerType.cpp Tue Aug 30 15:39:58 2016
> @@ -467,7 +467,16 @@ CompilerType::GetArrayElementType (uint6
> if (IsValid())
> {
> return m_type_system->GetArrayElementType(m_type, stride);
> -
> + }
> + return CompilerType();
> +}
> +
> +CompilerType
> +CompilerType::GetArrayType (uint64_t size) const
> +{
> + if (IsValid())
> + {
> + return m_type_system->GetArrayType(m_type, size);
> }
> return CompilerType();
> }
>
> Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=280151&r1=280150&r2=280151&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
> +++ lldb/trunk/source/Symbol/TypeSystem.cpp Tue Aug 30 15:39:58 2016
> @@ -62,6 +62,12 @@ TypeSystem::IsAnonymousType (lldb::opaqu
> }
>
> CompilerType
> +TypeSystem::GetArrayType (lldb::opaque_compiler_type_t type, uint64_t
> size)
> +{
> + return CompilerType();
> +}
> +
> +CompilerType
> TypeSystem::GetLValueReferenceType (lldb::opaque_compiler_type_t type)
> {
> return CompilerType();
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160830/f7d4a16a/attachment.html>
More information about the lldb-commits
mailing list