summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ASTDumper.cpp3
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp28
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp60
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp2
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp4
-rw-r--r--lldb/source/Expression/IRForTarget.cpp10
6 files changed, 62 insertions, 45 deletions
diff --git a/lldb/source/Expression/ASTDumper.cpp b/lldb/source/Expression/ASTDumper.cpp
index 5210d149e66..80faeb3d5a1 100644
--- a/lldb/source/Expression/ASTDumper.cpp
+++ b/lldb/source/Expression/ASTDumper.cpp
@@ -9,6 +9,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Expression/ASTDumper.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTType.h"
#include "llvm/Support/raw_ostream.h"
@@ -81,7 +82,7 @@ ASTDumper::ASTDumper (lldb::clang_type_t type)
ASTDumper::ASTDumper (const ClangASTType &clang_type)
{
- m_dump = clang_type.GetQualType().getAsString();
+ m_dump = ClangASTContext::GetQualType(clang_type).getAsString();
}
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 32fbb88d8c5..4632d4f452d 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -277,7 +277,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!clang_type)
continue;
- const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
+ const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
if (!tag_type)
continue;
@@ -316,7 +316,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!clang_type)
continue;
- const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
+ const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
if (!tag_type)
continue;
@@ -1881,9 +1881,13 @@ ClangASTSource::GuardedCopyType (const ClangASTType &src_type)
{
ClangASTMetrics::RegisterLLDBImport();
+ ClangASTContext* src_ast = src_type.GetTypeSystem()->AsClangASTContext();
+ if (!src_ast)
+ return ClangASTType();
+
SetImportInProgress(true);
- QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType());
+ QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_ast->getASTContext(), ClangASTContext::GetQualType(src_type));
SetImportInProgress(false);
@@ -1903,16 +1907,20 @@ NameSearchContext::AddVarDecl(const ClangASTType &type)
if (!type.IsValid())
return NULL;
+ ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
+ if (!lldb_ast)
+ return NULL;
+
IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
- clang::ASTContext *ast = type.GetASTContext();
+ clang::ASTContext *ast = lldb_ast->getASTContext();
clang::NamedDecl *Decl = VarDecl::Create(*ast,
const_cast<DeclContext*>(m_decl_context),
SourceLocation(),
SourceLocation(),
ii,
- type.GetQualType(),
+ ClangASTContext::GetQualType(type),
0,
SC_Static);
m_decls.push_back(Decl);
@@ -1930,12 +1938,16 @@ NameSearchContext::AddFunDecl (const ClangASTType &type, bool extern_c)
if (m_function_types.count(type))
return NULL;
+
+ ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
+ if (!lldb_ast)
+ return NULL;
m_function_types.insert(type);
- QualType qual_type (type.GetQualType());
+ QualType qual_type (ClangASTContext::GetQualType(type));
- clang::ASTContext *ast = type.GetASTContext();
+ clang::ASTContext *ast = lldb_ast->getASTContext();
const bool isInlineSpecified = false;
const bool hasWrittenPrototype = true;
@@ -2026,7 +2038,7 @@ NameSearchContext::AddTypeDecl(const ClangASTType &clang_type)
{
if (clang_type)
{
- QualType qual_type = clang_type.GetQualType();
+ QualType qual_type = ClangASTContext::GetQualType(clang_type);
if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
{
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 2c66a0aa427..b719e0663e3 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -201,10 +201,10 @@ ClangExpressionDeclMap::AddPersistentVariable
if (target == NULL)
return false;
- ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
+ ClangASTContext *context(target->GetScratchClangASTContext());
- TypeFromUser user_type(m_ast_importer->DeportType(context,
- parser_type.GetASTContext(),
+ TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
+ parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
parser_type.GetOpaqueQualType()),
context);
@@ -241,10 +241,10 @@ ClangExpressionDeclMap::AddPersistentVariable
if (target == NULL)
return false;
- ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
+ ClangASTContext *context(target->GetScratchClangASTContext());
- TypeFromUser user_type(m_ast_importer->DeportType(context,
- parser_type.GetASTContext(),
+ TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
+ parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
parser_type.GetOpaqueQualType()),
context);
@@ -1038,7 +1038,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
- &class_decl->getASTContext());
+ ClangASTContext::GetASTContext(&class_decl->getASTContext()));
if (log)
{
@@ -1076,7 +1076,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1166,7 +1166,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
return; // This is unlikely, but we have seen crashes where this occurred
TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
if (log)
{
@@ -1183,7 +1183,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1193,7 +1193,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_type = method_decl->getASTContext().getObjCClassType();
TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1222,11 +1222,11 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
ClangASTType self_clang_type = self_type->GetClangFullType();
- if (self_clang_type.IsObjCClassType())
+ if (ClangASTContext::IsObjCClassType(self_clang_type))
{
return;
}
- else if (self_clang_type.IsObjCObjectPointerType())
+ else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
{
self_clang_type = self_clang_type.GetPointeeType();
@@ -1748,7 +1748,7 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v
if (is_reference)
var_decl = context.AddVarDecl(pt);
else
- var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
+ var_decl = context.AddVarDecl(ClangASTContext::GetLValueReferenceType(pt));
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
@@ -1792,7 +1792,7 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
return;
}
- NamedDecl *var_decl = context.AddVarDecl(parser_type.GetLValueReferenceType());
+ NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::GetLValueReferenceType(parser_type));
pvar_sp->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
@@ -1824,8 +1824,8 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
- TypeFromUser user_type (ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
- TypeFromParser parser_type (ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
+ TypeFromUser user_type (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType()));
+ TypeFromParser parser_type (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType()));
NamedDecl *var_decl = context.AddVarDecl(parser_type);
std::string decl_name(context.m_decl_name.getAsString());
@@ -1867,7 +1867,7 @@ ClangExpressionDeclMap::ResolveUnknownTypes()
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
- ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
+ ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext();
for (size_t index = 0, num_entities = m_found_entities.GetSize();
index < num_entities;
@@ -1896,9 +1896,9 @@ ClangExpressionDeclMap::ResolveUnknownTypes()
}
QualType var_type = var_decl->getType();
- TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
+ TypeFromParser parser_type(var_type.getAsOpaquePtr(), ClangASTContext::GetASTContext(&var_decl->getASTContext()));
- lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
+ lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context->getASTContext(), &var_decl->getASTContext(), var_type.getAsOpaquePtr());
if (!copied_type)
{
@@ -2136,15 +2136,17 @@ ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
const bool is_attr_used = true;
const bool is_artificial = false;
- copied_clang_type.AddMethodToCXXRecordType ("$__lldb_expr",
- method_type,
- lldb::eAccessPublic,
- is_virtual,
- is_static,
- is_inline,
- is_explicit,
- is_attr_used,
- is_artificial);
+ ClangASTContext::GetASTContext(m_ast_context)->
+ AddMethodToCXXRecordType (copied_clang_type.GetOpaqueQualType(),
+ "$__lldb_expr",
+ method_type,
+ lldb::eAccessPublic,
+ is_virtual,
+ is_static,
+ is_inline,
+ is_explicit,
+ is_attr_used,
+ is_artificial);
}
return TypeFromParser(copied_clang_type);
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index d59e8e06f32..0e5e3f9c123 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -334,6 +334,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
ast_context->setExternalSource(ast_source);
}
+ m_ast_context.reset(new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
+ m_ast_context->setASTContext(ast_context.get());
m_compiler->setASTContext(ast_context.release());
std::string module_name("$__lldb_module");
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index 0da70e2b0a7..290b093e8b5 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -313,11 +313,11 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err)
return;
}
- if (self_clang_type.IsObjCClassType())
+ if (ClangASTContext::IsObjCClassType(self_clang_type))
{
return;
}
- else if (self_clang_type.IsObjCObjectPointerType())
+ else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
{
m_in_objectivec_method = true;
m_needs_object_ptr = true;
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp
index cf2a93b3ea7..9db827862f3 100644
--- a/lldb/source/Expression/IRForTarget.cpp
+++ b/lldb/source/Expression/IRForTarget.cpp
@@ -575,14 +575,14 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
else if (pointer_objcobjpointertype)
{
clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
else
{
@@ -598,7 +598,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
else
{
m_result_type = lldb_private::TypeFromParser(result_var->getType().getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
@@ -1241,7 +1241,7 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc)
clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
lldb_private::TypeFromParser result_decl_type (decl->getType().getAsOpaquePtr(),
- &decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&decl->getASTContext()));
StringRef decl_name (decl->getName());
lldb_private::ConstString persistent_variable_name (decl_name.data(), decl_name.size());
@@ -1539,7 +1539,7 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
{
log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
name.c_str(),
- clang_type.GetQualType().getAsString().c_str(),
+ lldb_private::ClangASTContext::GetQualType(clang_type).getAsString().c_str(),
PrintType(value_type).c_str(),
value_size,
value_alignment);
OpenPOWER on IntegriCloud