@@ -2067,20 +2067,29 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
20672067 // First element is always return type. For 'void' functions it is NULL.
20682068 Elts.push_back (Args[0 ]);
20692069
2070- // "this" pointer is always first argument.
2071- // ThisPtr may be null if the member function has an explicit 'this'
2072- // parameter.
2073- if (!ThisPtr.isNull ()) {
2070+ const bool HasExplicitObjectParameter = ThisPtr.isNull ();
2071+
2072+ // "this" pointer is always first argument. For explicit "this"
2073+ // parameters, it will already be in Args[1].
2074+ if (!HasExplicitObjectParameter) {
20742075 llvm::DIType *ThisPtrType = getOrCreateType (ThisPtr, Unit);
20752076 TypeCache[ThisPtr.getAsOpaquePtr ()].reset (ThisPtrType);
2076- ThisPtrType = DBuilder.createObjectPointerType (ThisPtrType);
2077+ ThisPtrType =
2078+ DBuilder.createObjectPointerType (ThisPtrType, /* Implicit=*/ true );
20772079 Elts.push_back (ThisPtrType);
20782080 }
20792081
20802082 // Copy rest of the arguments.
20812083 for (unsigned i = 1 , e = Args.size (); i != e; ++i)
20822084 Elts.push_back (Args[i]);
20832085
2086+ // Attach FlagObjectPointer to the explicit "this" parameter.
2087+ if (HasExplicitObjectParameter) {
2088+ assert (Elts.size () >= 2 && Args.size () >= 2 &&
2089+ " Expected at least return type and object parameter." );
2090+ Elts[1 ] = DBuilder.createObjectPointerType (Args[1 ], /* Implicit=*/ false );
2091+ }
2092+
20842093 llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray (Elts);
20852094
20862095 return DBuilder.createSubroutineType (EltTypeArray, OriginalFunc->getFlags (),
@@ -5499,7 +5508,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
54995508 llvm::DIType *CachedTy = getTypeOrNull (QualTy);
55005509 if (CachedTy)
55015510 Ty = CachedTy;
5502- return DBuilder.createObjectPointerType (Ty);
5511+ return DBuilder.createObjectPointerType (Ty, /* Implicit= */ true );
55035512}
55045513
55055514void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable (
0 commit comments