kamleshbhalui created this revision. kamleshbhalui added reviewers: dblaikie, aprantl. kamleshbhalui added a project: LLVM. Herald added a subscriber: mstorsjo. kamleshbhalui requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Clang emits duplicate file entry in object file on windows platform(when windows style path appended with posix style path or vice versa). which becomes problem for some debugger(not able to put break point on the file which has duplicate entry). By making sure it's native path before creating DIFile above problem goes away. Testcase Demonstration of problem on llvm-dev: https://lists.llvm.org/pipermail/llvm-dev/2021-March/149501.html Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D99580 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGen/debug-info-mingw.c Index: clang/test/CodeGen/debug-info-mingw.c =================================================================== --- /dev/null +++ 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 Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -443,6 +443,10 @@ Optional<StringRef> 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); }
Index: clang/test/CodeGen/debug-info-mingw.c =================================================================== --- /dev/null +++ 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 Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -443,6 +443,10 @@ Optional<StringRef> 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); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits