summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBType.cpp45
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp2
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp105
3 files changed, 150 insertions, 2 deletions
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 63c6c0a46cf..e4343fd2cce 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -437,6 +437,50 @@ SBType::GetTypeClass ()
return lldb::eTypeClassInvalid;
}
+uint32_t
+SBType::GetNumberOfTemplateArguments ()
+{
+ if (IsValid())
+ {
+ return ClangASTContext::GetNumTemplateArguments (m_opaque_sp->GetASTContext(),
+ m_opaque_sp->GetOpaqueQualType());
+ }
+ return 0;
+}
+
+lldb::SBType
+SBType::GetTemplateArgumentType (uint32_t idx)
+{
+ if (IsValid())
+ {
+ TemplateArgumentKind kind = eTemplateArgumentKindNull;
+ return SBType(ClangASTType(m_opaque_sp->GetASTContext(),
+ ClangASTContext::GetTemplateArgument(m_opaque_sp->GetASTContext(),
+ m_opaque_sp->GetOpaqueQualType(),
+ idx,
+ kind)));
+ }
+ return SBType();
+}
+
+
+lldb::TemplateArgumentKind
+SBType::GetTemplateArgumentKind (uint32_t idx)
+{
+ TemplateArgumentKind kind = eTemplateArgumentKindNull;
+ if (IsValid())
+ {
+ ClangASTContext::GetTemplateArgument(m_opaque_sp->GetASTContext(),
+ m_opaque_sp->GetOpaqueQualType(),
+ idx,
+ kind);
+ }
+ return kind;
+}
+
+
+
+
SBTypeList::SBTypeList() :
m_opaque_ap(new TypeListImpl())
{
@@ -622,4 +666,3 @@ SBTypeMember::ref () const
{
return *m_opaque_ap.get();
}
-
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 15e66610ef1..d2d355cac41 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -326,7 +326,7 @@ ScriptInterpreterPython::EnterSession ()
// embedded we don't know we should be feeding input to the embedded
// interpreter or to the python sys.stdin. We also don't want to let python
// play with the real stdin from this process, so we need to close it...
- run_string.PutCString ("; sys.stdin.close()");
+ //run_string.PutCString ("; sys.stdin.close()");
run_string.PutCString ("')");
PyRun_SimpleString (run_string.GetData());
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index d07df717992..0449902a193 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2499,6 +2499,111 @@ ClangASTContext::AddMethodToObjCObjectType
return objc_method_decl;
}
+size_t
+ClangASTContext::GetNumTemplateArguments (clang::ASTContext *ast, clang_type_t clang_type)
+{
+ if (clang_type)
+ {
+ QualType qual_type (QualType::getFromOpaquePtr(clang_type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteQualType (ast, qual_type))
+ {
+ const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ const ClassTemplateSpecializationDecl *template_decl = dyn_cast<ClassTemplateSpecializationDecl>(cxx_record_decl);
+ if (template_decl)
+ return template_decl->getTemplateArgs().size();
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return ClangASTContext::GetNumTemplateArguments (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ default:
+ break;
+ }
+ }
+ return 0;
+}
+
+clang_type_t
+ClangASTContext::GetTemplateArgument (clang::ASTContext *ast, clang_type_t clang_type, size_t arg_idx, lldb::TemplateArgumentKind &kind)
+{
+ if (clang_type)
+ {
+ QualType qual_type (QualType::getFromOpaquePtr(clang_type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteQualType (ast, qual_type))
+ {
+ const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ const ClassTemplateSpecializationDecl *template_decl = dyn_cast<ClassTemplateSpecializationDecl>(cxx_record_decl);
+ if (template_decl && arg_idx < template_decl->getTemplateArgs().size())
+ {
+ const TemplateArgument &template_arg = template_decl->getTemplateArgs()[arg_idx];
+ switch (template_arg.getKind())
+ {
+ case clang::TemplateArgument::Null:
+ kind = eTemplateArgumentKindNull;
+ return NULL;
+
+ case clang::TemplateArgument::Type:
+ kind = eTemplateArgumentKindType;
+ return template_arg.getAsType().getAsOpaquePtr();
+
+ case clang::TemplateArgument::Declaration:
+ kind = eTemplateArgumentKindDeclaration;
+ return NULL;
+
+ case clang::TemplateArgument::Integral:
+ kind = eTemplateArgumentKindIntegral;
+ return template_arg.getIntegralType().getAsOpaquePtr();
+
+ case clang::TemplateArgument::Template:
+ kind = eTemplateArgumentKindTemplate;
+ return NULL;
+
+ case clang::TemplateArgument::TemplateExpansion:
+ kind = eTemplateArgumentKindTemplateExpansion;
+ return NULL;
+
+ case clang::TemplateArgument::Expression:
+ kind = eTemplateArgumentKindExpression;
+ return NULL;
+
+ case clang::TemplateArgument::Pack:
+ kind = eTemplateArgumentKindPack;
+ return NULL;
+
+ default:
+ assert (!"Unhandled TemplateArgument::ArgKind");
+ kind = eTemplateArgumentKindNull;
+ return NULL;
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return ClangASTContext::GetTemplateArgument (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), arg_idx, kind);
+ default:
+ break;
+ }
+ }
+ kind = eTemplateArgumentKindNull;
+ return NULL;
+}
uint32_t
ClangASTContext::GetTypeInfo
OpenPOWER on IntegriCloud