Skip to content

Commit 9e8e56e

Browse files
committed
Fix a regression that caused the compiler to drop the path names of generated
macro expansion source code when emitting DWARF 4 or earlier. rdar://126688061
1 parent 470a04c commit 9e8e56e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
325325
}
326326
}
327327
Cached.File = getOrCreateFile(
328-
SM.getDisplayNameForLoc(SL, !ForceGeneratedSourceToDisk), Source);
328+
SM.getDisplayNameForLoc(SL, ForceGeneratedSourceToDisk), Source);
329329
std::tie(Cached.Line, Cached.Column) =
330330
SM.getPresumedLineAndColumnForLoc(SL);
331331
// When WinDbg finds two locations with the same line but different

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ const SILDebugScope *SILGenFunction::getMacroScope(SourceLoc SLoc) {
373373
TopLevelScope = It->second;
374374
else {
375375
// Recursively create one inlined function + scope per layer of generated
376-
// sources. Chains of Macro expansions are representad as flat
376+
// sources. Chains of Macro expansions are represented as flat
377377
// function-level scopes.
378378
SILGenFunctionBuilder B(SGM);
379379
auto &ASTContext = SGM.M.getASTContext();

test/Macros/macro_expand.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// RUN: %target-swift-frontend -swift-version 5 -emit-sil -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name MacroUser -o - -g | %FileCheck --check-prefix CHECK-SIL %s
2525

2626
// Debug info IR testing
27+
// RUN: %target-swift-frontend -swift-version 5 -dwarf-version=4 -emit-ir -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name MacroUser -o - -g | %FileCheck --check-prefix CHECK-IR-DWARF4 %s
2728
// RUN: %target-swift-frontend -swift-version 5 -dwarf-version=5 -emit-ir -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name MacroUser -o - -g | %FileCheck --check-prefix CHECK-IR %s
2829

2930
// Execution testing
@@ -71,7 +72,7 @@ struct MemberNotCovered {
7172
// expected-note@-1 {{in expansion of macro 'NotCovered' here}}
7273

7374
// CHECK-DIAGS: error: declaration name 'value' is not covered by macro 'NotCovered'
74-
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX69_2_33_4361AD9339943F52AE6186DD51E04E91Ll10NotCoveredfMf_.swift
75+
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX70_2_33_4361AD9339943F52AE6186DD51E04E91Ll10NotCoveredfMf_.swift
7576
// CHECK-DIAGS: var value: Int
7677
// CHECK-DIAGS: END CONTENTS OF FILE
7778
}
@@ -163,9 +164,10 @@ func testFileID(a: Int, b: Int) {
163164
// CHECK-AST: macro_expansion_expr type='String'{{.*}}name=line
164165
print("Builtin result is \(#fileID)")
165166
print(
166-
// CHECK-IR-DAG: ![[L1:[0-9]+]] = distinct !DILocation(line: [[@LINE+3]], column: 5
167+
// CHECK-IR-DAG: ![[L1:[0-9]+]] = distinct !DILocation(line: [[@LINE+4]], column: 5
167168
// CHECK-IR-DAG: ![[L2:[0-9]+]] = distinct !DILocation({{.*}}inlinedAt: ![[L1]])
168169
// CHECK-IR-DAG: !DIFile(filename: "{{.*}}@__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_.swift", {{.*}}source: "{{.*}}MacroUser/macro_expand.swift{{.*}}// original-source-range: {{.*}}")
170+
// CHECK-IR-DWARF4: !DIFile(filename: "{{.*}}generated-{{.*}}/@__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_.swift", directory: "")
169171
#addBlocker(
170172
#stringify(a - b)
171173
)

0 commit comments

Comments
 (0)