Skip to content

[Serialization] Do not absolute path the serialized line directive #37130

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
Apr 29, 2021
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
5 changes: 1 addition & 4 deletions lib/Serialization/SerializeDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,7 @@ static void writeRawLoc(const ExternalSourceLocs::RawLoc &Loc,
Writer.write<uint32_t>(Loc.Directive.Offset);
Writer.write<int32_t>(Loc.Directive.LineOffset);
Writer.write<uint32_t>(Loc.Directive.Length);
llvm::SmallString<128> AbsName = Loc.Directive.Name;
if (!AbsName.empty())
llvm::sys::fs::make_absolute(AbsName);
Writer.write<uint32_t>(Strings.getTextOffset(AbsName.str()));
Writer.write<uint32_t>(Strings.getTextOffset(Loc.Directive.Name));
}

/**
Expand Down
9 changes: 7 additions & 2 deletions test/diagnostics/multi-module-diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ open class ParentClass {
open func overridableMethodA(param: Int) {}
open func overridableMethodB(param: Int) {}
open func overridableMethodC(param: Int) {}
open func overridableMethodD(param: Int) {}
}
#endif

#if MODA_LOC
open class ParentClass {
#sourceLocation(file: "doesnotexist.swift", line: 10)
open func overridableMethodA(param: Int) {}
#sourceLocation(file: "REPLACEDWITHSED", line: 20)
open func overridableMethodB(param: Int) {}
#sourceLocation(file: "REPLACEDWITHSED", line: 20)
open func overridableMethodC(param: Int) {}
open func overridableMethodD(param: Int) {}
#sourceLocation()
}
#endif
Expand All @@ -24,6 +26,7 @@ open class SubClass: ParentClass {
open override func overridableMethodA(param: String) {}
open override func overridableMethodB(param: String) {}
open override func overridableMethodC(param: String) {}
open override func overridableMethodD(param: String) {}
}
#endif

Expand All @@ -41,6 +44,7 @@ open class SubClass: ParentClass {
// CHECK-EXISTS: moda.swift:3:13: note
// CHECK-EXISTS: moda.swift:4:13: note
// CHECK-EXISTS: moda.swift:5:13: note
// CHECK-EXISTS: moda.swift:6:13: note

// Removed the underlying file, so should use the generated source instead
// RUN: mv %t/moda.swift %t/moda.swift-moved
Expand All @@ -65,7 +69,8 @@ open class SubClass: ParentClass {

// RUN: cp %t/moda.swift %t/alternative.swift
// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-DIRECTIVE %s
// CHECK-DIRECTIVE: doesnotexist.swift:10:13: note
// CHECK-DIRECTIVE: {{^}}doesnotexist.swift:10:13: note
// CHECK-DIRECTIVE: {{^}}doesnotexist.swift:11:13: note
// CHECK-DIRECTIVE: alternative.swift:20:13: note
// CHECK-DIRECTIVE: alternative.swift:21:13: note

Expand Down