[llvm] r346450 - [llvm-rc] Support absolute filenames in manifests

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 8 15:45:00 PST 2018


Author: phosek
Date: Thu Nov  8 15:45:00 2018
New Revision: 346450

URL: http://llvm.org/viewvc/llvm-project?rev=346450&view=rev
Log:
[llvm-rc] Support absolute filenames in manifests

CMake generate manifests that contain absolute filenames and these
currently result in assertion error. This change ensures that we
handle these correctly.

Differential Revision: https://reviews.llvm.org/D54194

Added:
    llvm/trunk/test/tools/llvm-rc/absolute.test
Modified:
    llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp

Added: llvm/trunk/test/tools/llvm-rc/absolute.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/absolute.test?rev=346450&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/absolute.test (added)
+++ llvm/trunk/test/tools/llvm-rc/absolute.test Thu Nov  8 15:45:00 2018
@@ -0,0 +1,3 @@
+; RUN: touch %t.manifest
+; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
+; RUN: llvm-rc %t.rc

Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp?rev=346450&r1=346449&r2=346450&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp Thu Nov  8 15:45:00 2018
@@ -1502,6 +1502,10 @@ ResourceFileWriter::loadFile(StringRef F
   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());
@@ -1510,8 +1514,7 @@ ResourceFileWriter::loadFile(StringRef F
     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);




More information about the llvm-commits mailing list