// CompilerDeclContext override functions
+ /// Creates a CompilerDeclContext from the given DeclContext
+ /// with the current ClangASTContext instance as its typesystem.
+ /// The DeclContext has to come from the ASTContext of this
+ /// ClangASTContext.
+ CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
+
std::vector<CompilerDecl>
DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
const bool ignore_using_decls) override;
dyn_cast<NamespaceDecl>(context.m_decl_context)) {
if (namespace_context->getName().str() ==
std::string(g_lldb_local_vars_namespace_cstr)) {
- CompilerDeclContext compiler_decl_ctx(
- GetClangASTContext(), const_cast<void *>(static_cast<const void *>(
- context.m_decl_context)));
+ CompilerDeclContext compiler_decl_ctx = GetClangASTContext()->CreateDeclContext(const_cast<clang::DeclContext*>(context.m_decl_context));
FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
current_id);
return;
DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const DWARFDIE &die) {
clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
if (clang_decl_ctx)
- return CompilerDeclContext(&m_ast, clang_decl_ctx);
+ return m_ast.CreateDeclContext(clang_decl_ctx);
return CompilerDeclContext();
}
clang::DeclContext *clang_decl_ctx =
GetClangDeclContextContainingDIE(die, nullptr);
if (clang_decl_ctx)
- return CompilerDeclContext(&m_ast, clang_decl_ctx);
+ return m_ast.CreateDeclContext(clang_decl_ctx);
return CompilerDeclContext();
}
CompilerDeclContext
PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext &context) {
- return {&m_clang, &context};
+ return m_clang.CreateDeclContext(&context);
}
clang::Decl * PdbAstBuilder::FromCompilerDecl(CompilerDecl decl) {
CompilerType target_ast_type = target_type->GetFullCompilerType();
ast_typedef = m_ast.CreateTypedefType(
- target_ast_type, name.c_str(), CompilerDeclContext(&m_ast, decl_ctx));
+ target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx));
if (!ast_typedef)
return nullptr;
if (!decl_context)
return GetDeclContextContainingUID(uid);
- return CompilerDeclContext(clang_ast_ctx, decl_context);
+ return clang_ast_ctx->CreateDeclContext(decl_context);
}
lldb_private::CompilerDeclContext
auto decl_context = pdb->GetDeclContextContainingSymbol(*symbol);
assert(decl_context);
- return CompilerDeclContext(clang_ast_ctx, decl_context);
+ return clang_ast_ctx->CreateDeclContext(decl_context);
}
void SymbolFilePDB::ParseDeclsForContext(
if (!namespace_decl)
return CompilerDeclContext();
- return CompilerDeclContext(clang_type_system,
- static_cast<clang::DeclContext *>(namespace_decl));
+ return clang_type_system->CreateDeclContext(namespace_decl);
}
lldb_private::ConstString SymbolFilePDB::GetPluginName() {
return CompilerType();
}
+CompilerDeclContext ClangASTContext::CreateDeclContext(DeclContext *ctx) {
+ return CompilerDeclContext(this, ctx);
+}
+
CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
if (clang::ObjCInterfaceDecl *interface_decl =
- llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
+ llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
return GetTypeForDecl(interface_decl);
if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
return GetTypeForDecl(tag_decl);
CompilerDeclContext ClangASTContext::DeclGetDeclContext(void *opaque_decl) {
if (opaque_decl)
- return CompilerDeclContext(this,
- ((clang::Decl *)opaque_decl)->getDeclContext());
- else
- return CompilerDeclContext();
+ return CreateDeclContext(((clang::Decl *)opaque_decl)->getDeclContext());
+ return CompilerDeclContext();
}
CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) {
if (!searched.insert(it->second).second)
continue;
symbol_file->ParseDeclsForContext(
- CompilerDeclContext(this, it->second));
+ CreateDeclContext(it->second));
for (clang::Decl *child : it->second->decls()) {
if (clang::UsingDirectiveDecl *ud =
searched.insert(it->second);
symbol_file->ParseDeclsForContext(
- CompilerDeclContext(this, it->second));
+ CreateDeclContext(it->second));
for (clang::Decl *child : it->second->decls()) {
if (clang::UsingDirectiveDecl *ud =
// typedef foo<int, 47> foo_def;
CompilerType typedef_type = m_ast->CreateTypedefType(
- type, "foo_def",
- CompilerDeclContext(m_ast.get(), m_ast->GetTranslationUnitDecl()));
+ type, "foo_def", m_ast->CreateDeclContext(m_ast->GetTranslationUnitDecl()));
CompilerType auto_type(
m_ast.get(),
for (int i = 0; i < 4; ++i)
ast_parser.LinkDeclContextToDIE(decl_ctxs[i], dies[i]);
ast_parser.EnsureAllDIEsInDeclContextHaveBeenParsed(
- CompilerDeclContext(nullptr, decl_ctxs[1]));
+ ast_ctx.CreateDeclContext(decl_ctxs[1]));
EXPECT_THAT(ast_parser.GetDeclContextToDIEMapKeys(),
testing::UnorderedElementsAre(decl_ctxs[0], decl_ctxs[3]));