[Lldb-commits] [lldb] 8ef0448 - Reland "[CUDA][HIP] Use the same default language std as C++""

Yaxun Liu via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 20 09:03:02 PDT 2023


Author: Yaxun (Sam) Liu
Date: 2023-07-20T12:02:33-04:00
New Revision: 8ef04488d128853715a55683f0181d6398d23c61

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

LOG: Reland "[CUDA][HIP] Use the same default language std as C++""

Reland after fixing regression in lldb.

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

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/LangStandards.def
    clang/lib/Basic/LangStandards.cpp
    clang/test/CodeGenCUDA/long-double.cu
    clang/test/Driver/unknown-std.cpp
    clang/test/Preprocessor/lang-std.cpp
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2287ff9d70da3f..ef1cc898c21f6d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -886,6 +886,9 @@ RISC-V Support
 
 CUDA/HIP Language Changes
 ^^^^^^^^^^^^^^^^^^^^^^^^^
+- Clang has been updated to align its default language standard for CUDA/HIP with
+  that of C++. The standard has now been enhanced to gnu++17, supplanting the
+  previously used c++14.
 
 CUDA Support
 ^^^^^^^^^^^^

diff  --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def
index 911b626e4c9661..5c28bdd28ef257 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -214,14 +214,6 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
 LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
 LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
 
-// CUDA
-LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
-             LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
-
-// HIP
-LANGSTANDARD(hip, "hip", HIP, "HIP",
-             LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
-
 // HLSL
 LANGSTANDARD(hlsl, "hlsl",
              HLSL, "High Level Shader Language",

diff  --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp
index c6a1a0acc2cb7e..033c0efe8d4f5d 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -54,8 +54,6 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
     return LangStandard::lang_opencl12;
   case Language::OpenCLCXX:
     return LangStandard::lang_openclcpp10;
-  case Language::CUDA:
-    return LangStandard::lang_cuda;
   case Language::Asm:
   case Language::C:
     // The PS4 uses C99 as the default C standard.
@@ -66,13 +64,13 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
     return LangStandard::lang_gnu11;
   case Language::CXX:
   case Language::ObjCXX:
+  case Language::CUDA:
+  case Language::HIP:
     if (T.isPS())
       return LangStandard::lang_gnucxx14;
     return LangStandard::lang_gnucxx17;
   case Language::RenderScript:
     return LangStandard::lang_c99;
-  case Language::HIP:
-    return LangStandard::lang_hip;
   case Language::HLSL:
     return LangStandard::lang_hlsl2021;
   }

diff  --git a/clang/test/CodeGenCUDA/long-double.cu b/clang/test/CodeGenCUDA/long-double.cu
index 454a93ce5f6b6a..d52de972ea3da4 100644
--- a/clang/test/CodeGenCUDA/long-double.cu
+++ b/clang/test/CodeGenCUDA/long-double.cu
@@ -6,7 +6,7 @@
 // RUN:   -aux-triple x86_64-unknown-gnu-linux -fcuda-is-device \
 // RUN:   -emit-llvm -o - %s 2>&1 | FileCheck %s
 
-// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFFFFFD586B834, align 8
+// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFFFFFD586B834,{{.*}} align 8
 // CHECK: @size = {{.*}} i32 8
 
 #include "Inputs/cuda.h"

diff  --git a/clang/test/Driver/unknown-std.cpp b/clang/test/Driver/unknown-std.cpp
index e918c087095ef0..5c58042a0a2c71 100644
--- a/clang/test/Driver/unknown-std.cpp
+++ b/clang/test/Driver/unknown-std.cpp
@@ -4,7 +4,10 @@
 
 // RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
 // RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
+// RUN:   %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
+// RUN: not %clang -x hip -nocudainc -nocudalib %s -std=foobar -c 2>&1 \
+// RUN:   | FileCheck --match-full-lines %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
@@ -21,7 +24,6 @@
 // CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' standard
 // CHECK-NEXT: note: use 'c++2c' or 'c++26' for 'Working draft for C++2c' standard
 // CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for C++2c with GNU extensions' standard
-// CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}

diff  --git a/clang/test/Preprocessor/lang-std.cpp b/clang/test/Preprocessor/lang-std.cpp
index 881d38641bc73c..1fb0759679e04f 100644
--- a/clang/test/Preprocessor/lang-std.cpp
+++ b/clang/test/Preprocessor/lang-std.cpp
@@ -1,12 +1,14 @@
-// UNSUPPORTED: target={{.*-(ps4|ps5)}}
 /// Test default standards.
-/// PS4/PS5 default to gnu++14.
+/// CUDA/HIP uses the same default standards as C++.
 
-// RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s
-// RUN: %clang_cc1 -dM -E -x cuda %s | FileCheck --check-prefix=CXX14 %s
-// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck --check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E %s | grep __cplusplus >%T-cpp-std.txt
+// RUN: %clang_cc1 -dM -E -x cuda %s | grep __cplusplus >%T-cuda-cuda.txt
+// RUN: %clang_cc1 -dM -E -x hip %s | grep __cplusplus >%T-hip-std.txt
+// RUN: 
diff  %T-cpp-std.txt %T-cuda-cuda.txt
+// RUN: 
diff  %T-cpp-std.txt %T-hip-std.txt
 
 // RUN: %clang_cc1 -dM -E -x cuda -std=c++14 %s | FileCheck --check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E -x cuda -std=c++17 %s | FileCheck --check-prefix=CXX17 %s
 // RUN: %clang_cc1 -dM -E -x hip -std=c++98 %s | FileCheck --check-prefix=CXX98 %s
 
 // CXX98: #define __cplusplus 199711L

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 8d6b9f54315b78..5bc7a47241028d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -485,9 +485,6 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
     case clang::Language::OpenCLCXX:
       LangStd = LangStandard::lang_openclcpp10;
       break;
-    case clang::Language::CUDA:
-      LangStd = LangStandard::lang_cuda;
-      break;
     case clang::Language::Asm:
     case clang::Language::C:
     case clang::Language::ObjC:
@@ -497,8 +494,9 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
     case clang::Language::ObjCXX:
       LangStd = LangStandard::lang_gnucxx98;
       break;
+    case clang::Language::CUDA:
     case clang::Language::HIP:
-      LangStd = LangStandard::lang_hip;
+      LangStd = LangStandard::lang_gnucxx17;
       break;
     case clang::Language::HLSL:
       LangStd = LangStandard::lang_hlsl;


        


More information about the lldb-commits mailing list