[PATCH] D54194: [llvm-rc] Support absolute filenames in manifests

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 17:45:06 PST 2018


phosek updated this revision to Diff 173104.
phosek added a comment.

Test added.


Repository:
  rL LLVM

https://reviews.llvm.org/D54194

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
@@ -1502,16 +1502,19 @@
   SmallString<128> Cwd;
   std::unique_ptr<MemoryBuffer> Result;
 
+  // 0. The file path is absolute and the file exists.
+  if (sys::path::is_absolute(File))
+    return errorOrToExpected(MemoryBuffer::getFile(File, -1, false));
+
   // 1. The current working directory.
   sys::fs::current_path(Cwd);
   Path.assign(Cwd.begin(), Cwd.end());
   sys::path::append(Path, File);
   if (sys::fs::exists(Path))
     return errorOrToExpected(MemoryBuffer::getFile(Path, -1, false));
 
   // 2. The directory of the input resource file, if it is different from the
-  // current
-  //    working directory.
+  // current working directory.
   StringRef InputFileDir = sys::path::parent_path(Params.InputFilePath);
   Path.assign(InputFileDir.begin(), InputFileDir.end());
   sys::path::append(Path, File);
Index: llvm/test/tools/llvm-rc/absolute.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-rc/absolute.test
@@ -0,0 +1,5 @@
+; RUN: touch %t.manifest
+; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
+; RUN: llvm-rc %t.rc 2>&1 | FileCheck %s --allow-empty
+
+; CHECK-NOT: Assertion `!path::is_absolute(FileName)' failed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54194.173104.patch
Type: text/x-patch
Size: 1411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/f926600d/attachment.bin>


More information about the llvm-commits mailing list