IncludeDir = dwarf::toStringRef(IncludeDirectories[Entry.DirIdx - 1]);
}
- // For absolute paths only, include the compilation directory of compile unit.
- // We know that FileName is not absolute, the only way to have an absolute
- // path at this point would be if IncludeDir is absolute.
- if (Kind == FileLineInfoKind::AbsoluteFilePath && !CompDir.empty() &&
+ // For absolute paths only, include the compilation directory of compile unit,
+ // unless v5 DirIdx == 0 (IncludeDir indicates the compilation directory). We
+ // know that FileName is not absolute, the only way to have an absolute path
+ // at this point would be if IncludeDir is absolute.
+ if (Kind == FileLineInfoKind::AbsoluteFilePath &&
+ (getVersion() < 5 || Entry.DirIdx != 0) && !CompDir.empty() &&
!isPathAbsoluteOnWindowsOrPosix(IncludeDir))
sys::path::append(FilePath, Style, CompDir);
# RUN: llvm-symbolizer --verbose 0x0 --obj=test.o | FileCheck --check-prefix=SYM %s
# RUN: llvm-dwarfdump -lookup=0x1 test.o | FileCheck --check-prefix=LOOKUP %s
-# SYM: Filename: .{{[/\\]}}.{{[/\\]}}test.c
-# SYM: Function start filename: .{{[/\\]}}.{{[/\\]}}test.c
+# SYM: Filename: .{{[/\\]}}test.c
+# SYM: Function start filename: .{{[/\\]}}test.c
# LOOKUP: Line info: line 0, column 0, start file 'test.c', start line 1
# MAP_V5: DW_AT_name [DW_FORM_string] ("src.s")
# MAP_V5: DW_AT_comp_dir [DW_FORM_string] ("src_root")
-## FIXME llvm-dwarfdump incorrectly joins include_directories[0] to DW_AT_comp_dir,
-## so there are two src_root path components.
-# MAP_V5: DW_AT_decl_file [DW_FORM_data4] ("src_root{{(/|\\)+}}src_root{{(/|\\)+}}src.s")
+# MAP_V5: DW_AT_decl_file [DW_FORM_data4] ("src_root{{(/|\\)+}}src.s")
# MAP_V5: include_directories[ 0] = .debug_line_str[0x00000000] = "src_root"
# MAPABS_V4: DW_AT_name [DW_FORM_string] ("src.s")
# MAPABS_V4: DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root")
-# MAPABS_V4: DW_AT_decl_file [DW_FORM_data4] ("{{(/|\\)+}}src_root{{(/|\\)+}}src.s")
+# MAPABS_V4: DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}src.s")
# MAPABS_V4-NOT: .foo
# MAPABS_V5: DW_AT_name [DW_FORM_string] ("src.s")