Skip to content

Commit 834db1a

Browse files
[Backport to llvm_release_200] [DebugInfo] Use native for the system separator for source path string (#3169)
Backport of PR #3157 into `llvm_release_200`. All commits applied cleanly. Signed-off-by: Sidorov, Dmitry <[email protected]> Co-authored-by: Dmitry Sidorov <[email protected]>
1 parent 19d0732 commit 834db1a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/SPIRV/OCLUtil.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ SmallVector<unsigned, 3> decodeMDNode(MDNode *N);
461461
template <typename T> std::string getFullPath(const T *Scope) {
462462
if (!Scope)
463463
return std::string();
464-
std::string Filename = Scope->getFilename().str();
465-
if (sys::path::is_absolute(Filename))
466-
return Filename;
464+
StringRef Filename = Scope->getFilename();
465+
auto Style = sys::path::Style::native;
466+
if (sys::path::is_absolute(Filename, Style))
467+
return Filename.str();
467468
SmallString<16> DirName = Scope->getDirectory();
468-
sys::path::append(DirName, sys::path::Style::posix, Filename);
469+
sys::path::append(DirName, Style, Filename.str());
469470
return DirName.str().str();
470471
}
471472

test/DebugInfo/LocalAddressSpace.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
; CHECK: DW_TAG_variable
2323
; CHECK-NEXT: DW_AT_name {{.*}} = "a")
2424
; CHECK-NEXT: DW_AT_type {{.*}} "int")
25-
; CHECK-NEXT: DW_AT_decl_file {{.*}} ("/work/tmp{{[/\\]}}tmp.cl")
25+
; CHECK-NEXT: DW_AT_decl_file {{.*}} ("/work{{[/\\]}}tmp{{[/\\]}}tmp.cl")
2626
; CHECK-NEXT: DW_AT_decl_line {{.*}} (2)
2727
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0)
2828

test/RelativeSrcPath.ll renamed to test/DebugInfo/RelativeSrcPath.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ attributes #0 = { convergent noinline nounwind optnone "correctly-rounded-divide
4949
!6 = !{i32 1, i32 2}
5050
!7 = !{!"clang version 8.0.0 (cfe/trunk)"}
5151
!8 = distinct !DISubprogram(name: "foo", scope: !9, file: !9, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
52-
; CHECK: String [[ID:[0-9]+]] "/tmp/RelativeSrcPath.cl"
52+
; CHECK: String [[ID:[0-9]+]] "/tmp{{[/\\]}}RelativeSrcPath.cl"
5353
; CHECK: Line [[ID]]
5454
!9 = !DIFile(filename: "RelativeSrcPath.cl", directory: "/tmp")
5555
!10 = !DISubroutineType(types: !2)

0 commit comments

Comments
 (0)