@@ -434,6 +434,54 @@ llvm::DIType ldc::DIBuilder::CreateSArrayType(Type *type)
434
434
);
435
435
}
436
436
437
+ llvm::DIType ldc::DIBuilder::CreateAArrayType (Type *type)
438
+ {
439
+ // FIXME: Implement
440
+ #if LDC_LLVM_VER >= 304
441
+ return DBuilder.createUnspecifiedType (type->toChars ());
442
+ #else
443
+ return llvm::DIType (NULL );
444
+ #endif
445
+ }
446
+
447
+ // //////////////////////////////////////////////////////////////////////////////
448
+
449
+ ldc::DIFunctionType ldc::DIBuilder::CreateFunctionType (Type *type)
450
+ {
451
+ TypeFunction *t = static_cast <TypeFunction*>(type);
452
+ Type *retType = t->next ;
453
+
454
+ llvm::DIFile file = CreateFile (Loc (IR->dmodule , 0 ));
455
+
456
+ // Create "dummy" subroutine type for the return type
457
+ llvm::SmallVector<llvm::Value*, 16 > Elts;
458
+ Elts.push_back (CreateTypeDescription (retType, NULL , true ));
459
+ llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray (Elts);
460
+ return DBuilder.createSubroutineType (file, EltTypeArray);
461
+ }
462
+
463
+ ldc::DIFunctionType ldc::DIBuilder::CreateDelegateType (Type *type)
464
+ {
465
+ // FIXME: Implement
466
+ TypeDelegate *t = static_cast <TypeDelegate*>(type);
467
+
468
+ llvm::DIFile file = CreateFile (Loc (IR->dmodule , 0 ));
469
+
470
+ // Create "dummy" subroutine type for the return type
471
+ llvm::SmallVector<llvm::Value*, 16 > Elts;
472
+ Elts.push_back (
473
+ #if LDC_LLVM_VER >= 304
474
+ DBuilder.createUnspecifiedType (type->toChars ())
475
+ #else
476
+ llvm::DIType (NULL )
477
+ #endif
478
+ );
479
+ llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray (Elts);
480
+ return DBuilder.createSubroutineType (file, EltTypeArray);
481
+ }
482
+
483
+ // //////////////////////////////////////////////////////////////////////////////
484
+
437
485
llvm::DIType ldc::DIBuilder::CreateTypeDescription (Type* type,
438
486
const char * c_name,
439
487
bool derefclass)
@@ -445,7 +493,7 @@ llvm::DIType ldc::DIBuilder::CreateTypeDescription(Type* type,
445
493
t = type->toBasetype ();
446
494
}
447
495
448
- if (t->ty == Tvoid)
496
+ if (t->ty == Tvoid || t-> ty == Tnull )
449
497
#if LDC_LLVM_VER >= 304
450
498
return DBuilder.createUnspecifiedType (t->toChars ());
451
499
#else
@@ -465,10 +513,17 @@ llvm::DIType ldc::DIBuilder::CreateTypeDescription(Type* type,
465
513
return CreateArrayType (type);
466
514
else if (t->ty == Tsarray)
467
515
return CreateSArrayType (type);
516
+ else if (t->ty == Taarray)
517
+ return CreateAArrayType (type);
468
518
else if (t->ty == Tstruct || t->ty == Tclass)
469
519
return CreateCompositeType (type);
520
+ else if (t->ty == Tfunction)
521
+ return CreateFunctionType (type);
522
+ else if (t->ty == Tdelegate)
523
+ return CreateDelegateType (type);
470
524
471
- return llvm::DIType (NULL );
525
+ // Crash if the type is not supported.
526
+ llvm_unreachable (" Unsupported type in debug info" );
472
527
}
473
528
474
529
// //////////////////////////////////////////////////////////////////////////////
@@ -515,18 +570,9 @@ llvm::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd)
515
570
assert (CU && CU.Verify () && " Compilation unit missing or corrupted in DIBuilder::EmitSubProgram" );
516
571
517
572
llvm::DIFile file = CreateFile (fd->loc );
518
- Type *retType = static_cast <TypeFunction*>(fd->type )->next ;
519
573
520
- // Create "dummy" subroutine type for the return type
521
- llvm::SmallVector<llvm::Value*, 16 > Elts;
522
- Elts.push_back (CreateTypeDescription (retType, NULL , true ));
523
- llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray (Elts);
524
- #if LDC_LLVM_VER >= 304
525
- llvm::DICompositeType
526
- #else
527
- llvm::DIType
528
- #endif
529
- DIFnType = DBuilder.createSubroutineType (file, EltTypeArray);
574
+ // Create subroutine type
575
+ ldc::DIFunctionType DIFnType = CreateFunctionType (static_cast <TypeFunction*>(fd->type ));
530
576
531
577
// FIXME: duplicates ?
532
578
return DBuilder.createFunction (
@@ -560,12 +606,7 @@ llvm::DISubprogram ldc::DIBuilder::EmitSubProgramInternal(llvm::StringRef pretty
560
606
llvm::SmallVector<llvm::Value *, 1 > Elts;
561
607
Elts.push_back (llvm::DIType (NULL ));
562
608
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray (Elts);
563
- #if LDC_LLVM_VER >= 304
564
- llvm::DICompositeType
565
- #else
566
- llvm::DIType
567
- #endif
568
- DIFnType = DBuilder.createSubroutineType (file, EltTypeArray);
609
+ ldc::DIFunctionType DIFnType = DBuilder.createSubroutineType (file, EltTypeArray);
569
610
570
611
// FIXME: duplicates ?
571
612
return DBuilder.createFunction (
0 commit comments