@@ -45,6 +45,81 @@ StmtResult Parser::ParseStatement(SourceLocation *TrailingElseLoc,
45
45
return Res;
46
46
}
47
47
48
+ namespace clang
49
+ {
50
+
51
+ PPStructType
52
+ PPExtGetStructType (const RecordDecl* RD)
53
+ {
54
+ StringRef TagFieldName (" __pp_specialization_type" );
55
+ for (auto FieldIter = RD->field_begin ();
56
+ FieldIter != RD->field_end (); ++FieldIter) {
57
+ if (FieldIter->getName ().equals (TagFieldName)) {
58
+ return PPStructType::Generalization;
59
+ }
60
+ }
61
+
62
+ if (RD->getName ().startswith (" __pp_struct" )) {
63
+ return PPStructType::Specialization;
64
+ }
65
+
66
+ return PPStructType::Default;
67
+ }
68
+
69
+ std::vector<PPStructInitDesc>
70
+ PPExtGetRDListToInit (const RecordDecl* RD)
71
+ {
72
+ std::vector<PPStructInitDesc> Result;
73
+ assert (!RD->field_empty ());
74
+ auto HeadElem = *RD->field_begin ();
75
+ auto HeadType = HeadElem->getType ();
76
+ const RecordDecl* RDHead = HeadType.getCanonicalType ().getTypePtr ()->
77
+ getAsRecordDecl ();
78
+
79
+ if (!RDHead ||
80
+ !HeadElem->getName ().equals (" __pp_head" )) {
81
+ RDHead = RD;
82
+ }
83
+
84
+ for (auto FieldIter = RDHead->field_begin ();
85
+ FieldIter != RDHead->field_end (); ++FieldIter) {
86
+ auto FieldType = FieldIter->getType ();
87
+ RecordDecl* RDField = FieldType.getCanonicalType ().getTypePtr ()->
88
+ getAsRecordDecl ();
89
+ if (RDField) {
90
+ auto StrTy = PPExtGetStructType (RDField);
91
+ if (StrTy != PPStructType::Default) {
92
+ Result.emplace_back (
93
+ PPStructInitDesc{*FieldIter, RDField, StrTy});
94
+ }
95
+ }
96
+ }
97
+
98
+ return Result;
99
+ }
100
+
101
+ } // namespace clang
102
+
103
+
104
+
105
+ PPStructType
106
+ PPExtGetStructType (const RecordDecl* RD)
107
+ {
108
+ StringRef TagFieldName (" __pp_specialization_type" );
109
+ for (auto FieldIter = RD->field_begin ();
110
+ FieldIter != RD->field_end (); ++FieldIter) {
111
+ if (FieldIter->getName ().equals (TagFieldName)) {
112
+ return PPStructType::Generalization;
113
+ }
114
+ }
115
+
116
+ if (RD->getName ().startswith (" __pp_struct" )) {
117
+ return PPStructType::Specialization;
118
+ }
119
+
120
+ return PPStructType::Default;
121
+ }
122
+
48
123
// / ParseStatementOrDeclaration - Read 'statement' or 'declaration'.
49
124
// / StatementOrDeclaration:
50
125
// / statement
@@ -1168,57 +1243,6 @@ StmtResult Parser::handleExprStmt(ExprResult E, ParsedStmtContext StmtCtx) {
1168
1243
return Actions.ActOnExprStmt (E, /* DiscardedValue=*/ !IsStmtExprResult);
1169
1244
}
1170
1245
1171
- Parser::PPStructType
1172
- Parser::PPExtGetStructType (const RecordDecl* RD) const
1173
- {
1174
- StringRef TagFieldName (" __pp_specialization_type" );
1175
- for (auto FieldIter = RD->field_begin ();
1176
- FieldIter != RD->field_end (); ++FieldIter) {
1177
- if (FieldIter->getName ().equals (TagFieldName)) {
1178
- return PPStructType::Generalization;
1179
- }
1180
- }
1181
-
1182
- if (RD->getName ().startswith (" __pp_struct" )) {
1183
- return PPStructType::Specialization;
1184
- }
1185
-
1186
- return PPStructType::Default;
1187
- }
1188
-
1189
-
1190
- std::vector<Parser::PPStructInitDesc>
1191
- Parser::PPExtGetRDListToInit (const RecordDecl* RD) const
1192
- {
1193
- std::vector<Parser::PPStructInitDesc> Result;
1194
- assert (!RD->field_empty ());
1195
- auto HeadElem = *RD->field_begin ();
1196
- auto HeadType = HeadElem->getType ();
1197
- const RecordDecl* RDHead = HeadType.getCanonicalType ().getTypePtr ()->
1198
- getAsRecordDecl ();
1199
-
1200
- if (!RDHead ||
1201
- !HeadElem->getName ().equals (" __pp_head" )) {
1202
- RDHead = RD;
1203
- }
1204
-
1205
- for (auto FieldIter = RDHead->field_begin ();
1206
- FieldIter != RDHead->field_end (); ++FieldIter) {
1207
- auto FieldType = FieldIter->getType ();
1208
- RecordDecl* RDField = FieldType.getCanonicalType ().getTypePtr ()->
1209
- getAsRecordDecl ();
1210
- if (RDField) {
1211
- auto StrTy = PPExtGetStructType (RDField);
1212
- if (StrTy != PPStructType::Default) {
1213
- Result.emplace_back (
1214
- PPStructInitDesc{*FieldIter, RDField, StrTy});
1215
- }
1216
- }
1217
- }
1218
-
1219
- return Result;
1220
- }
1221
-
1222
1246
1223
1247
Parser::PPMemberInitData
1224
1248
Parser::PPExtInitPPStruct (PPStructInitDesc IDesc, Expr* MemberAccess)
0 commit comments