[PATCH] D92558: [llvm-rc] Handle driveless absolute windows paths when loading external files
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 10 04:11:33 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG879c15e890b4: [llvm-rc] Handle driveless absolute windows paths when loading external files (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92558/new/
https://reviews.llvm.org/D92558
Files:
llvm/test/tools/llvm-rc/absolute.test
llvm/tools/llvm-rc/ResourceFileWriter.cpp
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===================================================================
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1514,8 +1514,16 @@
SmallString<128> Cwd;
std::unique_ptr<MemoryBuffer> Result;
- // 0. The file path is absolute and the file exists.
- if (sys::path::is_absolute(File))
+ // 0. The file path is absolute or has a root directory, so we shouldn't
+ // try to append it on top of other base directories. (An absolute path
+ // must have a root directory, but e.g. the path "\dir\file" on windows
+ // isn't considered absolute, but it does have a root directory. As long as
+ // sys::path::append doesn't handle appending an absolute path or a path
+ // starting with a root directory on top of a base, we must handle this
+ // case separately at the top. C++17's path::append handles that case
+ // properly though, so if using that to append paths below, this early
+ // exception case could be removed.)
+ if (sys::path::has_root_directory(File))
return errorOrToExpected(MemoryBuffer::getFile(File, -1, false));
// 1. The current working directory.
Index: llvm/test/tools/llvm-rc/absolute.test
===================================================================
--- llvm/test/tools/llvm-rc/absolute.test
+++ llvm/test/tools/llvm-rc/absolute.test
@@ -1,3 +1,7 @@
; RUN: touch %t.manifest
; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
; RUN: llvm-rc -- %t.rc
+;; On Windows, try stripping out the drive name from the absolute path,
+;; and make sure the path still is found.
+; RUN: cat %t.rc | sed 's/"[a-zA-Z]:/"/' > %t2.rc
+; RUN: llvm-rc -- %t2.rc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92558.310835.patch
Type: text/x-patch
Size: 1694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201210/e7ab93eb/attachment.bin>
More information about the llvm-commits
mailing list