@@ -455,6 +455,16 @@ bool has_noexcept_attr(const std::vector<std::string>& attrs) {
455
455
attrs.end ();
456
456
}
457
457
458
+ bool has_copy_ctor_attr (const std::vector<std::string>& attrs) {
459
+ return std::find (attrs.begin (), attrs.end (), " cppmm|copy_constructor" ) !=
460
+ attrs.end ();
461
+ }
462
+
463
+ bool has_move_ctor_attr (const std::vector<std::string>& attrs) {
464
+ return std::find (attrs.begin (), attrs.end (), " cppmm|move_constructor" ) !=
465
+ attrs.end ();
466
+ }
467
+
458
468
bool has_manual_attr (const std::vector<std::string>& attrs) {
459
469
return std::find (attrs.begin (), attrs.end (), " cppmm|manual" ) != attrs.end ();
460
470
}
@@ -1055,17 +1065,63 @@ bool is_public_move_ctor(const Decl* cmd) {
1055
1065
}
1056
1066
}
1057
1067
1068
+ bool has_forbidden_copy_ctor (const CXXRecordDecl* crd) {
1069
+ for (const Decl* d: crd->decls ()) {
1070
+ if (is_inaccessible_copy_ctor (d)) {
1071
+ return true ;
1072
+ }
1073
+ }
1074
+
1075
+
1076
+ for (const auto base : crd->bases ()) {
1077
+ if (const CXXRecordDecl* base_crd =
1078
+ base.getType ()->getAsCXXRecordDecl ()) {
1079
+ if (has_forbidden_copy_ctor (base_crd)) {
1080
+ return true ;
1081
+ }
1082
+ }
1083
+ }
1084
+
1085
+ return false ;
1086
+ }
1087
+
1088
+ bool has_forbidden_move_ctor (const CXXRecordDecl* crd) {
1089
+ for (const Decl* d: crd->decls ()) {
1090
+ if (is_inaccessible_move_ctor (d)) {
1091
+ return true ;
1092
+ }
1093
+ }
1094
+
1095
+
1096
+ for (const auto base : crd->bases ()) {
1097
+ if (const CXXRecordDecl* base_crd =
1098
+ base.getType ()->getAsCXXRecordDecl ()) {
1099
+ if (has_forbidden_move_ctor (base_crd)) {
1100
+ return true ;
1101
+ }
1102
+ }
1103
+ }
1104
+
1105
+ return false ;
1106
+ }
1107
+
1058
1108
void has_public_copy_move_ctor (const CXXRecordDecl* crd,
1059
1109
bool & has_public_copy_ctor,
1060
1110
bool & has_public_move_ctor) {
1061
- for (const Decl* d : crd->decls ()) {
1062
- // has_public_copy_ctor |= is_public_copy_ctor(d);
1063
- // has_public_move_ctor |= is_public_move_ctor(d);
1064
- has_public_copy_ctor |= is_inaccessible_copy_ctor (d);
1065
- has_public_move_ctor |= is_inaccessible_move_ctor (d);
1066
- }
1067
- has_public_copy_ctor = !has_public_copy_ctor;
1068
- has_public_move_ctor = !has_public_move_ctor;
1111
+ // for (const Decl* d : crd->decls()) {
1112
+ // // has_public_copy_ctor |= is_public_copy_ctor(d);
1113
+ // // has_public_move_ctor |= is_public_move_ctor(d);
1114
+ // has_public_copy_ctor |= is_inaccessible_copy_ctor(d);
1115
+ // has_public_move_ctor |= is_inaccessible_move_ctor(d);
1116
+ // }
1117
+ // has_public_copy_ctor = !has_public_copy_ctor;
1118
+ // has_public_move_ctor = !has_public_move_ctor;
1119
+
1120
+ // has_public_copy_ctor = crd->hasTrivialCopyConstructor() || crd->hasNonTrivialCopyConstructor();
1121
+ has_public_move_ctor = (crd->hasTrivialMoveConstructor () || crd->hasNonTrivialMoveConstructor ()) && !has_forbidden_move_ctor (crd);
1122
+
1123
+ has_public_copy_ctor = !has_forbidden_copy_ctor (crd);
1124
+ // has_public_move_ctor = !has_forbidden_move_ctor(crd);
1069
1125
}
1070
1126
1071
1127
std::vector<std::string> get_properties (const std::vector<std::string>& attrs) {
@@ -1226,6 +1282,9 @@ void process_concrete_record(const CXXRecordDecl* crd, std::string filename,
1226
1282
mptr->is_noexcept |= has_noexcept_attr (mptr->attrs );
1227
1283
function_map[mptr->_function_id ] = mptr;
1228
1284
1285
+ mptr->is_copy_constructor = has_copy_ctor_attr (mptr->attrs );
1286
+ mptr->is_move_constructor = has_move_ctor_attr (mptr->attrs );
1287
+
1229
1288
NodeId id = NODES.size ();
1230
1289
NODE_MAP[method->qualified_name ] = id;
1231
1290
NODES.emplace_back (std::move (method));
0 commit comments