[PATCH] D59415: Do not resolve directory junctions for `-fdiagnostics-absolute-paths` on Windows.
Igor Kudrin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 20 04:35:29 PDT 2019
ikudrin updated this revision to Diff 200252.
ikudrin added a comment.
- Made the patch affect only `-fdiagnostics-absolute-paths` option.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59415/new/
https://reviews.llvm.org/D59415
Files:
lib/Frontend/TextDiagnostic.cpp
test/Frontend/absolute-paths-windows.test
test/Frontend/lit.local.cfg
Index: test/Frontend/lit.local.cfg
===================================================================
--- test/Frontend/lit.local.cfg
+++ test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl', '.test']
Index: test/Frontend/absolute-paths-windows.test
===================================================================
--- /dev/null
+++ test/Frontend/absolute-paths-windows.test
@@ -0,0 +1,9 @@
+// REQUIRES: system-windows
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir\real
+// RUN: cmd /c mklink /j %t.dir\junc %t.dir\real
+// RUN: echo "wrong code" > %t.dir\real\foo.cpp
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-absolute-paths %t.dir\junc\foo.cpp 2>&1 | FileCheck %s
+
+// CHECK-NOT: .dir\real\foo.cpp
+// CHECK: .dir\junc\foo.cpp
Index: lib/Frontend/TextDiagnostic.cpp
===================================================================
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -765,7 +765,14 @@
const DirectoryEntry *Dir = SM.getFileManager().getDirectory(
llvm::sys::path::parent_path(Filename));
if (Dir) {
+#ifdef _WIN32
+ SmallString<4096> DirName = Dir->getName();
+ llvm::sys::fs::make_absolute(DirName);
+ llvm::sys::path::native(DirName);
+ llvm::sys::path::remove_dots(DirName, /* remove_dot_dot */ true);
+#else
StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
+#endif
llvm::sys::path::append(AbsoluteFilename, DirName,
llvm::sys::path::filename(Filename));
Filename = StringRef(AbsoluteFilename.data(), AbsoluteFilename.size());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59415.200252.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190520/90156a41/attachment.bin>
More information about the cfe-commits
mailing list