diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 5bad7146895d7..2e85f85fbc1c1 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -198,7 +198,7 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const { // when the nvptx*-nvidia-cuda is passed to -fsycl-targets. if (DefaultToolChain.getTriple().isNVPTX()) return false; - if (llvm::sys::path::extension(ActualFile).equals(".spv")) + if (llvm::sys::path::extension(ActualFile) == ".spv") return false; } } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 6b67d7fe85178..3886531c6973e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -829,8 +829,8 @@ static bool isValidSYCLTriple(llvm::Triple T) { // SPIR/SPIRV arch, but has invalid SubArch for AOT. StringRef A(T.getArchName()); if (T.getSubArch() == llvm::Triple::NoSubArch && - ((T.getArch() == llvm::Triple::spir && !A.equals("spir")) || - (T.getArch() == llvm::Triple::spir64 && !A.equals("spir64")))) + ((T.getArch() == llvm::Triple::spir && A != "spir") || + (T.getArch() == llvm::Triple::spir64 && A != "spir64"))) return false; return true; } @@ -1149,7 +1149,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, return; const char *ArgValue = A->getValue(); for (const StringRef AllowedValue : AllowedValues) - if (AllowedValue.equals(ArgValue)) + if (AllowedValue == ArgValue) return; Diag(clang::diag::err_drv_invalid_argument_to_option) << ArgValue << A->getOption().getName(); @@ -1891,7 +1891,7 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { // an external option setting is required to target hardware. setOffloadCompileMode(FPGAEmulationMode); for (StringRef ArgString : TargetArgs) { - if (ArgString.equals("-hardware") || ArgString.equals("-simulation")) { + if (ArgString == "-hardware" || ArgString == "-simulation") { setOffloadCompileMode(FPGAHWMode); break; } @@ -6250,12 +6250,12 @@ class OffloadingActionBuilder final { using namespace tools::SYCL; StringRef Device{Value.first}; if (Device.consume_front(gen::AmdGPU)) - return TargetArch.equals(Device) && TargetTriple.isAMDGCN(); + return TargetArch == Device && TargetTriple.isAMDGCN(); if (Device.consume_front(gen::NvidiaGPU)) - return TargetArch.equals(Device) && TargetTriple.isNVPTX(); + return TargetArch == Device && TargetTriple.isNVPTX(); if (Device.consume_front(gen::IntelGPU)) - return TargetArch.equals(Device) && TargetTriple.isSPIRAOT(); - return TargetArch.equals(Device) && isValidSYCLTriple(TargetTriple); + return TargetArch == Device && TargetTriple.isSPIRAOT(); + return TargetArch == Device && isValidSYCLTriple(TargetTriple); }); } else { TargetIt = TargetTable.find(TargetTriple.str()); @@ -9710,7 +9710,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, const auto &ResultFiles = C.getResultFiles(); const auto CollidingFilenameIt = llvm::find_if(ResultFiles, [NamedOutput](const auto &It) { - return StringRef(NamedOutput).equals(It.second); + return StringRef(NamedOutput) == It.second; }); if (CollidingFilenameIt != ResultFiles.end()) { // Upon any collision, a unique hash will be appended to the filename, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a451693e7ac71..347f34de72d6a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4952,7 +4952,7 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA, if (isa(JA)) { if (IsMSVCHostCompiler) { // Check the output file, if it is 'stdout' we want to use -E. - if (StringRef(Output.getFilename()).equals("-")) { + if (StringRef(Output.getFilename()) == "-") { HostCompileArgs.push_back("-E"); OutputAdded = true; } else { diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 8f3b47937c512..ba0a8d928c8fa 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1568,9 +1568,8 @@ bool tools::isDependentLibAdded(const ArgList &Args, StringRef Lib) { // Check if given Lib is added via --dependent-lib SmallString<64> DepLib("--dependent-lib="); DepLib += Lib; - return llvm::any_of( - Args.getAllArgValues(options::OPT_Xclang), - [&DepLib](StringRef Option) { return Option.equals(DepLib); }); + return llvm::any_of(Args.getAllArgValues(options::OPT_Xclang), + [&DepLib](StringRef Option) { return Option == DepLib; }); } const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args, diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index f371e1e233538..1db4500bd3b51 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -114,7 +114,7 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA, // If fsycl-dump-device-code is passed, put the PTX files // into the path provided in fsycl-dump-device-code. if (T->getToolChain().getTriple().isNVPTX() && - C.getDriver().isDumpDeviceCodeEnabled() && Ext.equals("s")) { + C.getDriver().isDumpDeviceCodeEnabled() && Ext == "s") { SmallString<128> OutputDir; Arg *DumpDeviceCodeArg = @@ -235,12 +235,11 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple, for (StringRef Val : A->getValues()) { if (Val == "all") { for (const auto &K : DeviceLibLinkInfo.keys()) - DeviceLibLinkInfo[K] = - true && (!NoDeviceLibs || K.equals("internal")); + DeviceLibLinkInfo[K] = true && (!NoDeviceLibs || K == "internal"); break; } auto LinkInfoIter = DeviceLibLinkInfo.find(Val); - if (LinkInfoIter == DeviceLibLinkInfo.end() || Val.equals("internal")) { + if (LinkInfoIter == DeviceLibLinkInfo.end() || Val == "internal") { // TODO: Move the diagnostic to the SYCL section of // Driver::CreateOffloadingDeviceToolChains() to minimize code // duplication. @@ -488,7 +487,7 @@ const char *SYCL::Linker::constructLLVMLinkCommand( for (const auto &L : SYCLDeviceLibList) { std::string DeviceLibName(L); DeviceLibName.append(LibPostfix); - if (StringRef(PureLibName).equals(DeviceLibName) || + if (StringRef(PureLibName) == DeviceLibName || (IsNVPTX && StringRef(PureLibName).starts_with(L))) return true; } @@ -899,7 +898,7 @@ static bool hasPVCDevice(const ArgStringList &CmdArgs) { DeviceArg = SplitArg; break; } - if (SplitArg.equals("-device")) + if (SplitArg == "-device") DeviceSeen = true; } if (DeviceSeen) @@ -1477,8 +1476,8 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple, auto ProcessElement = [&](StringRef Ele) { auto [DeviceName, RegAllocMode] = Ele.split(':'); StringRef BackendOptName = SYCL::gen::getGenGRFFlag(RegAllocMode); - bool IsDefault = RegAllocMode.equals("default"); - if (RegAllocMode.empty() || !DeviceName.equals("pvc") || + bool IsDefault = RegAllocMode == "default"; + if (RegAllocMode.empty() || DeviceName != "pvc" || (BackendOptName.empty() && !IsDefault)) { getDriver().Diag(diag::err_drv_unsupported_option_argument) << A->getSpelling() << Ele; @@ -1526,7 +1525,7 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple, if (Args.hasArg(options::OPT_fintelfpga) && getDriver().IsFPGAHWMode() && Triple.getSubArch() == llvm::Triple::SPIRSubArch_fpga) { if (Arg *A = Args.getLastArg(options::OPT_ffp_model_EQ)) { - if (StringRef(A->getValue()).equals("fast")) + if (StringRef(A->getValue()) == "fast") BeArgs.push_back("-vpfp-relaxed"); } }