Zequan Wu via llvm-dev
2021-Nov-11 23:21 UTC
[llvm-dev] How to get the TypeIndex for the class/structure given its member function's TypeIndex in PdbAstBuilder?
Hi, 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? Zequan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211111/f4392545/attachment-0001.html>
Zequan Wu via llvm-dev
2021-Nov-12 00:28 UTC
[llvm-dev] How to get the TypeIndex for the class/structure given its member function's TypeIndex in PdbAstBuilder?
NVM, just noticed that the DeclContext for the parent record is available. I can get tye QualType using: llvm::dyn_cast<clang::TypeDecl>(parent)->getTypeForDecl()->getCanonicalTypeInternal() On Thu, Nov 11, 2021 at 3:21 PM Zequan Wu <zequanwu at google.com> wrote:> Hi, > > 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? > > Zequan >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211111/61e33619/attachment.html>