[clang] 14af99d - [OpenCL] Turn global vector into static array. NFCI.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 5 10:21:01 PST 2022


Author: Benjamin Kramer
Date: 2022-03-05T19:16:28+01:00
New Revision: 14af99d375b6c47e4b5ec457fb1f1f02b71a8566

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

LOG: [OpenCL] Turn global vector into static array. NFCI.

Added: 
    

Modified: 
    clang/include/clang/Basic/OpenCLOptions.h
    clang/lib/Basic/OpenCLOptions.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h
index 512bcb1e6ef10..d6cb1a210519d 100644
--- a/clang/include/clang/Basic/OpenCLOptions.h
+++ b/clang/include/clang/Basic/OpenCLOptions.h
@@ -212,15 +212,6 @@ class OpenCLOptions {
   bool isEnabled(llvm::StringRef Ext) const;
 
   OpenCLOptionInfoMap OptMap;
-
-  // First feature in a pair requires the second one to be supported.
-  using FeatureDepEntry = std::pair<llvm::StringRef, llvm::StringRef>;
-  using FeatureDepList = llvm::SmallVector<FeatureDepEntry, 8>;
-
-  static const FeatureDepList DependentFeaturesList;
-
-  // Extensions and equivalent feature pairs.
-  static const llvm::StringMap<llvm::StringRef> FeatureExtensionMap;
 };
 
 } // end namespace clang

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp
index 7e89b3f1b804d..44edf54025405 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -12,14 +12,16 @@
 
 namespace clang {
 
-const OpenCLOptions::FeatureDepList OpenCLOptions::DependentFeaturesList = {
+// First feature in a pair requires the second one to be supported.
+static const std::pair<StringRef, StringRef> DependentFeaturesList[] = {
     {"__opencl_c_read_write_images", "__opencl_c_images"},
     {"__opencl_c_3d_image_writes", "__opencl_c_images"},
     {"__opencl_c_pipes", "__opencl_c_generic_address_space"},
     {"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
     {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
 
-const llvm::StringMap<llvm::StringRef> OpenCLOptions::FeatureExtensionMap = {
+// Extensions and equivalent feature pairs.
+static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
     {"cl_khr_fp64", "__opencl_c_fp64"},
     {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
 
@@ -140,11 +142,11 @@ bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
 
   bool IsValid = true;
   for (auto &ExtAndFeat : FeatureExtensionMap)
-    if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) !=
-        TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) {
+    if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.first) !=
+        TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.second)) {
       IsValid = false;
       Diags.Report(diag::err_opencl_extension_and_feature_
diff ers)
-          << ExtAndFeat.getKey() << ExtAndFeat.getValue();
+          << ExtAndFeat.first << ExtAndFeat.second;
     }
   return IsValid;
 }


        


More information about the cfe-commits mailing list