diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -443,6 +443,10 @@ Optional Source) { StringRef Dir; StringRef File; + // Convert FileName to native path + SmallString<128> NativePath = FileName; + llvm::sys::path::native(NativePath); + FileName = NativePath.str(); std::string RemappedFile = remapDIPath(FileName); std::string CurDir = remapDIPath(getCurrentDirname()); SmallString<128> DirBuf; @@ -558,7 +562,10 @@ MainFile->getName().rsplit('.').second) .isPreprocessed()) MainFileName = CGM.getModule().getName().str(); - + // Convert MainFileName to native path + SmallString<128> NativePath = (StringRef)MainFileName; + llvm::sys::path::native(NativePath); + MainFileName = (std::string)NativePath.str(); CSKind = computeChecksum(SM.getMainFileID(), Checksum); } diff --git a/clang/test/CodeGen/debug-info-mingw.c b/clang/test/CodeGen/debug-info-mingw.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/debug-info-mingw.c @@ -0,0 +1,7 @@ +// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR +// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.c +// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited -main-file-name debug-info-mingw.c %t/UNIQUE_DIR/debug-info-mingw.c -emit-llvm -o - | FileCheck %s +int main() { +} +// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.c", +// UNSUPPORTED: !system-windows