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 @@ -3734,7 +3734,8 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F) { - if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly) + if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly && + !CGM.getCodeGenOpts().EmitCodeView)) // Create fake but valid subroutine type. Otherwise -verify would fail, and // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields. return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None)); diff --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp --- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp +++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp @@ -5,7 +5,6 @@ namespace NS { struct C { -public: void m() {} }; void f() {} @@ -14,17 +13,23 @@ NS::C c; void test() { - // CHECK: ![[EMPTY:[0-9]+]] = !{} // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]], // CHECK-SAME: type: ![[F:[0-9]+]] // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null) - // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]]) + // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]]) + // CHECK: ![[FTYPE]] = !{null} NS::f(); - // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]], - // CHECK-SAME: type: ![[F]] + // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]], + // CHECK-SAME: type: ![[MTYPE:[0-9]+]] // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C", // CHECK-SAME: flags: DIFlagFwdDecl // CHECK-NOT: identifier c.m(); + + // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]] + // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type, + // CHECK-SAME: flags: DIFlagFwdDecl + auto lambda1 = []() {}; + lambda1(); }