[PATCH] D90928: [OpenCL] Add assertions to extension lookup
Erik Tomusk via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 06:50:26 PST 2020
erik2020 updated this revision to Diff 306094.
erik2020 added a comment.
Changed asserting code to return `false` instead.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90928/new/
https://reviews.llvm.org/D90928
Files:
clang/include/clang/Basic/OpenCLOptions.h
Index: clang/include/clang/Basic/OpenCLOptions.h
===================================================================
--- clang/include/clang/Basic/OpenCLOptions.h
+++ clang/include/clang/Basic/OpenCLOptions.h
@@ -37,33 +37,46 @@
}
bool isEnabled(llvm::StringRef Ext) const {
- return OptMap.find(Ext)->second.Enabled;
+ auto E = OptMap.find(Ext);
+ return E != OptMap.end() && E->second.Enabled;
}
// Is supported as either an extension or an (optional) core feature for
// OpenCL version \p CLVer.
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const {
+ auto E = OptMap.find(Ext);
+ if (E == OptMap.end()) {
+ return false;
+ }
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
- auto I = OptMap.find(Ext)->getValue();
+ auto I = E->getValue();
return I.Supported && I.Avail <= CLVer;
}
// Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
// For supported extension, return false.
bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
+ auto E = OptMap.find(Ext);
+ if (E == OptMap.end()) {
+ return false;
+ }
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
- auto I = OptMap.find(Ext)->getValue();
+ auto I = E->getValue();
return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
}
// Is supported OpenCL extension for OpenCL version \p CLVer.
// For supported (optional) core feature, return false.
bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const {
+ auto E = OptMap.find(Ext);
+ if (E == OptMap.end()) {
+ return false;
+ }
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
- auto I = OptMap.find(Ext)->getValue();
+ auto I = E->getValue();
return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < I.Core);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90928.306094.patch
Type: text/x-patch
Size: 2116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201118/ad77ce8e/attachment.bin>
More information about the cfe-commits
mailing list