Index: source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h =================================================================== --- source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h +++ source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h @@ -56,7 +56,7 @@ lldb_private::CompilerDeclContext GetTranslationUnitDecl(); lldb_private::CompilerDecl GetOrCreateDeclForUid(PdbSymUid uid); - clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid); + lldb_private::CompilerDeclContext GetOrCreateDeclContextForUid(PdbSymUid uid); clang::DeclContext *GetParentDeclContext(PdbSymUid uid); clang::FunctionDecl *GetOrCreateFunctionDecl(PdbCompilandSymId func_id); Index: source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp =================================================================== --- source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -494,22 +494,24 @@ return decl; } -clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) { +lldb_private::CompilerDeclContext +PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) { if (uid.kind() == PdbSymUidKind::CompilandSym) { if (uid.asCompilandSym().offset == 0) { auto decl_ctx = GetTranslationUnitDecl(); auto context = static_cast(decl_ctx.GetOpaqueDeclContext()); - return context; + return CompilerDeclContext(&m_clang, context); } } lldb_private::CompilerDecl decl = GetOrCreateDeclForUid(uid); if (!decl) - return nullptr; + return CompilerDeclContext(); auto clang_decl = static_cast(decl.GetOpaqueDecl()); - return clang::Decl::castToDeclContext(clang_decl); + auto clang_decl_ctx = clang::Decl::castToDeclContext(clang_decl); + return CompilerDeclContext(&m_clang, clang_decl_ctx); } std::pair @@ -603,8 +605,13 @@ case PdbSymUidKind::CompilandSym: { llvm::Optional scope = FindSymbolScope(m_index, uid.asCompilandSym()); - if (scope) - return GetOrCreateDeclContextForUid(*scope); + if (scope) { + lldb_private::CompilerDeclContext decl_ctx = + GetOrCreateDeclContextForUid(*scope); + auto ctx = + static_cast(decl_ctx.GetOpaqueDeclContext()); + return ctx; + } CVSymbol sym = m_index.ReadSymbolRecord(uid.asCompilandSym()); return GetParentDeclContextForSymbol(sym); @@ -620,7 +627,11 @@ static_cast(decl_ctx.GetOpaqueDeclContext()); return context; } - return GetOrCreateDeclContextForUid(PdbTypeSymId(iter->second)); + lldb_private::CompilerDeclContext decl_ctx = + GetOrCreateDeclContextForUid(PdbTypeSymId(iter->second)); + auto ctx = + static_cast(decl_ctx.GetOpaqueDeclContext()); + return ctx; } case PdbSymUidKind::FieldListMember: // In this case the parent DeclContext is the one for the class that this @@ -880,7 +891,10 @@ if (clang::Decl *decl = TryGetDecl(var_id)) return llvm::dyn_cast(decl); - clang::DeclContext *scope = GetOrCreateDeclContextForUid(scope_id); + lldb_private::CompilerDeclContext lldb_scope = + GetOrCreateDeclContextForUid(scope_id); + auto scope = + static_cast(lldb_scope.GetOpaqueDeclContext()); CVSymbol sym = m_index.ReadSymbolRecord(var_id); return CreateVariableDecl(PdbSymUid(var_id), sym, *scope); Index: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp =================================================================== --- source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -595,7 +595,6 @@ return array_sp; } - TypeSP SymbolFileNativePDB::CreateFunctionType(PdbTypeSymId type_id, const MemberFunctionRecord &mfr, CompilerType ct) { @@ -668,7 +667,8 @@ } if (cvt.kind() == LF_MFUNCTION) { MemberFunctionRecord mfr; - llvm::cantFail(TypeDeserializer::deserializeAs(cvt, mfr)); + llvm::cantFail( + TypeDeserializer::deserializeAs(cvt, mfr)); return CreateFunctionType(type_id, mfr, ct); } @@ -1236,9 +1236,9 @@ } uint32_t SymbolFileNativePDB::FindTypes( - ConstString name, const CompilerDeclContext *parent_decl_ctx, - bool append, uint32_t max_matches, - llvm::DenseSet &searched_symbol_files, TypeMap &types) { + ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, + uint32_t max_matches, llvm::DenseSet &searched_symbol_files, + TypeMap &types) { if (!append) types.Clear(); if (!name) @@ -1515,12 +1515,14 @@ CompilerDeclContext SymbolFileNativePDB::GetDeclContextForUID(lldb::user_id_t uid) { - clang::DeclContext *context = + lldb_private::CompilerDeclContext context = m_ast->GetOrCreateDeclContextForUid(PdbSymUid(uid)); if (!context) return {}; - return m_ast->ToCompilerDeclContext(*context); + auto clang_ctx = + static_cast(context.GetOpaqueDeclContext()); + return m_ast->ToCompilerDeclContext(*clang_ctx); } CompilerDeclContext @@ -1555,7 +1557,6 @@ return llvm::None; } - bool SymbolFileNativePDB::CompleteType(CompilerType &compiler_type) { clang::QualType qt = clang::QualType::getFromOpaquePtr(compiler_type.GetOpaqueQualType());