Merge "Fix missing JSON database warning from hipify-clang" into amd-master

This commit is contained in:
Maneesh Gupta
2016-05-23 01:50:46 -04:00
committed by Gerrit Code Review
+15 -15
View File
@@ -769,27 +769,26 @@ private:
} // end anonymous namespace } // end anonymous namespace
// Set up the command line options // Set up the command line options
static cl::OptionCategory static cl::opt<std::string>
ToolTemplateCategory("CUDA to HIP source translator options"); InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
static cl::extrahelp MoreHelp("<source0> specify the path of source file\n\n");
static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
cl::value_desc("filename"), cl::value_desc("filename"));
cl::cat(ToolTemplateCategory));
static cl::opt<bool> static cl::opt<bool>
Inplace("inplace", Inplace("inplace",
cl::desc("Modify input file inplace, replacing input with hipified " cl::desc("Modify input file inplace, replacing input with hipified "
"output, save backup in .prehip file. "), "output, save backup in .prehip file. "),
cl::value_desc("inplace"), cl::cat(ToolTemplateCategory)); cl::value_desc("inplace"));
static cl::opt<bool> static cl::opt<bool>
NoOutput("no-output", NoOutput("no-output",
cl::desc("don't write any translated output to stdout"), cl::desc("don't write any translated output to stdout"),
cl::value_desc("no-output"), cl::cat(ToolTemplateCategory)); cl::value_desc("no-output"));
static cl::opt<bool> static cl::opt<bool>
PrintStats("print-stats", cl::desc("print the command-line, like a header"), PrintStats("print-stats", cl::desc("print the command-line, like a header"),
cl::value_desc("print-stats"), cl::cat(ToolTemplateCategory)); cl::value_desc("print-stats"));
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
@@ -797,12 +796,13 @@ int main(int argc, const char **argv) {
int Result; int Result;
CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, std::unique_ptr<CompilationDatabase> Compilations(
llvm::cl::Required); new FixedCompilationDatabase(".",std::vector<std::string>()));
cl::ParseCommandLineOptions(argc, argv);
std::string dst = OutputFilename; std::string dst = OutputFilename;
std::vector<std::string> fileSources = OptionsParser.getSourcePathList();
if (dst.empty()) { if (dst.empty()) {
dst = fileSources[0]; dst = InputFilename;
if (!Inplace) { if (!Inplace) {
size_t pos = dst.rfind(".cu"); size_t pos = dst.rfind(".cu");
if (pos != std::string::npos) { if (pos != std::string::npos) {
@@ -820,13 +820,13 @@ int main(int argc, const char **argv) {
} }
// copy source file since tooling makes changes "inplace" // copy source file since tooling makes changes "inplace"
std::ifstream source(fileSources[0], std::ios::binary); std::ifstream source(InputFilename, std::ios::binary);
std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary);
dest << source.rdbuf(); dest << source.rdbuf();
source.close(); source.close();
dest.close(); dest.close();
RefactoringTool Tool(OptionsParser.getCompilations(), dst); RefactoringTool Tool(*Compilations, dst);
ast_matchers::MatchFinder Finder; ast_matchers::MatchFinder Finder;
Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder); Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder);
HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); HipifyPPCallbacks PPCallbacks(&Tool.getReplacements());
@@ -931,7 +931,7 @@ int main(int argc, const char **argv) {
llvm::outs() << counterNames[i] << ':' llvm::outs() << counterNames[i] << ':'
<< Callback.countReps[i] + PPCallbacks.countReps[i] << ' '; << Callback.countReps[i] + PPCallbacks.countReps[i] << ' ';
} }
llvm::outs() << ") in \'" << fileSources[0] << "\'\n"; llvm::outs() << ") in \'" << InputFilename << "\'\n";
} }
return Result; return Result;
} }