diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -177,7 +177,6 @@ /// ivars and property accessors. llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); - llvm::DIType *CreateType(const AutoType *Ty); llvm::DIType *CreateType(const BitIntType *Ty); llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty, @@ -231,10 +230,10 @@ /// not updated to include implicit \c this pointer. Use this routine /// to get a method type which includes \c this pointer. llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method, - llvm::DIFile *F, bool decl); + llvm::DIFile *F); llvm::DISubroutineType * getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func, - llvm::DIFile *Unit, bool decl); + llvm::DIFile *Unit); llvm::DISubroutineType * getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F); /// \return debug info descriptor for vtable. diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -883,10 +883,6 @@ return DBuilder.createBasicType(BTName, Size, Encoding); } -llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) { - return DBuilder.createUnspecifiedType("auto"); -} - llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) { StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt"; @@ -1647,18 +1643,16 @@ llvm::DISubroutineType * CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, - llvm::DIFile *Unit, bool decl) { - const auto *Func = Method->getType()->castAs(); + llvm::DIFile *Unit) { + const FunctionProtoType *Func = Method->getType()->getAs(); if (Method->isStatic()) return cast_or_null( getOrCreateType(QualType(Func, 0), Unit)); - return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, decl); + return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit); } -llvm::DISubroutineType * -CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr, - const FunctionProtoType *Func, - llvm::DIFile *Unit, bool decl) { +llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( + QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) { FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo(); Qualifiers &Qc = EPI.TypeQuals; Qc.removeConst(); @@ -1681,20 +1675,9 @@ assert(Args.size() && "Invalid number of arguments!"); SmallVector Elts; + // First element is always return type. For 'void' functions it is NULL. - QualType temp = Func->getReturnType(); - if (temp->getTypeClass() == Type::Auto && decl) { - const AutoType *AT = cast(temp); - - // It may be tricky in some cases to link the specification back the lambda - // call operator and so we skip emitting "auto" for lambdas. This is - // consistent with gcc as well. - if (AT->isDeduced() && ThisPtr->getPointeeCXXRecordDecl()->isLambda()) - Elts.push_back(getOrCreateType(AT->getDeducedType(), Unit)); - else - Elts.push_back(CreateType(AT)); - } else - Elts.push_back(Args[0]); + Elts.push_back(Args[0]); // "this" pointer is always first argument. const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl(); @@ -1747,7 +1730,7 @@ isa(Method) || isa(Method); StringRef MethodName = getFunctionName(Method); - llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit, true); + llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit); // Since a single ctor/dtor corresponds to multiple functions, it doesn't // make sense to give a single ctor/dtor a linkage name. @@ -3160,7 +3143,7 @@ return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), - FPT, U, false), + FPT, U), ClassType, Size, /*Align=*/0, Flags); } @@ -3971,7 +3954,7 @@ return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None)); if (const auto *Method = dyn_cast(D)) - return getOrCreateMethodType(Method, F, false); + return getOrCreateMethodType(Method, F); const auto *FTy = FnType->getAs(); CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C; diff --git a/clang/test/CodeGenCXX/debug-info-auto-return.cpp b/clang/test/CodeGenCXX/debug-info-auto-return.cpp --- a/clang/test/CodeGenCXX/debug-info-auto-return.cpp +++ b/clang/test/CodeGenCXX/debug-info-auto-return.cpp @@ -2,17 +2,20 @@ // RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple x86_64-linux-gnu %s -o - \ // RUN: -O0 -disable-llvm-passes \ // RUN: -debug-info-kind=standalone \ -// RUN: | FileCheck %s +// RUN: | FileCheck --implicit-check-not="\"auto\"" --implicit-check-not=DISubprogram %s -// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: ![[FUN_TYPE:[0-9]+]],{{.*}} +// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: [[FUN_TYPE:![0-9]+]], {{.*}}spFlags: DISPFlagDefinition, {{.*}} declaration: [[DECL:![0-9]+]] -// CHECK: ![[FUN_TYPE]] = !DISubroutineType(types: ![[TYPE_NODE:[0-9]+]]) -// CHECK-NEXT: ![[TYPE_NODE]] = !{![[DOUBLE_TYPE:[0-9]+]], {{.*}} -// CHECK-NEXT: ![[DOUBLE_TYPE]] = !DIBasicType(name: "double", {{.*}}) +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "myClass", +// CHECK-SAME: elements: [[MEMBERS:![0-9]+]], + +// CHECK: [[MEMBERS]] = !{} + +// CHECK: [[FUN_TYPE]] = !DISubroutineType(types: [[TYPE_NODE:![0-9]+]]) +// CHECK-NEXT: [[TYPE_NODE]] = !{[[DOUBLE_TYPE:![0-9]+]], +// CHECK-NEXT: [[DOUBLE_TYPE]] = !DIBasicType(name: "double", +// CHECK: [[DECL]] = !DISubprogram(name: "findMax",{{.*}}, type: [[FUN_TYPE]], -// CHECK: !DISubroutineType(types: ![[TYPE_DECL_NODE:[0-9]+]]) -// CHECK-NEXT: ![[TYPE_DECL_NODE]] = !{![[AUTO_TYPE:[0-9]+]], {{.*}} -// CHECK-NEXT: ![[AUTO_TYPE]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto") struct myClass { auto findMax(); }; diff --git a/clang/test/CodeGenCXX/no_auto_return_lambda.cpp b/clang/test/CodeGenCXX/no_auto_return_lambda.cpp deleted file mode 100644 --- a/clang/test/CodeGenCXX/no_auto_return_lambda.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s - -// We emit "auto" for deduced return types for member functions but we should -// not emitting "auto" for deduced return types for lambdas call function which -// will be implmented as operator() in a class type. This test will verify that -// behavior. - -__attribute__((used)) int g() { - auto f = []() { return 10; }; - return f(); -} - -// g() is not a member function so we should not emit "auto" for the deduced -// return type. -// -// CHECK: !DISubprogram(name: "g",{{.*}}, type: ![[FUN_TYPE:[0-9]+]],{{.*}} -// CHECK: ![[FUN_TYPE]] = !DISubroutineType(types: ![[TYPE_NODE:[0-9]+]]) -// CHECK: ![[TYPE_NODE]] = !{![[INT_TYPE:[0-9]+]]} -// CHECK: ![[INT_TYPE]] = !DIBasicType(name: "int", {{.*}}) - -// operator() of the local lambda should have the same return type as g() -// -// CHECK: distinct !DISubprogram(name: "operator()",{{.*}}, type: ![[FUN_TYPE_LAMBDA:[0-9]+]],{{.*}} -// CHECK: ![[FUN_TYPE_LAMBDA]] = !DISubroutineType({{.*}}types: ![[TYPE_NODE_LAMBDA:[0-9]+]]) -// CHECK: ![[TYPE_NODE_LAMBDA]] = !{![[INT_TYPE]], {{.*}}