How to get the TypeIndex for the class/structure given its member function's TypeIndex in PdbAstBuilder?


I’m trying to call TypeSystemClang::AddMethodToCXXRecordType in PdbAstBuilder::GetOrCreateFunctionDecl to create a function decl in the case when the function is inside a record. It requires the record’s type as the first argument. So, I think I need to get its TypeIndex first. I tried to do the following, but it fails to find the parent’s TypeIndex. type_id.index is the member function’s TypeIndex.
auto iter = m_parent_types.find(type_id.index);

Am I using m_parent_types incorrectly? Or is there any other ways to get the class/structure’s TypeIndex?


NVM, just noticed that the DeclContext for the parent record is available. I can get tye QualType using: llvm::dyn_castclang::TypeDecl(parent)->getTypeForDecl()->getCanonicalTypeInternal()