Skip to content

Commit f0adc90

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

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
@@ -455,11 +455,12 @@ void decodeMDNode(MDNode *N, unsigned &X, unsigned &Y, unsigned &Z);
455455
template <typename T> std::string getFullPath(const T *Scope) {
456456
if (!Scope)
457457
return std::string();
458-
std::string Filename = Scope->getFilename().str();
459-
if (sys::path::is_absolute(Filename))
460-
return Filename;
458+
StringRef Filename = Scope->getFilename();
459+
auto Style = sys::path::Style::native;
460+
if (sys::path::is_absolute(Filename, Style))
461+
return Filename.str();
461462
SmallString<16> DirName = Scope->getDirectory();
462-
sys::path::append(DirName, sys::path::Style::posix, Filename);
463+
sys::path::append(DirName, Style, Filename.str());
463464
return DirName.str().str();
464465
}
465466

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
@@ -51,7 +51,7 @@ attributes #0 = { convergent noinline nounwind optnone "correctly-rounded-divide
5151
!6 = !{i32 1, i32 2}
5252
!7 = !{!"clang version 8.0.0 (cfe/trunk)"}
5353
!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)
54-
; CHECK: String [[ID:[0-9]+]] "/tmp/RelativeSrcPath.cl"
54+
; CHECK: String [[ID:[0-9]+]] "/tmp{{[/\\]}}RelativeSrcPath.cl"
5555
; CHECK: Line [[ID]]
5656
!9 = !DIFile(filename: "RelativeSrcPath.cl", directory: "/tmp")
5757
!10 = !DISubroutineType(types: !2)

0 commit comments

Comments
 (0)