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

Function ProcessFields

CfrontCodeGenerator.cpp:815–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813//-----------------------------------------------------------------------------
814
815static void ProcessFields(CXXRecordDecl* recordDecl, const CXXRecordDecl* rd)
816{
817 RETURN_IF(not rd->hasDefinition())
818
819 auto AddField = [&](const FieldDecl* field) {
820 recordDecl->addDecl(mkFieldDecl(recordDecl, GetName(*field), field->getType()));
821 };
822
823 // Insert field from base classes
824 for(const auto& base : rd->bases()) {
825 // XXX: ignoring TemplateSpecializationType
826 if(const auto* rdBase = dyn_cast_or_null<CXXRecordDecl>(base.getType().getCanonicalType()->getAsRecordDecl())) {
827 ProcessFields(recordDecl, rdBase);
828 }
829 }
830
831 // insert vtable pointer if required
832 if(rd->isPolymorphic() and (rd->getNumBases() == 0)) {
833 recordDecl->addDecl(CfrontCodeGenerator::VtableData().VtblPtrField(rd));
834 }
835
836 // insert own fields
837 for(const auto* d : rd->fields()) {
838 AddField(d);
839 }
840
841 if(recordDecl->field_empty()) {
842 AddField(mkFieldDecl(recordDecl, "__dummy"sv, GetGlobalAST().CharTy));
843 }
844}
845//-----------------------------------------------------------------------------
846
847static std::string GetFirstPolymorphicBaseName(const RecordDecl* decl, const RecordDecl* to)

Callers 1

InsertArgMethod · 0.85

Calls 4

mkFieldDeclFunction · 0.85
GetNameFunction · 0.85
AddFieldFunction · 0.85
VtblPtrFieldMethod · 0.80

Tested by

no test coverage detected