[PATCH] D40606: [Support/TarWriter] - Don't allow TarWriter to add the same file more than once.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 14:40:35 PST 2017


ruiu added inline comments.


================
Comment at: include/llvm/Support/TarWriter.h:16
 #include "llvm/Support/raw_ostream.h"
+#include <set>
 
----------------
Please use llvm::StringSet.


================
Comment at: include/llvm/Support/TarWriter.h:24
 
-  void append(StringRef Path, StringRef Data);
+  bool append(StringRef Path, StringRef Data);
 
----------------
Just keep it return void as you are not going to use its return value.


================
Comment at: lib/Support/TarWriter.cpp:176
 
+  bool Exist;
+  std::tie(std::ignore, Exist) = Files.insert(Fullpath);
----------------
Exists


================
Comment at: lib/Support/TarWriter.cpp:177-178
+  bool Exist;
+  std::tie(std::ignore, Exist) = Files.insert(Fullpath);
+  if (Exist)
+    return false;
----------------
Or, just `if (Seen.insert(Fullpath).second) return;`


https://reviews.llvm.org/D40606





More information about the llvm-commits mailing list