MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / InsertVtblPtr

Function InsertVtblPtr

CfrontCodeGenerator.cpp:441–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439//-----------------------------------------------------------------------------
440
441static void InsertVtblPtr(const CXXMethodDecl* stmt, const CXXRecordDecl* cur, StmtsContainer& bodyStmts)
442{
443 if(cur->isPolymorphic() and (0 == cur->getNumBases())) {
444 auto* fieldDecl = CfrontCodeGenerator::VtableData().VtblPtrField(cur);
445 auto* lhsMemberExpr = AccessMember(kwInternalThis, fieldDecl, Ptr(GetRecordDeclType(cur)));
446
447 // struct __mptr *__ptbl_vec__c___src_C_[]
448 auto* vtablAr = CfrontCodeGenerator::VtableData().VtblArrayVar(1);
449 auto* vtblArrayPos =
450 ArraySubscript(mkDeclRefExpr(vtablAr), GetGlobalVtablePos(stmt->getParent(), cur), fieldDecl->getType());
451
452 bodyStmts.AddBodyStmts(Assign(lhsMemberExpr, fieldDecl, vtblArrayPos));
453
454 } else if(cur->isPolymorphic() and (0 < cur->getNumBases()) and (cur != stmt->getParent())) {
455 for(const auto& base : cur->bases()) {
456 InsertVtblPtr(stmt, base.getType()->getAsCXXRecordDecl(), bodyStmts);
457 }
458 }
459}
460//-----------------------------------------------------------------------------
461
462void CfrontCodeGenerator::InsertCXXMethodDecl(const CXXMethodDecl* stmt, SkipBody)

Callers 1

InsertCXXMethodDeclMethod · 0.85

Calls 10

PtrFunction · 0.85
GetRecordDeclTypeFunction · 0.85
ArraySubscriptFunction · 0.85
mkDeclRefExprFunction · 0.85
GetGlobalVtablePosFunction · 0.85
AssignFunction · 0.85
VtblPtrFieldMethod · 0.80
VtblArrayVarMethod · 0.80
AddBodyStmtsMethod · 0.80
AccessMemberFunction · 0.70

Tested by

no test coverage detected