From 0ec50d179c26ac8fa6d50a005f8a7427933a9464 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 8 Dec 2016 23:14:19 +0300 Subject: [PATCH] [HIPIFY] -no-backup option is added. Is useful for release hipifying in place. [ROCm/hip commit: 428a1bc79f592c71542a32c07edea8620fa50226] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index a124fb7c64..c66a2b1b87 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2004,6 +2004,11 @@ static cl::opt Inplace("inplace", cl::value_desc("inplace"), cl::cat(ToolTemplateCategory)); +static cl::opt NoBackup("no-backup", + cl::desc("Don't create a backup file for the hipified source"), + cl::value_desc("no-backup"), + cl::cat(ToolTemplateCategory)); + static cl::opt NoOutput("no-output", cl::desc("Don't write any translated output to stdout"), cl::value_desc("no-output"), @@ -2134,12 +2139,14 @@ int main(int argc, const char **argv) { } dst += ".hip"; } - // copy source file since tooling makes changes "inplace" - std::ifstream source(fileSources[0], std::ios::binary); - std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); - dest << source.rdbuf(); - source.close(); - dest.close(); + // backup source file since tooling may change "inplace" + if (!NoBackup || !Inplace) { + std::ifstream source(fileSources[0], std::ios::binary); + std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); + dest << source.rdbuf(); + source.close(); + dest.close(); + } RefactoringTool Tool(OptionsParser.getCompilations(), dst); ast_matchers::MatchFinder Finder;