llvm-reduce: Remove some string copies

llvm-svn: 372053
This commit is contained in:
David Blaikie 2019-09-16 23:54:57 +00:00
parent f04bbad688
commit 1018faa8e7
2 changed files with 5 additions and 25 deletions

View File

@ -10,25 +10,8 @@
using namespace llvm; using namespace llvm;
/// Gets Current Working Directory and tries to create a Tmp Directory TestRunner::TestRunner(StringRef TestName, const std::vector<std::string> &TestArgs)
static SmallString<128> initializeTmpDirectory() { : TestName(TestName), TestArgs(TestArgs) {
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();
} }
/// Runs the interestingness test, passes file to be tested as first argument /// Runs the interestingness test, passes file to be tested as first argument

View File

@ -24,23 +24,20 @@ namespace llvm {
// respective filename. // respective filename.
class TestRunner { class TestRunner {
public: 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 /// Runs the interesting-ness test for the specified file
/// @returns 0 if test was successful, 1 if otherwise /// @returns 0 if test was successful, 1 if otherwise
int run(StringRef Filename); int run(StringRef Filename);
/// Directory where tmp files are created
StringRef getTmpDir() const { return TmpDirectory; }
/// Returns the most reduced version of the original testcase /// Returns the most reduced version of the original testcase
Module *getProgram() const { return Program.get(); } Module *getProgram() const { return Program.get(); }
void setProgram(std::unique_ptr<Module> P) { Program = std::move(P); } void setProgram(std::unique_ptr<Module> P) { Program = std::move(P); }
private: private:
SmallString<128> TestName; StringRef TestName;
std::vector<std::string> TestArgs; const std::vector<std::string> &TestArgs;
SmallString<128> TmpDirectory;
std::unique_ptr<Module> Program; std::unique_ptr<Module> Program;
}; };