diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -340,25 +340,25 @@ return 1; } -int main(int argc_, const char **argv_) { +int main(int argc, const char **argv) { noteBottomOfStack(); - llvm::InitLLVM X(argc_, argv_); + llvm::InitLLVM X(argc, argv); llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL " and include the crash backtrace, preprocessed " "source, and associated run script.\n"); - SmallVector argv(argv_, argv_ + argc_); + SmallVector Argv(argv, argv + argc); if (llvm::sys::Process::FixupStandardFileDescriptors()) return 1; llvm::InitializeAllTargets(); - auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]); + auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Argv[0]); llvm::BumpPtrAllocator A; llvm::StringSaver Saver(A); // Parse response files using the GNU syntax, unless we're in CL mode. There - // are two ways to put clang in CL compatibility mode: argv[0] is either + // are two ways to put clang in CL compatibility mode: Argv[0] is either // clang-cl or cl, or --driver-mode=cl is on the command line. The normal // command line parsing can't happen until after response file parsing, so we // have to manually search for a --driver-mode=cl argument the hard way. @@ -366,20 +366,20 @@ // response files written by clang will tokenize the same way in either mode. bool ClangCLMode = false; if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") || - llvm::find_if(argv, [](const char *F) { + llvm::find_if(Argv, [](const char *F) { return F && strcmp(F, "--driver-mode=cl") == 0; - }) != argv.end()) { + }) != Argv.end()) { ClangCLMode = true; } enum { Default, POSIX, Windows } RSPQuoting = Default; - for (const char *F : argv) { + for (const char *F : Argv) { if (strcmp(F, "--rsp-quoting=posix") == 0) RSPQuoting = POSIX; else if (strcmp(F, "--rsp-quoting=windows") == 0) RSPQuoting = Windows; } - // Determines whether we want nullptr markers in argv to indicate response + // Determines whether we want nullptr markers in Argv to indicate response // files end-of-lines. We only use this for the /LINK driver argument with // clang-cl.exe on Windows. bool MarkEOLs = ClangCLMode; @@ -390,31 +390,31 @@ else Tokenizer = &llvm::cl::TokenizeGNUCommandLine; - if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1")) + if (MarkEOLs && Argv.size() > 1 && StringRef(Argv[1]).startswith("-cc1")) MarkEOLs = false; - llvm::cl::ExpandResponseFiles(Saver, Tokenizer, argv, MarkEOLs); + llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, MarkEOLs); // Handle -cc1 integrated tools, even if -cc1 was expanded from a response // file. - auto FirstArg = std::find_if(argv.begin() + 1, argv.end(), + auto FirstArg = std::find_if(Argv.begin() + 1, Argv.end(), [](const char *A) { return A != nullptr; }); - if (FirstArg != argv.end() && StringRef(*FirstArg).startswith("-cc1")) { + if (FirstArg != Argv.end() && StringRef(*FirstArg).startswith("-cc1")) { // If -cc1 came from a response file, remove the EOL sentinels. if (MarkEOLs) { - auto newEnd = std::remove(argv.begin(), argv.end(), nullptr); - argv.resize(newEnd - argv.begin()); + auto newEnd = std::remove(Argv.begin(), Argv.end(), nullptr); + Argv.resize(newEnd - Argv.begin()); } - return ExecuteCC1Tool(argv); + return ExecuteCC1Tool(Argv); } // Handle options that need handling before the real command line parsing in // Driver::BuildCompilation() bool CanonicalPrefixes = true; - for (int i = 1, size = argv.size(); i < size; ++i) { + for (int i = 1, size = Argv.size(); i < size; ++i) { // Skip end-of-line response file markers - if (argv[i] == nullptr) + if (Argv[i] == nullptr) continue; - if (StringRef(argv[i]) == "-no-canonical-prefixes") { + if (StringRef(Argv[i]) == "-no-canonical-prefixes") { CanonicalPrefixes = false; break; } @@ -430,7 +430,7 @@ getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts); // Insert right after the program name to prepend to the argument list. - argv.insert(argv.begin() + 1, PrependedOpts.begin(), PrependedOpts.end()); + Argv.insert(Argv.begin() + 1, PrependedOpts.begin(), PrependedOpts.end()); } // Arguments in "_CL_" are appended. llvm::Optional Opt_CL_ = llvm::sys::Process::GetEnv("_CL_"); @@ -439,7 +439,7 @@ getCLEnvVarOptions(Opt_CL_.getValue(), Saver, AppendedOpts); // Insert at the end of the argument list to append. - argv.append(AppendedOpts.begin(), AppendedOpts.end()); + Argv.append(AppendedOpts.begin(), AppendedOpts.end()); } } @@ -448,10 +448,10 @@ // scenes. if (const char *OverrideStr = ::getenv("CCC_OVERRIDE_OPTIONS")) { // FIXME: Driver shouldn't take extra initial argument. - ApplyQAOverride(argv, OverrideStr, SavedStrings); + ApplyQAOverride(Argv, OverrideStr, SavedStrings); } - std::string Path = GetExecutablePath(argv[0], CanonicalPrefixes); + std::string Path = GetExecutablePath(Argv[0], CanonicalPrefixes); // Whether the cc1 tool should be called inside the current process, or if we // should spawn a new clang subprocess (old behavior). @@ -460,7 +460,7 @@ bool UseNewCC1Process; IntrusiveRefCntPtr DiagOpts = - CreateAndPopulateDiagOpts(argv, UseNewCC1Process); + CreateAndPopulateDiagOpts(Argv, UseNewCC1Process); TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); @@ -481,10 +481,10 @@ ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags); - SetInstallDir(argv, TheDriver, CanonicalPrefixes); + SetInstallDir(Argv, TheDriver, CanonicalPrefixes); TheDriver.setTargetAndMode(TargetAndMode); - insertTargetAndModeArgs(TargetAndMode, argv, SavedStrings); + insertTargetAndModeArgs(TargetAndMode, Argv, SavedStrings); SetBackdoorDriverOutputsFromEnvVars(TheDriver); @@ -494,7 +494,7 @@ llvm::CrashRecoveryContext::Enable(); } - std::unique_ptr C(TheDriver.BuildCompilation(argv)); + std::unique_ptr C(TheDriver.BuildCompilation(Argv)); int Res = 1; bool IsCrash = false; if (C && !C->containsError()) { diff --git a/flang/tools/flang-driver/driver.cpp b/flang/tools/flang-driver/driver.cpp --- a/flang/tools/flang-driver/driver.cpp +++ b/flang/tools/flang-driver/driver.cpp @@ -66,27 +66,27 @@ return 1; } -int main(int argc_, const char **argv_) { +int main(int argc, const char **argv) { // Initialize variables to call the driver - llvm::InitLLVM x(argc_, argv_); - llvm::SmallVector argv(argv_, argv_ + argc_); + llvm::InitLLVM x(argc, argv); + llvm::SmallVector Argv(argv, argv + argc); clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang"); - std::string driverPath = GetExecutablePath(argv[0]); + std::string driverPath = GetExecutablePath(Argv[0]); // Check if flang-new is in the frontend mode auto firstArg = std::find_if( - argv.begin() + 1, argv.end(), [](const char *a) { return a != nullptr; }); - if (firstArg != argv.end()) { - if (llvm::StringRef(argv[1]).startswith("-cc1")) { - llvm::errs() << "error: unknown integrated tool '" << argv[1] << "'. " + Argv.begin() + 1, Argv.end(), [](const char *a) { return a != nullptr; }); + if (firstArg != Argv.end()) { + if (llvm::StringRef(Argv[1]).startswith("-cc1")) { + llvm::errs() << "error: unknown integrated tool '" << Argv[1] << "'. " << "Valid tools include '-fc1'.\n"; return 1; } // Call flang-new frontend - if (llvm::StringRef(argv[1]).startswith("-fc1")) { - return ExecuteFC1Tool(argv); + if (llvm::StringRef(Argv[1]).startswith("-fc1")) { + return ExecuteFC1Tool(Argv); } } @@ -94,14 +94,14 @@ // Create DiagnosticsEngine for the compiler driver llvm::IntrusiveRefCntPtr diagOpts = - CreateAndPopulateDiagOpts(argv); + CreateAndPopulateDiagOpts(Argv); llvm::IntrusiveRefCntPtr diagID( new clang::DiagnosticIDs()); Fortran::frontend::TextDiagnosticPrinter *diagClient = new Fortran::frontend::TextDiagnosticPrinter(llvm::errs(), &*diagOpts); diagClient->set_prefix( - std::string(llvm::sys::path::stem(GetExecutablePath(argv[0])))); + std::string(llvm::sys::path::stem(GetExecutablePath(Argv[0])))); clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagClient); @@ -110,7 +110,7 @@ llvm::sys::getDefaultTargetTriple(), diags, "flang LLVM compiler"); theDriver.setTargetAndMode(targetandMode); std::unique_ptr c( - theDriver.BuildCompilation(argv)); + theDriver.BuildCompilation(Argv)); llvm::SmallVector, 4> failingCommands;