Skip to content

Commit c3a935e

Browse files
authored
Revert "[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this" (llvm#123455)
Reverts llvm#122928
1 parent 4aedb97 commit c3a935e

File tree

6 files changed

+23
-39
lines changed

6 files changed

+23
-39
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,29 +2016,20 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
20162016
// First element is always return type. For 'void' functions it is NULL.
20172017
Elts.push_back(Args[0]);
20182018

2019-
const bool HasExplicitObjectParameter = ThisPtr.isNull();
2020-
2021-
// "this" pointer is always first argument. For explicit "this"
2022-
// parameters, it will already be in Args[1].
2023-
if (!HasExplicitObjectParameter) {
2019+
// "this" pointer is always first argument.
2020+
// ThisPtr may be null if the member function has an explicit 'this'
2021+
// parameter.
2022+
if (!ThisPtr.isNull()) {
20242023
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
20252024
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
2026-
ThisPtrType =
2027-
DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
2025+
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
20282026
Elts.push_back(ThisPtrType);
20292027
}
20302028

20312029
// Copy rest of the arguments.
20322030
for (unsigned i = 1, e = Args.size(); i != e; ++i)
20332031
Elts.push_back(Args[i]);
20342032

2035-
// Attach FlagObjectPointer to the explicit "this" parameter.
2036-
if (HasExplicitObjectParameter) {
2037-
assert(Elts.size() >= 2 && Args.size() >= 2 &&
2038-
"Expected at least return type and object parameter.");
2039-
Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
2040-
}
2041-
20422033
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
20432034

20442035
return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
@@ -5127,7 +5118,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
51275118
llvm::DIType *CachedTy = getTypeOrNull(QualTy);
51285119
if (CachedTy)
51295120
Ty = CachedTy;
5130-
return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
5121+
return DBuilder.createObjectPointerType(Ty);
51315122
}
51325123

51335124
void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(

clang/test/CodeGenCXX/debug-info-object-pointer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
66
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer
77
//
8+
// // FIXME: DIFlagObjectPointer not attached to the explicit object
9+
// // argument in the subprogram declaration.
810
// CHECK: !DISubprogram(name: "explicit_this",
911
// flags: DIFlagPrototyped
10-
//
11-
// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
12-
// CHECK-SAME: flags: DIFlagObjectPointer)
12+
// CHECK-NOT: DIFlagObjectPointer
13+
// CHECK-NOT: DIFlagArtificial
1314
//
1415
// CHECK: !DILocalVariable(name: "this", arg: 1
1516
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer

llvm/include/llvm-c/DebugInfo.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -870,16 +870,13 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
870870
LLVMMetadataRef Ty);
871871

872872
/**
873-
* Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
874-
* is true, then also set FlagArtificial.
873+
* Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
875874
* \param Builder The DIBuilder.
876875
* \param Type The underlying type to which this pointer points.
877-
* \param Implicit Indicates whether this pointer was implicitly generated
878-
* (i.e., not spelled out in source).
879876
*/
880-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
881-
LLVMMetadataRef Type,
882-
LLVMBool Implicit);
877+
LLVMMetadataRef
878+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
879+
LLVMMetadataRef Type);
883880

884881
/**
885882
* Create debugging information entry for a qualified

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ namespace llvm {
662662
/// Create a uniqued clone of \p Ty with FlagArtificial set.
663663
static DIType *createArtificialType(DIType *Ty);
664664

665-
/// Create a uniqued clone of \p Ty with FlagObjectPointer set.
666-
/// If \p Implicit is true, also set FlagArtificial.
667-
static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
665+
/// Create a uniqued clone of \p Ty with FlagObjectPointer and
666+
/// FlagArtificial set.
667+
static DIType *createObjectPointerType(DIType *Ty);
668668

669669
/// Create a permanent forward-declared type.
670670
DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,

llvm/lib/IR/DIBuilder.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,11 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
644644
return createTypeWithFlags(Ty, DINode::FlagArtificial);
645645
}
646646

647-
DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
647+
DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
648648
// FIXME: Restrict this to the nodes where it's valid.
649649
if (Ty->isObjectPointer())
650650
return Ty;
651-
DINode::DIFlags Flags = DINode::FlagObjectPointer;
652-
653-
if (Implicit)
654-
Flags |= DINode::FlagArtificial;
655-
651+
DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
656652
return createTypeWithFlags(Ty, Flags);
657653
}
658654

llvm/lib/IR/DebugInfo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,11 +1432,10 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
14321432
PropertyAttributes, unwrapDI<DIType>(Ty)));
14331433
}
14341434

1435-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1436-
LLVMMetadataRef Type,
1437-
LLVMBool Implicit) {
1438-
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
1439-
Implicit));
1435+
LLVMMetadataRef
1436+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1437+
LLVMMetadataRef Type) {
1438+
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
14401439
}
14411440

14421441
LLVMMetadataRef

0 commit comments

Comments
 (0)