Skip to content

Commit 1ea700a

Browse files
Merge pull request #23076 from adrian-prantl/48509051
Stop producing line and file debug information for clang::Decls.
2 parents dcd1924 + b63ab45 commit 1ea700a

File tree

3 files changed

+12
-34
lines changed

3 files changed

+12
-34
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
240240
if (!D)
241241
return L;
242242

243-
if (auto *ClangDecl = D->getClangDecl()) {
244-
auto ClangSrcLoc = ClangDecl->getBeginLoc();
245-
clang::SourceManager &ClangSM =
246-
CI.getClangASTContext().getSourceManager();
247-
L.Line = ClangSM.getPresumedLineNumber(ClangSrcLoc);
248-
L.Filename = ClangSM.getBufferName(ClangSrcLoc);
249-
return L;
250-
}
243+
// If D is a clang::Decl, it would be nice to query the clang::SourceManager
244+
// for the source location of the clang::Decl here, but module out-of-date
245+
// rebuilds may unload previously loaded clang::Modules and thus also
246+
// invalidate source locations pointed to, leading to a use-after-free
247+
// here. If this functionality is desired, the source location must be
248+
// captured by ClangImporter and stored on the side.
249+
// LLDB only uses the DW_AT_decl_file / DW_AT_decl_line for C++ types.
250+
251251
return getSwiftDebugLoc(DI, D, End);
252252
}
253253

test/ClangImporter/objc_ir.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,11 @@ func testBlocksWithGenerics(hba: HasBlockArray) -> Any {
360360
// CHECK: attributes [[NOUNWIND]] = { nounwind }
361361

362362
// CHECK: ![[SWIFT_NAME_ALIAS_VAR]] = !DILocalVariable(name: "obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[SWIFT_NAME_ALIAS_TYPE:[0-9]+]])
363-
// CHECK: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}})
363+
// CHECK: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
364364

365365
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
366-
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo21SwiftGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}})
366+
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo21SwiftGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
367367

368368
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "constr_generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
369-
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo27SwiftConstrGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}})
369+
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo27SwiftConstrGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
370+

test/DebugInfo/ClangPathDots.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)