[clang] 06c70e9 - DebugInfo: Remove auto return type representation support
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 17:35:18 PDT 2022
Author: David Blaikie
Date: 2022-08-17T00:35:05Z
New Revision: 06c70e9b998ca289630ee1629ec09b6dd51b29b9
URL: https://github.com/llvm/llvm-project/commit/06c70e9b998ca289630ee1629ec09b6dd51b29b9
DIFF: https://github.com/llvm/llvm-project/commit/06c70e9b998ca289630ee1629ec09b6dd51b29b9.diff
LOG: DebugInfo: Remove auto return type representation support
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
This reverts commit 5ff992bca208a0e37ca6338fc735aec6aa848b72: [DEBUG-INFO] Change how we handle auto return types for lambda operator() to be consistent with gcc
This reverts commit c83602fdf51b2692e3bacb06bf861f20f74e987f: [DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions.
Differential Revision: https://reviews.llvm.org/D131933
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-auto-return.cpp
Removed:
clang/test/CodeGenCXX/no_auto_return_lambda.cpp
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0469de766d78c..3d78a13d30aa8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -883,10 +883,6 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
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 @@ void CGDebugInfo::CollectRecordFields(
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 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
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 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
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 @@ llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
return DBuilder.createMemberPointerType(
getOrCreateInstanceMethodType(
CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()),
- FPT, U, false),
+ FPT, U),
ClassType, Size, /*Align=*/0, Flags);
}
@@ -3971,7 +3954,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
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;
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 38e3fa5b2fa96..d257a87a972af 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -177,7 +177,6 @@ class CGDebugInfo {
/// 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 @@ class CGDebugInfo {
/// 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/test/CodeGenCXX/debug-info-auto-return.cpp b/clang/test/CodeGenCXX/debug-info-auto-return.cpp
index 8b4c5cb3ad9b3..c7a97ba166ecc 100644
--- 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
index 61e76a0656e67..0000000000000
--- 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]], {{.*}}
More information about the cfe-commits
mailing list