Skip to content

Commit 0d951bf

Browse files
authored
Merge pull request #23100 from apple/revert-23076-48509051
2 parents 2e6b0cb + 7035047 commit 0d951bf

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
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 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-
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+
}
251251
return getSwiftDebugLoc(DI, D, End);
252252
}
253253

test/ClangImporter/objc_ir.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,10 @@ 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]+}}, baseType: !{{[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]+}})
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]+}}, baseType: !{{[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]+}})
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]+}}, baseType: !{{[0-9]+}})
370-
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]+}})

test/DebugInfo/ClangPathDots.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// REQUIRES: objc_interop
2+
// RUN: rm -rf %t.cache
3+
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - \
4+
// RUN: -module-cache-path %t.cache | %FileCheck %s --check-prefix=FIRST
5+
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - \
6+
// RUN: -module-cache-path %t.cache | %FileCheck %s --check-prefix=CACHED
7+
8+
// Test that the paths have no extra "./" components on rebuild.
9+
10+
// FIRST: !DIFile(filename: "{{.*}}/include/objc/NSObject.h",
11+
// CACHED: !DIFile(filename: "{{.*}}/include/objc/NSObject.h",
12+
13+
import ObjectiveC
14+
15+
extension NSObject : CVarArg {
16+
/// Transform `self` into a series of machine words that can be
17+
/// appropriately interpreted by C varargs
18+
public var _cVarArgEncoding: [Int] {
19+
_autorelease(self)
20+
return _encodeBitsAsWords(self)
21+
}
22+
}
23+

0 commit comments

Comments
 (0)