本文整理汇总了C++中TargetSP::GetScratchClangASTContext方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetSP::GetScratchClangASTContext方法的具体用法?C++ TargetSP::GetScratchClangASTContext怎么用?C++ TargetSP::GetScratchClangASTContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetSP
的用法示例。
在下文中一共展示了TargetSP::GetScratchClangASTContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g___lldb_autogen_nspair
static ClangASTType
GetLLDBNSPairType (TargetSP target_sp)
{
ClangASTType clang_type;
ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
if (target_ast_context)
{
ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair");
clang_type = target_ast_context->GetTypeForIdentifier<clang::CXXRecordDecl>(g___lldb_autogen_nspair);
if (!clang_type)
{
clang_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(), 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();
}
}
}
return clang_type;
}
示例2:
static ClangASTType
GetLLDBNSPairType (TargetSP target_sp)
{
ClangASTType clang_type;
ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
if (target_ast_context)
{
clang::ASTContext *ast = target_ast_context->getASTContext();
if (ast)
{
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();
}
}
}
}
return clang_type;
}