if (PLoc.isValid()) {
OS << " at ";
StringRef File = PLoc.getFilename();
+ llvm::SmallString<1024> WrittenFile(File);
if (auto *Callbacks = Policy.Callbacks)
- OS << Callbacks->remapPath(File);
- else
- OS << File;
- OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+ WrittenFile = Callbacks->remapPath(File);
+ // Fix inconsistent path separator created by
+ // clang::DirectoryLookup::LookupFile when the file path is relative
+ // path.
+ llvm::sys::path::Style Style =
+ !llvm::sys::path::is_absolute(WrittenFile) && Policy.MSVCFormatting
+ ? llvm::sys::path::Style::windows_backslash
+ : llvm::sys::path::Style::native;
+ llvm::sys::path::native(WrittenFile, Style);
+ OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
}
}
--- /dev/null
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN: lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h