summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/NSDictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/DataFormatters/NSDictionary.cpp')
-rw-r--r--lldb/source/DataFormatters/NSDictionary.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/lldb/source/DataFormatters/NSDictionary.cpp b/lldb/source/DataFormatters/NSDictionary.cpp
index c9fef4288c0..05a5dda39e5 100644
--- a/lldb/source/DataFormatters/NSDictionary.cpp
+++ b/lldb/source/DataFormatters/NSDictionary.cpp
@@ -30,52 +30,52 @@ using namespace lldb_private::formatters;
static ClangASTType
GetLLDBNSPairType (TargetSP target_sp)
{
- ClangASTType clang_type = ClangASTType();
+ ClangASTType clang_type;
ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
- if (!target_ast_context)
- return clang_type;
-
- const char* type_name = "__lldb_autogen_nspair";
-
- clang::IdentifierInfo &myIdent = target_ast_context->getASTContext()->Idents.get(type_name);
- clang::DeclarationName myName = target_ast_context->getASTContext()->DeclarationNames.getIdentifier(&myIdent);
-
- clang::DeclContext::lookup_const_result result = target_ast_context->getASTContext()->getTranslationUnitDecl()->lookup(myName);
-
- clang_type_t opaque_type = NULL;
-
- for (clang::NamedDecl *named_decl : result)
+ if (target_ast_context)
{
- if (const clang::CXXRecordDecl *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(named_decl))
- {
- opaque_type = clang::QualType(record_decl->getTypeForDecl(), 0).getAsOpaquePtr();
- break;
- }
- else
+ clang::ASTContext *ast = target_ast_context->getASTContext();
+
+ if (ast)
{
- // somebody else (the user?) has defined a type with the magic name already - fail!!!
- return clang_type;
+ const char* type_name = "__lldb_autogen_nspair";
+
+ clang::IdentifierInfo &myIdent = ast->Idents.get(type_name);
+ clang::DeclarationName myName = ast->DeclarationNames.getIdentifier(&myIdent);
+
+ clang::DeclContext::lookup_const_result result = ast->getTranslationUnitDecl()->lookup(myName);
+
+ for (clang::NamedDecl *named_decl : result)
+ {
+ if (const clang::CXXRecordDecl *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(named_decl))
+ {
+ clang_type.SetClangType(ast, clang::QualType(record_decl->getTypeForDecl(), 0));
+ break;
+ }
+ else
+ {
+ // somebody else (the user?) has defined a type with the magic name already - fail!!!
+ return clang_type;
+ }
+ }
+
+ if (!clang_type)
+ {
+ clang_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, type_name, clang::TTK_Struct, lldb::eLanguageTypeC);
+
+ if (clang_type)
+ {
+ clang_type.StartTagDeclarationDefinition();
+ ClangASTType id_clang_type = target_ast_context->GetBasicType (eBasicTypeObjCID);
+ clang_type.AddFieldToRecordType("key", id_clang_type, lldb::eAccessPublic, 0);
+ clang_type.AddFieldToRecordType("value", id_clang_type, lldb::eAccessPublic, 0);
+ clang_type.CompleteTagDeclarationDefinition();
+ }
+ }
}
}
-
- if (!opaque_type)
- {
- opaque_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, type_name, clang::TTK_Struct, lldb::eLanguageTypeC);
-
- if (!opaque_type)
- return clang_type;
-
- target_ast_context->StartTagDeclarationDefinition(opaque_type);
-
- target_ast_context->AddFieldToRecordType(opaque_type, "key", target_ast_context->GetBuiltInType_objc_id(), lldb::eAccessPublic, 0);
- target_ast_context->AddFieldToRecordType(opaque_type, "value", target_ast_context->GetBuiltInType_objc_id(), lldb::eAccessPublic, 0);
-
- target_ast_context->CompleteTagDeclarationDefinition(opaque_type);
- }
-
- clang_type.SetClangType(target_ast_context->getASTContext(), opaque_type);
return clang_type;
}
OpenPOWER on IntegriCloud