| 1126 | //----------------------------------------------------------------------------- |
| 1127 | |
| 1128 | std::string EmitGlobalVariableCtors() |
| 1129 | { |
| 1130 | StmtsContainer bodyStmts{}; |
| 1131 | |
| 1132 | for(auto& e : globalVarCtors) { |
| 1133 | bodyStmts.AddBodyStmts(e); |
| 1134 | } |
| 1135 | |
| 1136 | auto* cxaStartFun = Function(cxaStart, VoidTy(), {}); |
| 1137 | cxaStartFun->setBody(mkCompoundStmt(bodyStmts)); |
| 1138 | |
| 1139 | OutputFormatHelper ofm{}; |
| 1140 | ofm.AppendNewLine(); |
| 1141 | ofm.AppendNewLine(); |
| 1142 | CodeGeneratorVariant cg{ofm}; |
| 1143 | |
| 1144 | if(gVtables.size()) { |
| 1145 | SmallVector<Expr*, 16> mInitExprs{}; |
| 1146 | |
| 1147 | for(auto& e : gVtables) { |
| 1148 | cg->InsertArg(e.second); |
| 1149 | mInitExprs.push_back(mkDeclRefExpr(e.second)); |
| 1150 | } |
| 1151 | |
| 1152 | ofm.AppendNewLine(); |
| 1153 | |
| 1154 | // struct __mptr *__ptbl_vec__c___src_C_[] |
| 1155 | auto* vtable = CfrontCodeGenerator::VtableData().VtblArrayVar(mInitExprs.size()); |
| 1156 | vtable->setInit(InitList(mInitExprs, vtable->getType())); |
| 1157 | |
| 1158 | cg->InsertArg(vtable); |
| 1159 | |
| 1160 | ofm.AppendNewLine(); |
| 1161 | } |
| 1162 | |
| 1163 | cg->InsertArg(cxaStartFun); |
| 1164 | |
| 1165 | StmtsContainer bodyStmtsDtors{}; |
| 1166 | |
| 1167 | for(auto& e : globalVarDtors) { |
| 1168 | bodyStmtsDtors.AddBodyStmts(e); |
| 1169 | } |
| 1170 | |
| 1171 | auto* cxaAtExitFun = Function(cxaAtExit, VoidTy(), {}); |
| 1172 | cxaAtExitFun->setBody(mkCompoundStmt(bodyStmtsDtors)); |
| 1173 | |
| 1174 | ofm.AppendNewLine(); |
| 1175 | cg->InsertArg(cxaAtExitFun); |
| 1176 | |
| 1177 | return ofm.GetString(); |
| 1178 | } |
| 1179 | //----------------------------------------------------------------------------- |
| 1180 | |
| 1181 | void CodeGenerator::LifetimeAddExtended(const VarDecl* vd, const ValueDecl* extending) |
no test coverage detected