@@ -19,6 +19,7 @@ import dstep.translator.Declaration;
19
19
import dstep.translator.Output;
20
20
import dstep.translator.Translator;
21
21
import dstep.translator.Type;
22
+ import dstep.translator.Util;
22
23
23
24
string translateRecordTypeKeyword (in Cursor cursor)
24
25
{
@@ -140,7 +141,14 @@ void translateRecordDef(
140
141
auto canonical = cursor.canonical;
141
142
142
143
auto spelling = keepUnnamed ? " " : context.translateTagSpelling(cursor);
143
- spelling = spelling == " " ? spelling : " " ~ spelling;
144
+ /* Spaghetti warning: Since unnamed values might in at least clang 19.1
145
+ * contain "unnamed enum" or something as the name instead of being empty,
146
+ * explicitly set it our variable to the empty string.
147
+ *
148
+ * Preferably, this would be disentagled and it would be ensured that there
149
+ * is only one source of the spelling in this whole function.
150
+ */
151
+ spelling = spelling.isUnnamed ? " " : " " ~ spelling;
144
152
auto type = translateRecordTypeKeyword(cursor);
145
153
146
154
output.subscopeStrong(cursor.extent, " %s%s" , type, spelling) in {
@@ -195,7 +203,7 @@ void translateRecordDef(
195
203
196
204
case CXCursorKind.unionDecl:
197
205
case CXCursorKind.structDecl:
198
- if (cursor.type.isAnonymous)
206
+ if (cursor.type.isAnonymous || cursor.spelling.isUnnamed )
199
207
translateAnonymousRecord(output, context, cursor);
200
208
201
209
break ;
@@ -216,7 +224,8 @@ void translateRecordDecl(Output output, Context context, Cursor cursor)
216
224
context.markAsDefined(cursor);
217
225
218
226
auto spelling = context.translateTagSpelling(cursor);
219
- spelling = spelling == " " ? spelling : " " ~ spelling;
227
+ // spelling = spelling == "" ? spelling : " " ~ spelling;
228
+ spelling = spelling.isUnnamed ? " " : " " ~ spelling;
220
229
auto type = translateRecordTypeKeyword(cursor);
221
230
output.singleLine(cursor.extent, " %s%s;" , type, spelling);
222
231
}
@@ -233,7 +242,7 @@ bool shouldSkipRecord(Context context, Cursor cursor)
233
242
cursor.kind == CXCursorKind.unionDecl)
234
243
{
235
244
auto typedefp = context.typedefParent(cursor.canonical);
236
- auto spelling = typedefp.isValid && cursor.spelling == " "
245
+ auto spelling = typedefp.isValid && isUnnamed( cursor.spelling)
237
246
? typedefp.spelling
238
247
: cursor.spelling;
239
248
@@ -249,7 +258,7 @@ bool shouldSkipRecordDefinition(Context context, Cursor cursor)
249
258
cursor.kind == CXCursorKind.unionDecl)
250
259
{
251
260
auto typedefp = context.typedefParent(cursor.canonical);
252
- auto spelling = typedefp.isValid && cursor.spelling == " "
261
+ auto spelling = typedefp.isValid && cursor.spelling.isUnnamed
253
262
? typedefp.spelling
254
263
: cursor.spelling;
255
264
0 commit comments