[clang] 9ae9262 - [OpenCL] Fix version reporting of C++ for OpenCL 2021

Justas Janickas via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 20 00:58:49 PDT 2021


Author: Justas Janickas
Date: 2021-08-20T08:58:12+01:00
New Revision: 9ae9262857a1e7aadc385a68a00755896440f6b1

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

LOG: [OpenCL] Fix version reporting of C++ for OpenCL 2021

C++ for OpenCL version 2021 and later are expected to consist of a
major version number only. Therefore, a different constructor for
`VersionTuple` needs to be called when reporting language version.

Differential Revision: https://reviews.llvm.org/D108379

Added: 
    

Modified: 
    clang/lib/Basic/LangOptions.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 169b67949038..3e3e7fe3dc15 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@ bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+    return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 


        


More information about the cfe-commits mailing list