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 @@ -4217,7 +4217,7 @@ llvm::DISubprogram *SP = DBuilder.createFunction(FDContext, Name, LinkageName, Unit, LineNo, STy, ScopeLine, Flags, SPFlags, TParamsArray.get(), - getFunctionDeclaration(D), nullptr, Annotations); + nullptr, nullptr, Annotations); // Preserve btf_decl_tag attributes for parameters of extern functions // for BPF target. The parameters created in this loop are attached as diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5772,11 +5772,12 @@ .. _DISubprogramDeclaration: -When ``isDefinition: false``, subprograms describe a declaration in the type -tree as opposed to a definition of a function. If the scope is a composite -type with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``, -then the subprogram declaration is uniqued based only on its ``linkageName:`` -and ``scope:``. +When ``spFlags: DISPFlagDefinition`` is not present, subprograms describe a +declaration in the type tree as opposed to a definition of a function. In this +case, the ``declaration`` field must be empty. If the scope is a composite type +with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``, then +the subprogram declaration is uniqued based only on its ``linkageName:`` and +``scope:``. .. code-block:: text @@ -5785,9 +5786,9 @@ } !0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1, - file: !2, line: 7, type: !3, isLocal: true, - isDefinition: true, scopeLine: 8, - containingType: !4, + file: !2, line: 7, type: !3, + spFlags: DISPFlagDefinition | DISPFlagLocalToUnit, + scopeLine: 8, containingType: !4, virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10, flags: DIFlagPrototyped, isOptimized: true, unit: !5, templateParams: !6, diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1400,6 +1400,8 @@ } else { // Subprogram declarations (part of the type hierarchy). CheckDI(!Unit, "subprogram declarations must not have a compile unit", &N); + CheckDI(!N.getRawDeclaration(), + "subprogram declaration must not have a declaration field"); } if (auto *RawThrownTypes = N.getRawThrownTypes()) {