aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/OpenCLOptions.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2021-03-03 12:05:38 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2021-03-03 15:02:21 +0000
commit25ad188bfcdb2a85416013c6303f30cbc7775674 (patch)
treef05df37bb6b2be9f20a5902febbdda120d357d18 /clang/lib/Basic/OpenCLOptions.cpp
parent0a5dd067181dac2a8882a139ea3bd19bdea5fa44 (diff)
downloadllvm-25ad188bfcdb2a85416013c6303f30cbc7775674.zip
llvm-25ad188bfcdb2a85416013c6303f30cbc7775674.tar.gz
llvm-25ad188bfcdb2a85416013c6303f30cbc7775674.tar.bz2
[OpenCL] Prevent adding extension pragma by default.
This commit refactors extension support to allow specifying whether pragma is needed or not explicitly. For backward compatibility pragmas are set to required for all extensions that were added prior to this but not for OpenCL 3.0 features. Differential Revision: https://reviews.llvm.org/D97052
Diffstat (limited to 'clang/lib/Basic/OpenCLOptions.cpp')
-rw-r--r--clang/lib/Basic/OpenCLOptions.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp
index 266acc5..2ca1ee0 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -19,6 +19,11 @@ bool OpenCLOptions::isEnabled(llvm::StringRef Ext) const {
return E != OptMap.end() && E->second.Enabled;
}
+bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const {
+ auto E = OptMap.find(Ext);
+ return E != OptMap.end() && E->second.WithPragma;
+}
+
bool OpenCLOptions::isSupported(llvm::StringRef Ext,
const LangOptions &LO) const {
auto E = OptMap.find(Ext);
@@ -69,6 +74,10 @@ void OpenCLOptions::enable(llvm::StringRef Ext, bool V) {
OptMap[Ext].Enabled = V;
}
+void OpenCLOptions::acceptsPragma(llvm::StringRef Ext, bool V) {
+ OptMap[Ext].WithPragma = V;
+}
+
void OpenCLOptions::support(llvm::StringRef Ext, bool V) {
assert(!Ext.empty() && "Extension is empty.");
assert(Ext[0] != '+' && Ext[0] != '-');
@@ -76,10 +85,9 @@ void OpenCLOptions::support(llvm::StringRef Ext, bool V) {
}
OpenCLOptions::OpenCLOptions() {
-#define OPENCL_GENERIC_EXTENSION(Ext, AvailVer, CoreVer, OptVer) \
- OptMap[#Ext].Avail = AvailVer; \
- OptMap[#Ext].Core = CoreVer; \
- OptMap[#Ext].Opt = OptVer;
+#define OPENCL_GENERIC_EXTENSION(Ext, WithPragma, AvailVer, CoreVer, OptVer) \
+ OptMap.insert_or_assign( \
+ #Ext, OpenCLOptionInfo{WithPragma, AvailVer, CoreVer, OptVer});
#include "clang/Basic/OpenCLExtensions.def"
}