@@ -810,6 +810,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
810
810
return DBuilder.createBasicType (BTName, Size, Encoding);
811
811
}
812
812
813
+ llvm::DIType *CGDebugInfo::CreateType (const AutoType *Ty) {
814
+ return DBuilder.createUnspecifiedType (" auto" );
815
+ }
816
+
813
817
llvm::DIType *CGDebugInfo::CreateType (const ComplexType *Ty) {
814
818
// Bit size and offset of the type.
815
819
llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
@@ -1457,26 +1461,31 @@ void CGDebugInfo::CollectRecordFields(
1457
1461
1458
1462
llvm::DISubroutineType *
1459
1463
CGDebugInfo::getOrCreateMethodType (const CXXMethodDecl *Method,
1460
- llvm::DIFile *Unit) {
1464
+ llvm::DIFile *Unit, bool decl ) {
1461
1465
const FunctionProtoType *Func = Method->getType ()->getAs <FunctionProtoType>();
1462
1466
if (Method->isStatic ())
1463
1467
return cast_or_null<llvm::DISubroutineType>(
1464
1468
getOrCreateType (QualType (Func, 0 ), Unit));
1465
- return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit);
1469
+ return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit, decl );
1466
1470
}
1467
1471
1468
- llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType (
1469
- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
1472
+ llvm::DISubroutineType *
1473
+ CGDebugInfo::getOrCreateInstanceMethodType (QualType ThisPtr,
1474
+ const FunctionProtoType *Func,
1475
+ llvm::DIFile *Unit, bool decl) {
1470
1476
// Add "this" pointer.
1471
1477
llvm::DITypeRefArray Args (
1472
1478
cast<llvm::DISubroutineType>(getOrCreateType (QualType (Func, 0 ), Unit))
1473
1479
->getTypeArray ());
1474
1480
assert (Args.size () && " Invalid number of arguments!" );
1475
1481
1476
1482
SmallVector<llvm::Metadata *, 16 > Elts;
1477
-
1478
1483
// First element is always return type. For 'void' functions it is NULL.
1479
- Elts.push_back (Args[0 ]);
1484
+ QualType temp = Func->getReturnType ();
1485
+ if (temp->getTypeClass () == Type::Auto && decl)
1486
+ Elts.push_back (CreateType (cast<AutoType>(temp)));
1487
+ else
1488
+ Elts.push_back (Args[0 ]);
1480
1489
1481
1490
// "this" pointer is always first argument.
1482
1491
const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl ();
@@ -1535,7 +1544,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
1535
1544
isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method);
1536
1545
1537
1546
StringRef MethodName = getFunctionName (Method);
1538
- llvm::DISubroutineType *MethodTy = getOrCreateMethodType (Method, Unit);
1547
+ llvm::DISubroutineType *MethodTy = getOrCreateMethodType (Method, Unit, true );
1539
1548
1540
1549
// Since a single ctor/dtor corresponds to multiple functions, it doesn't
1541
1550
// make sense to give a single ctor/dtor a linkage name.
@@ -2754,7 +2763,7 @@ llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
2754
2763
return DBuilder.createMemberPointerType (
2755
2764
getOrCreateInstanceMethodType (
2756
2765
CXXMethodDecl::getThisType (FPT, Ty->getMostRecentCXXRecordDecl ()),
2757
- FPT, U),
2766
+ FPT, U, false ),
2758
2767
ClassType, Size, /* Align=*/ 0 , Flags);
2759
2768
}
2760
2769
@@ -3529,7 +3538,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
3529
3538
return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray (None));
3530
3539
3531
3540
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
3532
- return getOrCreateMethodType (Method, F);
3541
+ return getOrCreateMethodType (Method, F, false );
3533
3542
3534
3543
const auto *FTy = FnType->getAs <FunctionType>();
3535
3544
CallingConv CC = FTy ? FTy->getCallConv () : CallingConv::CC_C;
0 commit comments