Skip to content

Revert " Stop producing line and file debug information for clang::Decls." #23100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
if (!D)
return L;

// If D is a clang::Decl, it would be nice to query the clang::SourceManager
// for the source location of the clang::Decl here, but module out-of-date
// rebuilds may unload previously loaded clang::Modules and thus also
// invalidate source locations pointed to, leading to a use-after-free
// here. If this functionality is desired, the source location must be
// captured by ClangImporter and stored on the side.
// LLDB only uses the DW_AT_decl_file / DW_AT_decl_line for C++ types.

if (auto *ClangDecl = D->getClangDecl()) {
auto ClangSrcLoc = ClangDecl->getBeginLoc();
clang::SourceManager &ClangSM =
CI.getClangASTContext().getSourceManager();
L.Line = ClangSM.getPresumedLineNumber(ClangSrcLoc);
L.Filename = ClangSM.getBufferName(ClangSrcLoc);
return L;
}
return getSwiftDebugLoc(DI, D, End);
}

Expand Down
7 changes: 3 additions & 4 deletions test/ClangImporter/objc_ir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,10 @@ func testBlocksWithGenerics(hba: HasBlockArray) -> Any {
// CHECK: attributes [[NOUNWIND]] = { nounwind }

// 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]+]])
// CHECK: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
// CHECK: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}})

// 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]+]])
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo21SwiftGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
// 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]+}})

// 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]+]])
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo27SwiftConstrGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})

// 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]+}})
23 changes: 23 additions & 0 deletions test/DebugInfo/ClangPathDots.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// REQUIRES: objc_interop
// RUN: rm -rf %t.cache
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - \
// RUN: -module-cache-path %t.cache | %FileCheck %s --check-prefix=FIRST
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - \
// RUN: -module-cache-path %t.cache | %FileCheck %s --check-prefix=CACHED

// Test that the paths have no extra "./" components on rebuild.

// FIRST: !DIFile(filename: "{{.*}}/include/objc/NSObject.h",
// CACHED: !DIFile(filename: "{{.*}}/include/objc/NSObject.h",

import ObjectiveC

extension NSObject : CVarArg {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs
public var _cVarArgEncoding: [Int] {
_autorelease(self)
return _encodeBitsAsWords(self)
}
}