summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangASTSource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression/ClangASTSource.cpp')
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp90
1 files changed, 46 insertions, 44 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 0fc3db61b8b..49513d740f3 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -238,12 +238,12 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!type)
continue;
- lldb::clang_type_t opaque_type = type->GetClangFullType();
+ ClangASTType clang_type (type->GetClangFullType());
- if (!opaque_type)
+ if (!clang_type)
continue;
- const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>();
+ const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
if (!tag_type)
continue;
@@ -277,12 +277,12 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!type)
continue;
- lldb::clang_type_t opaque_type = type->GetClangFullType();
+ ClangASTType clang_type (type->GetClangFullType());
- if (!opaque_type)
+ if (!clang_type)
continue;
- const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>();
+ const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
if (!tag_type)
continue;
@@ -346,7 +346,7 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de
if (!complete_type_sp)
return NULL;
- TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType(), complete_type_sp->GetClangAST());
+ TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType());
lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
if (!complete_opaque_type)
@@ -696,12 +696,11 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
(name_string ? name_string : "<anonymous>"));
}
- clang::ASTContext *type_ast = type_sp->GetClangAST();
- lldb::clang_type_t full_type = type_sp->GetClangFullType();
+ ClangASTType full_type = type_sp->GetClangFullType();
- void *copied_type = GuardedCopyType(m_ast_context, type_ast, full_type);
+ ClangASTType copied_clang_type (GuardedCopyType(full_type));
- if (!copied_type)
+ if (!copied_clang_type)
{
if (log)
log->Printf(" CAS::FEVD[%u] - Couldn't export a type",
@@ -710,7 +709,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
break;
}
- context.AddTypeDecl(copied_type);
+ context.AddTypeDecl(copied_clang_type);
}
else
{
@@ -750,13 +749,9 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
name.GetCString());
}
- const clang::Type *runtime_clang_type = QualType::getFromOpaquePtr(types[0].GetOpaqueQualType()).getTypePtr();
+ ClangASTType copied_clang_type (GuardedCopyType(types[0]));
- clang::QualType runtime_qual_type(runtime_clang_type, 0);
-
- void *copied_type = GuardedCopyType(m_ast_context, type_vendor->GetClangASTContext(), runtime_qual_type.getAsOpaquePtr());
-
- if (!copied_type)
+ if (!copied_clang_type)
{
if (log)
log->Printf(" CAS::FEVD[%u] - Couldn't export a type from the runtime",
@@ -765,7 +760,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
break;
}
- context.AddTypeDecl(copied_type);
+ context.AddTypeDecl(copied_clang_type);
}
while(0);
}
@@ -1688,42 +1683,43 @@ ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::Name
return dyn_cast<NamespaceDecl>(copied_decl);
}
-void *
-ClangASTSource::GuardedCopyType (ASTContext *dest_context,
- ASTContext *source_context,
- void *clang_type)
+ClangASTType
+ClangASTSource::GuardedCopyType (const ClangASTType &src_type)
{
ClangASTMetrics::RegisterLLDBImport();
SetImportInProgress(true);
- QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type));
-
- void *ret = ret_qual_type.getAsOpaquePtr();
+ QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType());
SetImportInProgress(false);
- if (ret && ret_qual_type->getCanonicalTypeInternal().isNull())
+ if (copied_qual_type.getAsOpaquePtr() && copied_qual_type->getCanonicalTypeInternal().isNull())
// this shouldn't happen, but we're hardening because the AST importer seems to be generating bad types
// on occasion.
- return NULL;
+ return ClangASTType();
- return ret;
+ return ClangASTType(m_ast_context, copied_qual_type);
}
clang::NamedDecl *
-NameSearchContext::AddVarDecl(void *type)
+NameSearchContext::AddVarDecl(const ClangASTType &type)
{
+ assert (type && "Type for variable must be valid!");
+
+ if (!type.IsValid())
+ return NULL;
+
IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
- assert (type && "Type for variable must be non-NULL!");
-
- clang::NamedDecl *Decl = VarDecl::Create(*m_ast_source.m_ast_context,
+ clang::ASTContext *ast = type.GetASTContext();
+
+ clang::NamedDecl *Decl = VarDecl::Create(*ast,
const_cast<DeclContext*>(m_decl_context),
SourceLocation(),
SourceLocation(),
ii,
- QualType::getFromOpaquePtr(type),
+ type.GetQualType(),
0,
SC_Static);
m_decls.push_back(Decl);
@@ -1732,25 +1728,32 @@ NameSearchContext::AddVarDecl(void *type)
}
clang::NamedDecl *
-NameSearchContext::AddFunDecl (void *type)
+NameSearchContext::AddFunDecl (const ClangASTType &type)
{
- assert (type && "Type for variable must be non-NULL!");
+ assert (type && "Type for variable must be valid!");
+ if (!type.IsValid())
+ return NULL;
+
if (m_function_types.count(type))
return NULL;
m_function_types.insert(type);
+ QualType qual_type (type.GetQualType());
+
+ clang::ASTContext *ast = type.GetASTContext();
+
const bool isInlineSpecified = false;
const bool hasWrittenPrototype = true;
const bool isConstexprSpecified = false;
- clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context,
+ clang::FunctionDecl *func_decl = FunctionDecl::Create (*ast,
const_cast<DeclContext*>(m_decl_context),
SourceLocation(),
SourceLocation(),
m_decl_name.getAsIdentifierInfo(),
- QualType::getFromOpaquePtr(type),
+ qual_type,
NULL,
SC_Static,
isInlineSpecified,
@@ -1761,7 +1764,6 @@ NameSearchContext::AddFunDecl (void *type)
// synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do
// this, we raid the function's FunctionProtoType for types.
- QualType qual_type (QualType::getFromOpaquePtr(type));
const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs<FunctionProtoType>();
if (func_proto_type)
@@ -1775,7 +1777,7 @@ NameSearchContext::AddFunDecl (void *type)
{
QualType arg_qual_type (func_proto_type->getArgType(ArgIndex));
- parm_var_decls.push_back(ParmVarDecl::Create (*m_ast_source.m_ast_context,
+ parm_var_decls.push_back(ParmVarDecl::Create (*ast,
const_cast<DeclContext*>(m_decl_context),
SourceLocation(),
SourceLocation(),
@@ -1812,15 +1814,15 @@ NameSearchContext::AddGenericFunDecl()
ArrayRef<QualType>(), // argument types
proto_info));
- return AddFunDecl(generic_function_type.getAsOpaquePtr());
+ return AddFunDecl(ClangASTType (m_ast_source.m_ast_context, generic_function_type));
}
clang::NamedDecl *
-NameSearchContext::AddTypeDecl(void *type)
+NameSearchContext::AddTypeDecl(const ClangASTType &clang_type)
{
- if (type)
+ if (clang_type)
{
- QualType qual_type = QualType::getFromOpaquePtr(type);
+ QualType qual_type = clang_type.GetQualType();
if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
{
OpenPOWER on IntegriCloud