[clang] d912232 - [CUDA][FIX] Fix name conflict in getNVPTXTargetFeatures

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 20:13:56 PDT 2022


Author: Joseph Huber
Date: 2022-03-23T23:07:51-04:00
New Revision: d91223274145a0c33ab01641902650b249921a43

URL: https://github.com/llvm/llvm-project/commit/d91223274145a0c33ab01641902650b249921a43
DIFF: https://github.com/llvm/llvm-project/commit/d91223274145a0c33ab01641902650b249921a43.diff

LOG: [CUDA][FIX] Fix name conflict in getNVPTXTargetFeatures

Summary:
There was a naming conflict in the getNVPTXTargetFeatures function that
prevented some compilers from correctly disambiguating between the
enumeration and variable of the same name. Rename the variable to avoid
this.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Cuda.cpp
    clang/lib/Driver/ToolChains/Cuda.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index b162cec8a27c3..f8a06a2e09ab7 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -633,17 +633,17 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA,
 void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple,
                                    const llvm::opt::ArgList &Args,
                                    std::vector<StringRef> &Features,
-                                   Optional<clang::CudaVersion> CudaVersion) {
-  if (!CudaVersion) {
+                                   Optional<clang::CudaVersion> Version) {
+  if (!Version) {
     CudaInstallationDetector CudaInstallation(D, Triple, Args);
-    CudaVersion = CudaInstallation.version();
+    Version = CudaInstallation.version();
   }
 
   // New CUDA versions often introduce new instructions that are only supported
   // by new PTX version, so we need to raise PTX level to enable them in NVPTX
   // back-end.
   const char *PtxFeature = nullptr;
-  switch (*CudaVersion) {
+  switch (*Version) {
 #define CASE_CUDA_VERSION(CUDA_VER, PTX_VER)                                   \
   case CudaVersion::CUDA_##CUDA_VER:                                           \
     PtxFeature = "+ptx" #PTX_VER;                                              \

diff  --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h
index f4f924ff8a684..f2517a9b38d1e 100644
--- a/clang/lib/Driver/ToolChains/Cuda.h
+++ b/clang/lib/Driver/ToolChains/Cuda.h
@@ -127,7 +127,7 @@ class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {
 void getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple,
                             const llvm::opt::ArgList &Args,
                             std::vector<StringRef> &Features,
-                            Optional<clang::CudaVersion> CudaVersion = None);
+                            Optional<clang::CudaVersion> Version = None);
 
 } // end namespace NVPTX
 } // end namespace tools


        


More information about the cfe-commits mailing list