[PATCH] D42326: [COFF] add option to avoid overwriting unchanged import libraries

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 17:11:15 PST 2018


ruiu added inline comments.


================
Comment at: lld/COFF/Driver.cpp:546
+  if (Config->KeepUnchangedImplib) {
+    auto OldBuf = MemoryBuffer::getFile(Path);
+    if (OldBuf) {
----------------
Please write the actual type instead of `auto`.


================
Comment at: lld/COFF/Driver.cpp:549-550
+      SmallString<128> TmpName;
+      auto EC = sys::fs::createUniqueFile(Path + ".tmp-%%%%%%%%.lib", TmpName);
+      if (EC)
+        fatal("Cannot create temporary file for import library " + Path + ": " +
----------------
if (auto EC = ...)


================
Comment at: lld/COFF/Driver.cpp:551
+      if (EC)
+        fatal("Cannot create temporary file for import library " + Path + ": " +
+              EC.message());
----------------
Error messages should start with a lowercase letter.


================
Comment at: lld/COFF/Driver.cpp:556
+      if (!E) {
+        auto NewBuf = check(MemoryBuffer::getFile(TmpName));
+        if ((*OldBuf)->getBuffer() != NewBuf->getBuffer()) {
----------------
Ditto


================
Comment at: lld/COFF/Driver.cpp:558
+        if ((*OldBuf)->getBuffer() != NewBuf->getBuffer()) {
+          OldBuf->reset();
+          auto EC = sys::fs::rename(TmpName, Path);
----------------
Do you have to call `reset`?


================
Comment at: lld/COFF/Driver.cpp:559-560
+          OldBuf->reset();
+          auto EC = sys::fs::rename(TmpName, Path);
+          if (EC)
+            HandleError(errorCodeToError(EC));
----------------
if (auto EC = ...


https://reviews.llvm.org/D42326





More information about the llvm-commits mailing list