llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Bruce Changlong Xu (brucechanglongxu) <details> <summary>Changes</summary> Use empty() instead of size() checks, back() instead of [size()-1], and brace-init instead of std::make_pair in the AMDGPU and HIP driver toolchains. --- Full diff: https://github.com/llvm/llvm-project/pull/187586.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+3-4) - (modified) clang/lib/Driver/ToolChains/HIPAMD.cpp (+1-1) ``````````diff diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 7bbdb71b1e24f..1097b714f6c24 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -147,8 +147,7 @@ void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) { llvm::Twine GfxName = Twine("gfx") + IsaVersionNumber; SmallString<8> Tmp; - LibDeviceMap.insert( - std::make_pair(GfxName.toStringRef(Tmp), FilePath.str())); + LibDeviceMap.insert({GfxName.toStringRef(Tmp), FilePath.str()}); } } } @@ -339,7 +338,7 @@ RocmInstallationDetector::RocmInstallationDetector( unsigned Minor = ~0U; SmallVector<StringRef, 3> Parts; HIPVersionArg.split(Parts, '.'); - if (Parts.size()) + if (!Parts.empty()) Parts[0].getAsInteger(0, Major); if (Parts.size() > 1) Parts[1].getAsInteger(0, Minor); @@ -373,7 +372,7 @@ void RocmInstallationDetector::detectDeviceLibrary() { assert(LibDevicePath.empty()); if (!RocmDeviceLibPathArg.empty()) - LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1]; + LibDevicePath = RocmDeviceLibPathArg.back(); else if (std::optional<std::string> LibPathEnv = llvm::sys::Process::GetEnv("HIP_DEVICE_LIB_PATH")) LibDevicePath = std::move(*LibPathEnv); diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index 5b1bc6d8b6fd7..4684909867752 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -207,7 +207,7 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { - if (Inputs.size() > 0 && + if (!Inputs.empty() && Inputs[0].getType() == types::TY_Image && JA.getType() == types::TY_Object) return HIP::constructGenerateObjFileFromHIPFatBinary(C, Output, Inputs, `````````` </details> https://github.com/llvm/llvm-project/pull/187586 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
