Index: source/Plugins/SymbolFile/PDB/PDBASTParser.h =================================================================== --- source/Plugins/SymbolFile/PDB/PDBASTParser.h +++ source/Plugins/SymbolFile/PDB/PDBASTParser.h @@ -54,7 +54,7 @@ virtual lldb_private::CompilerDeclContext GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol) = 0; - virtual clang::DeclContext * + virtual lldb_private::CompilerDeclContext GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol) = 0; virtual void Index: source/Plugins/SymbolFile/PDB/PDBASTParserClang.h =================================================================== --- source/Plugins/SymbolFile/PDB/PDBASTParserClang.h +++ source/Plugins/SymbolFile/PDB/PDBASTParserClang.h @@ -54,7 +54,7 @@ lldb_private::CompilerDeclContext GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol) override; - clang::DeclContext * + lldb_private::CompilerDeclContext GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol) override; void ParseDeclsForDeclContext(const clang::DeclContext *decl_context) override; Index: source/Plugins/SymbolFile/PDB/PDBASTParserClang.cpp =================================================================== --- source/Plugins/SymbolFile/PDB/PDBASTParserClang.cpp +++ source/Plugins/SymbolFile/PDB/PDBASTParserClang.cpp @@ -392,7 +392,9 @@ if (name.empty()) return nullptr; - auto decl_context = GetDeclContextContainingSymbol(type); + auto comp_decl_context = GetDeclContextContainingSymbol(type); + auto decl_context = static_cast( + comp_decl_context.GetOpaqueDeclContext()); // Check if such an UDT already exists in the current context. // This may occur with const or volatile types. There are separate type @@ -468,7 +470,9 @@ std::string name = MSVCUndecoratedNameParser::DropScope(enum_type->getName()); - auto decl_context = GetDeclContextContainingSymbol(type); + auto comp_decl_context = GetDeclContextContainingSymbol(type); + auto decl_context = static_cast( + comp_decl_context.GetOpaqueDeclContext()); uint64_t bytes = enum_type->getLength(); // Check if such an enum already exists in the current context @@ -541,7 +545,9 @@ std::string name = MSVCUndecoratedNameParser::DropScope(type_def->getName()); - auto decl_ctx = GetDeclContextContainingSymbol(type); + auto comp_decl_ctx = GetDeclContextContainingSymbol(type); + auto decl_ctx = + static_cast(comp_decl_ctx.GetOpaqueDeclContext()); // Check if such a typedef already exists in the current context CompilerType ast_typedef = @@ -878,7 +884,9 @@ auto data = llvm::dyn_cast(&symbol); assert(data); - auto decl_context = GetDeclContextContainingSymbol(symbol); + auto comp_decl_context = GetDeclContextContainingSymbol(symbol); + auto decl_context = static_cast( + comp_decl_context.GetOpaqueDeclContext()); assert(decl_context); // May be the current context is a class really, but we haven't found @@ -912,7 +920,9 @@ auto func = llvm::dyn_cast(&symbol); assert(func); - auto decl_context = GetDeclContextContainingSymbol(symbol); + auto comp_decl_context = GetDeclContextContainingSymbol(symbol); + auto decl_context = static_cast( + comp_decl_context.GetOpaqueDeclContext()); assert(decl_context); std::string name = MSVCUndecoratedNameParser::DropScope(func->getName()); @@ -996,13 +1006,13 @@ return CompilerDeclContext(&m_ast, result); } -clang::DeclContext *PDBASTParserClang::GetDeclContextContainingSymbol( +lldb_private::CompilerDeclContext +PDBASTParserClang::GetDeclContextContainingSymbol( const llvm::pdb::PDBSymbol &symbol) { auto parent = GetClassOrFunctionParent(symbol); while (parent) { if (auto parent_context = GetDeclContextForSymbol(*parent)) - return static_cast( - parent_context.GetOpaqueDeclContext()); + return parent_context; parent = GetClassOrFunctionParent(*parent); } @@ -1018,15 +1028,15 @@ MSVCUndecoratedNameParser parser(name); llvm::ArrayRef specs = parser.GetSpecifiers(); if (specs.empty()) - return m_ast.GetTranslationUnitDecl(); + return CompilerDeclContext(&m_ast, m_ast.GetTranslationUnitDecl()); auto symbol_file = static_cast(m_ast.GetSymbolFile()); if (!symbol_file) - return m_ast.GetTranslationUnitDecl(); + return CompilerDeclContext(&m_ast, m_ast.GetTranslationUnitDecl()); auto global = symbol_file->GetPDBSession().getGlobalScope(); if (!global) - return m_ast.GetTranslationUnitDecl(); + return CompilerDeclContext(&m_ast, m_ast.GetTranslationUnitDecl()); bool has_type_or_function_parent = false; clang::DeclContext *curr_context = m_ast.GetTranslationUnitDecl(); @@ -1069,7 +1079,7 @@ } } - return curr_context; + return CompilerDeclContext(&m_ast, curr_context); } void PDBASTParserClang::ParseDeclsForDeclContext( Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -650,7 +650,7 @@ auto decl_context = pdb->GetDeclContextContainingSymbol(*symbol); assert(decl_context); - return CompilerDeclContext(clang_ast_ctx, decl_context); + return decl_context; } void SymbolFilePDB::ParseDeclsForContext(