[clang][driver] Rename ClangExecutable and getClangProgramPath (NFC) (#200814)

This patch is to rename ClangExecutable to DriverExecutable and 
getClangProgramPath to getDriverProgramPath. This makes the 
name more neutral and less confusing when used in flang.
This commit is contained in:
Kelvin Li 2026-06-04 10:38:30 -04:00 committed by GitHub
parent 6e58021642
commit 2e9f45a702
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 29 additions and 32 deletions

View file

@ -168,8 +168,8 @@ public:
/// command line.
std::string Dir;
/// The original path to the clang executable.
std::string ClangExecutable;
/// The original path to the driver executable.
std::string DriverExecutable;
/// Target and driver mode components extracted from clang executable name.
ParsedClangName ClangNameParts;
@ -389,7 +389,7 @@ private:
SmallString<128> &CrashDiagDir);
public:
Driver(StringRef ClangExecutable, StringRef TargetTriple,
Driver(StringRef DriverExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
@ -426,10 +426,8 @@ public:
std::string getTargetTriple() const { return TargetTriple; }
/// Get the path to the main clang executable.
const char *getClangProgramPath() const {
return ClangExecutable.c_str();
}
/// Get the path to the main driver executable.
const char *getDriverProgramPath() const { return DriverExecutable.c_str(); }
StringRef getPreferredLinker() const { return PreferredLinker; }
void setPreferredLinker(std::string Value) {

View file

@ -175,13 +175,13 @@ std::string CUIDOptions::getCUID(StringRef InputFile,
}
return CUID;
}
Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
Driver::Driver(StringRef DriverExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags, std::string Title,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
: Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode),
SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
Offload(OffloadHostDevice), CXX20HeaderType(HeaderMode_None),
ModulesModeCXX20(false), ClangExecutable(ClangExecutable),
ModulesModeCXX20(false), DriverExecutable(DriverExecutable),
SysRoot(DEFAULT_SYSROOT), DriverTitle(Title), CCCPrintBindings(false),
CCPrintOptions(false), CCLogDiagnostics(false), CCGenDiagnostics(false),
CCPrintProcessStats(false), CCPrintInternalStats(false),
@ -192,8 +192,8 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
if (!this->VFS)
this->VFS = llvm::vfs::getRealFileSystem();
Name = std::string(llvm::sys::path::filename(ClangExecutable));
Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
Name = std::string(llvm::sys::path::filename(DriverExecutable));
Dir = std::string(llvm::sys::path::parent_path(DriverExecutable));
if ((!SysRoot.empty()) && llvm::sys::path::is_relative(SysRoot)) {
// Prepend InstalledDir if SysRoot is relative
@ -221,7 +221,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
#endif
// Compute the path to the resource directory.
ResourceDir = GetResourcesPath(ClangExecutable);
ResourceDir = GetResourcesPath(DriverExecutable);
}
void Driver::setDriverMode(StringRef Value) {
@ -1443,7 +1443,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// We look for the driver mode option early, because the mode can affect
// how other options are parsed.
auto DriverMode = getDriverMode(ClangExecutable, ArgList.slice(1));
auto DriverMode = getDriverMode(DriverExecutable, ArgList.slice(1));
if (!DriverMode.empty())
setDriverMode(DriverMode);

View file

@ -1294,7 +1294,7 @@ createClangModulePrecompileJob(Compilation &C, const Command &ImportingJob,
const auto &D = C.getDriver();
return std::make_unique<Command>(
*PA, ImportingJob.getCreator(), ResponseFileSupport::AtFileUTF8(),
D.getClangProgramPath(), JobArgs,
D.getDriverProgramPath(), JobArgs,
/*Inputs=*/ArrayRef<InputInfo>{},
/*Outputs=*/ArrayRef<InputInfo>{}, D.getPrependArg());
}

View file

@ -249,8 +249,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_shared) && !hasExportListLinkerOpts(CmdArgs)) {
const char *CreateExportListExec = Args.MakeArgString(
path::parent_path(ToolChain.getDriver().ClangExecutable) +
"/llvm-nm");
path::parent_path(ToolChain.getDriver().DriverExecutable) + "/llvm-nm");
ArgStringList CreateExportCmdArgs;
std::string CreateExportListPath =

View file

@ -249,7 +249,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
// Deduce ROCm path by the real path of the invoked clang, resolving symbolic
// link of clang itself.
llvm::SmallString<256> RealClangPath;
llvm::sys::fs::real_path(D.getClangProgramPath(), RealClangPath);
llvm::sys::fs::real_path(D.getDriverProgramPath(), RealClangPath);
auto ParentPath = llvm::sys::path::parent_path(RealClangPath);
if (ParentPath != InstallDir)
ROCmSearchDirs.emplace_back(DeduceROCmPath(ParentPath));

View file

@ -2323,7 +2323,7 @@ void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
if (Output.isFilename())
CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
CDB << ", \"arguments\": [\"" << escape(D.ClangExecutable) << "\"";
CDB << ", \"arguments\": [\"" << escape(D.DriverExecutable) << "\"";
SmallString<128> Buf;
Buf = "-x";
Buf += types::getTypeName(Input.getType());
@ -5551,7 +5551,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::AtFileUTF8(), D.getClangProgramPath(),
JA, *this, ResponseFileSupport::AtFileUTF8(), D.getDriverProgramPath(),
CmdArgs, Inputs, Output, D.getPrependArg()));
return;
}
@ -8060,7 +8060,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddAllArgs(CmdArgs, options::OPT_undef);
const char *Exec = D.getClangProgramPath();
const char *Exec = D.getDriverProgramPath();
// Optionally embed the -cc1 level arguments into the debug info or a
// section, for build analysis.
@ -9116,7 +9116,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
Arg->render(Args, OriginalArgs);
SmallString<256> Flags;
const char *Exec = getToolChain().getDriver().getClangProgramPath();
const char *Exec = getToolChain().getDriver().getDriverProgramPath();
escapeSpacesAndBackslashes(Exec, Flags);
for (const char *OriginalArg : OriginalArgs) {
SmallString<128> EscapedArg;
@ -9249,7 +9249,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
assert(Input.isFilename() && "Invalid input.");
CmdArgs.push_back(Input.getFilename());
const char *Exec = getToolChain().getDriver().getClangProgramPath();
const char *Exec = getToolChain().getDriver().getDriverProgramPath();
if (D.CC1Main && !D.CCGenDiagnostics) {
// Invoke cc1as directly in this process.
C.addCommand(std::make_unique<CC1Command>(

View file

@ -995,7 +995,7 @@ void tools::addDTLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
Args.MakeArgString("--thinlto-distributor=" + Twine(A->getValue())));
const Driver &D = ToolChain.getDriver();
CmdArgs.push_back(Args.MakeArgString("--thinlto-remote-compiler=" +
Twine(D.getClangProgramPath())));
Twine(D.getDriverProgramPath())));
if (auto *PA = D.getPrependArg())
CmdArgs.push_back(Args.MakeArgString(
"--thinlto-remote-compiler-prepend-arg=" + Twine(PA)));
@ -3329,7 +3329,7 @@ void tools::escapeSpacesAndBackslashes(const char *Arg,
const char *tools::renderEscapedCommandLine(const ToolChain &TC,
const llvm::opt::ArgList &Args) {
const Driver &D = TC.getDriver();
const char *Exec = D.getClangProgramPath();
const char *Exec = D.getDriverProgramPath();
llvm::opt::ArgStringList OriginalArgs;
for (const auto &Arg : Args)

View file

@ -1385,7 +1385,7 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args,
runtime.hasSubscripting())
return;
SmallString<128> P(getDriver().ClangExecutable);
SmallString<128> P(getDriver().DriverExecutable);
llvm::sys::path::remove_filename(P); // 'clang'
llvm::sys::path::remove_filename(P); // 'bin'
llvm::sys::path::append(P, "lib", "arc");

View file

@ -180,7 +180,7 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
Output.getFilename()});
const Driver &Driver = getToolChain().getDriver();
const char *Exec = Driver.getClangProgramPath();
const char *Exec = Driver.getDriverProgramPath();
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, LinkedBCFile,
Output, Driver.getPrependArg()));

View file

@ -482,7 +482,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
"-x", "assembler",
ObjinFile, "-c"};
C.addCommand(std::make_unique<Command>(JA, T, ResponseFileSupport::None(),
D.getClangProgramPath(), ClangArgs,
D.getDriverProgramPath(), ClangArgs,
Inputs, Output, D.getPrependArg()));
}

View file

@ -247,7 +247,7 @@ static bool stripPositionalArgs(std::vector<const char *> Args,
// The clang executable path isn't required since the jobs the driver builds
// will not be executed.
std::unique_ptr<driver::Driver> NewDriver(new driver::Driver(
/* ClangExecutable= */ "", llvm::sys::getDefaultTargetTriple(),
/* DriverExecutable= */ "", llvm::sys::getDefaultTargetTriple(),
Diagnostics));
NewDriver->setCheckInputsExist(false);

View file

@ -925,12 +925,12 @@ TEST(ToolChainTest, NestedConfigFile) {
FS->addFile("/home/test/bin/platform.cfg", 0,
llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-bin\n"));
SmallString<128> ClangExecutable("/home/test/bin/clang");
FS->makeAbsolute(ClangExecutable);
SmallString<128> DriverExecutable("/home/test/bin/clang");
FS->makeAbsolute(DriverExecutable);
// User file is absent - use system definitions.
{
Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
Driver TheDriver(DriverExecutable, "arm-linux-gnueabi", Diags,
"clang LLVM compiler", FS);
std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
{"/home/test/bin/clang", "--config", "root.cfg",
@ -944,7 +944,7 @@ TEST(ToolChainTest, NestedConfigFile) {
FS->addFile("/home/test/sdk/platform.cfg", 0,
llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-user\n"));
{
Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
Driver TheDriver(DriverExecutable, "arm-linux-gnueabi", Diags,
"clang LLVM compiler", FS);
std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
{"/home/test/bin/clang", "--config", "root.cfg",