[clang] Remove Linux search paths on Windows (PR #113628)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 17:06:22 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 7b9f988a535c3549b71025e951e3a36a2bf0fa03 2bcd8608ca1e00893692f1d1f8b1734204abbd15 --extensions cpp,h -- clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp clang/lib/Driver/ToolChains/HIPAMD.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/ROCm.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2be0d04d1c..b652988157 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
       TC = std::make_unique<toolchains::NVPTXToolChain>(*this, Target, Args);
       break;
     case llvm::Triple::AMDHSA:
-      TC = std::make_unique<toolchains::ROCMToolChain>(*this, Target, Args, Target.isWindowsMSVCEnvironment());
+      TC = std::make_unique<toolchains::ROCMToolChain>(
+          *this, Target, Args, Target.isWindowsMSVCEnvironment());
       break;
     case llvm::Triple::AMDPAL:
     case llvm::Triple::Mesa3D:
@@ -6582,8 +6583,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain(
         TC = std::make_unique<toolchains::HIPAMDToolChain>(*this, Target,
                                                            HostTC, Args);
       else if (Target.getArch() == llvm::Triple::spirv64 &&
-                 Target.getVendor() == llvm::Triple::UnknownVendor &&
-                 Target.getOS() == llvm::Triple::UnknownOS)
+               Target.getVendor() == llvm::Triple::UnknownVendor &&
+               Target.getOS() == llvm::Triple::UnknownOS)
         TC = std::make_unique<toolchains::HIPSPVToolChain>(*this, Target,
                                                            HostTC, Args);
       break;
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index c6ff2717d9..c7520b0a58 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -307,17 +307,17 @@ RocmInstallationDetector::getInstallationPathCandidates() {
     }
   }
 
- if (!isHostWindows()) {
-  if (!LatestROCm.empty())
-    ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
-                                /*StrictChecking=*/true);
+  if (!isHostWindows()) {
+    if (!LatestROCm.empty())
+      ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
+                                  /*StrictChecking=*/true);
 
     ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
                                 /*StrictChecking=*/true);
     ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
                                 /*StrictChecking=*/true);
- }
-  
+  }
+
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
 }
@@ -379,15 +379,14 @@ RocmInstallationDetector::RocmInstallationDetector(
                           .str();
   }
 
-  // Windows needs to exclude linux style paths from the list of paths to search,
-  // so delay these detection functions until after the constructor
+  // Windows needs to exclude linux style paths from the list of paths to
+  // search, so delay these detection functions until after the constructor
   if (!isHostWindows() && !HostTriple.isWindowsMSVCEnvironment()) {
     if (DetectHIPRuntime)
       detectHIPRuntime();
     if (DetectDeviceLib)
       detectDeviceLibrary();
-    }
-
+  }
 }
 
 void RocmInstallationDetector::detectDeviceLibrary() {
@@ -846,7 +845,7 @@ ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
                              const ArgList &Args, bool isHostTCMSVC)
     : AMDGPUToolChain(D, Triple, Args) {
   RocmInstallation->setHostWindows(isHostTCMSVC);
-  if (isHostTCMSVC) 
+  if (isHostTCMSVC)
     RocmInstallation->init(true, false);
   RocmInstallation->detectDeviceLibrary();
 }
diff --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 892db0dbc7..11a5c22e18 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -33,7 +33,9 @@ AMDGPUOpenMPToolChain::AMDGPUOpenMPToolChain(const Driver &D,
                                              const llvm::Triple &Triple,
                                              const ToolChain &HostTC,
                                              const ArgList &Args)
-    : ROCMToolChain(D, Triple, Args, HostTC.getTriple().isWindowsMSVCEnvironment()), HostTC(HostTC) {
+    : ROCMToolChain(D, Triple, Args,
+                    HostTC.getTriple().isWindowsMSVCEnvironment()),
+      HostTC(HostTC) {
   // Lookup binaries into the driver directory, this is used to
   // discover the 'amdgpu-arch' executable.
   getProgramPaths().push_back(getDriver().Dir);
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index bea8e6e2df..b999ec2ab3 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -213,13 +213,13 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
 HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
                                  const ToolChain &HostTC, const ArgList &Args)
-    : ROCMToolChain(D, Triple, Args, HostTC.getTriple().isWindowsMSVCEnvironment()),
+    : ROCMToolChain(D, Triple, Args,
+                    HostTC.getTriple().isWindowsMSVCEnvironment()),
       HostTC(HostTC) {
   if (HostTC.getTriple().isWindowsMSVCEnvironment()) {
     RocmInstallation->setHostWindows(true);
     RocmInstallation->init(true, false);
   }
- 
 
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index e149717fb1..ba1130e650 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -426,7 +426,8 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
     : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args),
       RocmInstallation(D, Triple, Args) {
 
-  // Tell the ROCm installation detector that Host is Windows before trying to find HIPRT or Device Libs
+  // Tell the ROCm installation detector that Host is Windows before trying to
+  // find HIPRT or Device Libs
   RocmInstallation->setHostWindows(true);
   RocmInstallation->init();
 
diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h
index a8868ade1c..a851ecc30d 100644
--- a/clang/lib/Driver/ToolChains/ROCm.h
+++ b/clang/lib/Driver/ToolChains/ROCm.h
@@ -196,7 +196,7 @@ public:
 
   /// Check whether the target triple is for Windows.
   bool isHostWindows() const { return IsHostMSVC; }
-  void setHostWindows(bool val) { IsHostMSVC=val; }
+  void setHostWindows(bool val) { IsHostMSVC = val; }
 
   /// Print information about the detected ROCm installation.
   void print(raw_ostream &OS) const;
@@ -277,7 +277,7 @@ public:
     return Loc->second;
   }
 
-  void init(bool DetectHIPRuntime=true, bool DetectDeviceLib=false) {
+  void init(bool DetectHIPRuntime = true, bool DetectDeviceLib = false) {
     if (DetectHIPRuntime)
       detectHIPRuntime();
     if (DetectDeviceLib)

``````````

</details>


https://github.com/llvm/llvm-project/pull/113628


More information about the cfe-commits mailing list