From 3792d264c0a34a71460ee7bd5450d3dcf670c735 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 10 Jan 2019 18:27:30 +0300 Subject: [PATCH] [HIPIFY] Introduce '--' option - a separator between hipify-clang and clang options + Append '--' to the end of hipify-clang options in case of its absence. [Reason] + Avoid the necessity for the user in JSON compilation database specification. Otherwise: Error while trying to load a compilation database: Could not auto-detect compilation database for file "test.cu" Though the hipification will be performed correctly without JSON database. [ROCm/hip commit: aa4c59ae0cf1d3c60d91acc6887bcf9f78f08664] --- projects/hip/hipify-clang/src/ArgParse.cpp | 5 +++++ projects/hip/hipify-clang/src/ArgParse.h | 1 + projects/hip/hipify-clang/src/main.cpp | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/projects/hip/hipify-clang/src/ArgParse.cpp b/projects/hip/hipify-clang/src/ArgParse.cpp index d9efe1732d..9696cb74aa 100644 --- a/projects/hip/hipify-clang/src/ArgParse.cpp +++ b/projects/hip/hipify-clang/src/ArgParse.cpp @@ -84,4 +84,9 @@ cl::opt Examine("examine", cl::value_desc("examine"), cl::cat(ToolTemplateCategory)); +cl::opt DashDash("-", + cl::desc("Separator between hipify-clang and clang options;\ndon't specify if there are no clang options."), + cl::value_desc("--"), + cl::cat(ToolTemplateCategory)); + cl::extrahelp CommonHelp(ct::CommonOptionsParser::HelpMessage); diff --git a/projects/hip/hipify-clang/src/ArgParse.h b/projects/hip/hipify-clang/src/ArgParse.h index 28195fd93f..97f172d812 100644 --- a/projects/hip/hipify-clang/src/ArgParse.h +++ b/projects/hip/hipify-clang/src/ArgParse.h @@ -42,3 +42,4 @@ extern cl::opt OutputStatsFilename; extern cl::opt Examine; extern cl::extrahelp CommonHelp; extern cl::opt TranslateToRoc; +extern cl::opt DashDash; diff --git a/projects/hip/hipify-clang/src/main.cpp b/projects/hip/hipify-clang/src/main.cpp index 1f26df4886..6df8ae9679 100644 --- a/projects/hip/hipify-clang/src/main.cpp +++ b/projects/hip/hipify-clang/src/main.cpp @@ -68,6 +68,13 @@ std::string getAbsoluteDirectory(const std::string& sDir, std::error_code& EC, } int main(int argc, const char **argv) { + std::vector new_argv(argv, argv + argc); + if (std::find(new_argv.begin(), new_argv.end(), std::string("--")) == new_argv.end()) { + new_argv.push_back("--"); + new_argv.push_back(nullptr); + argv = new_argv.data(); + argc++; + } llcompat::PrintStackTraceOnErrorSignal(); ct::CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::OneOrMore); std::vector fileSources = OptionsParser.getSourcePathList();