[PATCH] D108247: [CUDA] Improve CUDA version detection and diagnostics.

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 19 10:46:50 PDT 2021


Hahnfeld added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:209-211
+      Version = FS.exists(LibDevicePath + "/libdevice.10.bc")
+                    ? Version = CudaVersion::NEW
+                    : Version = CudaVersion::CUDA_70;
----------------
tra wrote:
> Hahnfeld wrote:
> > The compiler is now warning here because of the assignment to `VERSION` in the ternary operator
> I'll fix it shortly. I also need to figure out why my build does not produce the warning. 
The exact warning is
```
LLVM/src/clang/lib/Driver/ToolChains/Cuda.cpp: In constructor ‘clang::driver::CudaInstallationDetector::CudaInstallationDetector(const clang::driver::Driver&, const llvm::Triple&, const llvm::opt::ArgList&)’:              
LLVM/src/clang/lib/Driver/ToolChains/Cuda.cpp:207:15: warning: operation on ‘((clang::driver::CudaInstallationDetector*)this)->clang::driver::CudaInstallationDetector::Version’ may be undefined [-Wsequence-point]          
       Version = FS.exists(LibDevicePath + "/libdevice.10.bc")
       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     ? Version = CudaVersion::NEW
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     : Version = CudaVersion::CUDA_70;
                     ~~~~~~~~~~~~~~~~~~~~~~~
```
Re-reading the code, I actually think this is a false positive of GCC 8.3.1 (on CentOS 8) and `Version` is never undefined. But it was redundant, so it's good to remove it anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108247/new/

https://reviews.llvm.org/D108247



More information about the cfe-commits mailing list