dblaikie created this revision. dblaikie added reviewers: aprantl, probinson, shafik, awpandey. Herald added a project: All. dblaikie requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Seems this complicated lldb sufficiently for some cases that it hasn't been worth supporting/fixing there - and it so far hasn't provided any new use cases/value for debug info consumers, so let's remove it until someone has a use case for it. (side note: the original implementation of this still had a bug (I should've caught it in review) that we still didn't produce auto-returning function declarations in types where the function wasn't instantiatied (that requires a fix to remove the `if getContainedAutoType` condition in `CGDebugInfo::CollectCXXMemberFunctions` - without that, auto returning functions were still being handled the same as member function templates and special member functions - never added to the member list, only attached to the type via the declaration chain from the definition) Further discussion about this in D123319 <https://reviews.llvm.org/D123319> This reverts commit 5ff992bca208a0e37ca6338fc735aec6aa848b72 <https://reviews.llvm.org/rG5ff992bca208a0e37ca6338fc735aec6aa848b72>: [DEBUG-INFO] Change how we handle auto return types for lambda operator() to be consistent with gcc This reverts commit c83602fdf51b2692e3bacb06bf861f20f74e987f <https://reviews.llvm.org/rGc83602fdf51b2692e3bacb06bf861f20f74e987f>: [DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D131933 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-auto-return.cpp clang/test/CodeGenCXX/no_auto_return_lambda.cpp
Index: clang/test/CodeGenCXX/no_auto_return_lambda.cpp =================================================================== --- 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]], {{.*}} Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-auto-return.cpp +++ 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(); }; Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ 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. Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ 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<FunctionProtoType>(); + llvm::DIFile *Unit) { + const FunctionProtoType *Func = Method->getType()->getAs<FunctionProtoType>(); if (Method->isStatic()) return cast_or_null<llvm::DISubroutineType>( 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<llvm::Metadata *, 16> 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<AutoType>(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<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(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<CXXMethodDecl>(D)) - return getOrCreateMethodType(Method, F, false); + return getOrCreateMethodType(Method, F); const auto *FTy = FnType->getAs<FunctionType>(); CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits