]> granicus.if.org Git - llvm/commitdiff
llvm-reduce: Remove some string copies
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 16 Sep 2019 23:54:57 +0000 (23:54 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 16 Sep 2019 23:54:57 +0000 (23:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372053 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-reduce/TestRunner.cpp
tools/llvm-reduce/TestRunner.h

index 626003925278d2c80d6e3b11f92a29ec854540e3..d0e195d5697c96c34c91b0a6c41b1ec24f287d31 100644 (file)
 
 using namespace llvm;
 
-/// Gets Current Working Directory and tries to create a Tmp Directory
-static SmallString<128> initializeTmpDirectory() {
-  SmallString<128> CWD;
-  if (std::error_code EC = sys::fs::current_path(CWD)) {
-    errs() << "Error getting current directory: " << EC.message() << "!\n";
-    exit(1);
-  }
-
-  SmallString<128> TmpDirectory;
-  sys::path::append(TmpDirectory, CWD, "tmp");
-  if (std::error_code EC = sys::fs::create_directory(TmpDirectory))
-    errs() << "Error creating tmp directory: " << EC.message() << "!\n";
-
-  return TmpDirectory;
-}
-
-TestRunner::TestRunner(StringRef TestName, std::vector<std::string> TestArgs)
-    : TestName(TestName), TestArgs(std::move(TestArgs)) {
-  TmpDirectory = initializeTmpDirectory();
+TestRunner::TestRunner(StringRef TestName, const std::vector<std::string> &TestArgs)
+    : TestName(TestName), TestArgs(TestArgs) {
 }
 
 /// Runs the interestingness test, passes file to be tested as first argument
index 35235e2adebd5cb9eac90713c6b981f176dae707..2270d6bd90b27656659e62683cd80916c4624dae 100644 (file)
@@ -24,23 +24,20 @@ namespace llvm {
 // respective filename.
 class TestRunner {
 public:
-  TestRunner(StringRef TestName, std::vector<std::string> TestArgs);
+  TestRunner(StringRef TestName, const std::vector<std::string> &TestArgs);
 
   /// Runs the interesting-ness test for the specified file
   /// @returns 0 if test was successful, 1 if otherwise
   int run(StringRef Filename);
 
-  /// Directory where tmp files are created
-  StringRef getTmpDir() const { return TmpDirectory; }
   /// Returns the most reduced version of the original testcase
   Module *getProgram() const { return Program.get(); }
 
   void setProgram(std::unique_ptr<Module> P) { Program = std::move(P); }
 
 private:
-  SmallString<128> TestName;
-  std::vector<std::string> TestArgs;
-  SmallString<128> TmpDirectory;
+  StringRef TestName;
+  const std::vector<std::string> &TestArgs;
   std::unique_ptr<Module> Program;
 };