aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorAnton Zabaznov <anton.zabaznov@intel.com>2021-03-05 16:23:49 +0300
committerAnton Zabaznov <anton.zabaznov@intel.com>2021-03-12 11:43:53 +0300
commit840643bbe1d25c88b0832f93c8bf3b2c451c7b14 (patch)
tree2abadb7a67bf993fd6bb95a92bc020dca24621f3 /clang/lib
parentbe5b844a354240007de05b67f6be7b48e1bbb25c (diff)
downloadllvm-840643bbe1d25c88b0832f93c8bf3b2c451c7b14.zip
llvm-840643bbe1d25c88b0832f93c8bf3b2c451c7b14.tar.gz
llvm-840643bbe1d25c88b0832f93c8bf3b2c451c7b14.tar.bz2
[OpenCL] Refactor diagnostic for OpenCL extension/feature
There is no need to check for enabled pragma for core or optional core features, thus this check is removed Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D97058
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/OpenCLOptions.cpp58
-rw-r--r--clang/lib/Parse/ParseDecl.cpp4
-rw-r--r--clang/lib/Parse/ParseExpr.cpp5
-rw-r--r--clang/lib/Parse/ParsePragma.cpp6
-rw-r--r--clang/lib/Sema/DeclSpec.cpp3
-rw-r--r--clang/lib/Sema/Sema.cpp68
-rw-r--r--clang/lib/Sema/SemaCast.cpp4
-rw-r--r--clang/lib/Sema/SemaChecking.cpp3
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
-rw-r--r--clang/lib/Sema/SemaExpr.cpp22
-rw-r--r--clang/lib/Sema/SemaInit.cpp8
-rw-r--r--clang/lib/Sema/SemaType.cpp18
12 files changed, 115 insertions, 96 deletions
diff --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp
index 2ca1ee0..78b7493 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -14,9 +14,21 @@ bool OpenCLOptions::isKnown(llvm::StringRef Ext) const {
return OptMap.find(Ext) != OptMap.end();
}
+bool OpenCLOptions::isAvailableOption(llvm::StringRef Ext,
+ const LangOptions &LO) const {
+ if (!isKnown(Ext))
+ return false;
+
+ auto &OptInfo = OptMap.find(Ext)->getValue();
+ if (OptInfo.isCoreIn(LO) || OptInfo.isOptionalCoreIn(LO))
+ return isSupported(Ext, LO);
+
+ return isEnabled(Ext);
+}
+
bool OpenCLOptions::isEnabled(llvm::StringRef Ext) const {
- auto E = OptMap.find(Ext);
- return E != OptMap.end() && E->second.Enabled;
+ auto I = OptMap.find(Ext);
+ return I != OptMap.end() && I->getValue().Enabled;
}
bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const {
@@ -26,32 +38,23 @@ bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const {
bool OpenCLOptions::isSupported(llvm::StringRef Ext,
const LangOptions &LO) const {
- auto E = OptMap.find(Ext);
- if (E == OptMap.end()) {
- return false;
- }
- auto I = OptMap.find(Ext)->getValue();
- return I.Supported && I.isAvailableIn(LO);
+ auto I = OptMap.find(Ext);
+ return I != OptMap.end() && I->getValue().Supported &&
+ I->getValue().isAvailableIn(LO);
}
bool OpenCLOptions::isSupportedCore(llvm::StringRef Ext,
const LangOptions &LO) const {
- auto E = OptMap.find(Ext);
- if (E == OptMap.end()) {
- return false;
- }
- auto I = OptMap.find(Ext)->getValue();
- return I.Supported && I.isCoreIn(LO);
+ auto I = OptMap.find(Ext);
+ return I != OptMap.end() && I->getValue().Supported &&
+ I->getValue().isCoreIn(LO);
}
bool OpenCLOptions::isSupportedOptionalCore(llvm::StringRef Ext,
const LangOptions &LO) const {
- auto E = OptMap.find(Ext);
- if (E == OptMap.end()) {
- return false;
- }
- auto I = OptMap.find(Ext)->getValue();
- return I.Supported && I.isOptionalCoreIn(LO);
+ auto I = OptMap.find(Ext);
+ return I != OptMap.end() && I->getValue().Supported &&
+ I->getValue().isOptionalCoreIn(LO);
}
bool OpenCLOptions::isSupportedCoreOrOptionalCore(llvm::StringRef Ext,
@@ -61,12 +64,9 @@ bool OpenCLOptions::isSupportedCoreOrOptionalCore(llvm::StringRef Ext,
bool OpenCLOptions::isSupportedExtension(llvm::StringRef Ext,
const LangOptions &LO) const {
- auto E = OptMap.find(Ext);
- if (E == OptMap.end()) {
- return false;
- }
- auto I = OptMap.find(Ext)->getValue();
- return I.Supported && I.isAvailableIn(LO) &&
+ auto I = OptMap.find(Ext);
+ return I != OptMap.end() && I->getValue().Supported &&
+ I->getValue().isAvailableIn(LO) &&
!isSupportedCoreOrOptionalCore(Ext, LO);
}
@@ -105,10 +105,4 @@ void OpenCLOptions::disableAll() {
Opt.getValue().Enabled = false;
}
-void OpenCLOptions::enableSupportedCore(const LangOptions &LO) {
- for (auto &Opt : OptMap)
- if (isSupportedCoreOrOptionalCore(Opt.getKey(), LO))
- Opt.getValue().Enabled = true;
-}
-
} // end namespace clang
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 069f981..9edf4d3 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3646,8 +3646,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// C++ for OpenCL does not allow virtual function qualifier, to avoid
// function pointers restricted in OpenCL v2.0 s6.9.a.
if (getLangOpts().OpenCLCPlusPlus &&
- !getActions().getOpenCLOptions().isEnabled(
- "__cl_clang_function_pointers")) {
+ !getActions().getOpenCLOptions().isAvailableOption(
+ "__cl_clang_function_pointers", getLangOpts())) {
DiagID = diag::err_openclcxx_virtual_function;
PrevSpec = Tok.getIdentifierInfo()->getNameStart();
isInvalid = true;
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 3b0dd3f..c417985 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1807,8 +1807,9 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
// These can be followed by postfix-expr pieces.
PreferredType = SavedType;
Res = ParsePostfixExpressionSuffix(Res);
- if (getLangOpts().OpenCL && !getActions().getOpenCLOptions().isEnabled(
- "__cl_clang_function_pointers"))
+ if (getLangOpts().OpenCL &&
+ !getActions().getOpenCLOptions().isAvailableOption(
+ "__cl_clang_function_pointers", getLangOpts()))
if (Expr *PostfixExpr = Res.get()) {
QualType Ty = PostfixExpr->getType();
if (!Ty.isNull() && Ty->isFunctionType()) {
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 8f7b977..b9cdcf4 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -771,12 +771,10 @@ void Parser::HandlePragmaOpenCLExtension() {
// overriding all previously issued extension directives, but only if the
// behavior is set to disable."
if (Name == "all") {
- if (State == Disable) {
+ if (State == Disable)
Opt.disableAll();
- Opt.enableSupportedCore(getLangOpts());
- } else {
+ else
PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
- }
} else if (State == Begin) {
if (!Opt.isKnown(Name) || !Opt.isSupported(Name, getLangOpts())) {
Opt.support(Name);
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index da42db3..a2b55c0 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -625,7 +625,8 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
// OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
// specifiers are not supported."
if (S.getLangOpts().OpenCL &&
- !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
+ !S.getOpenCLOptions().isAvailableOption(
+ "cl_clang_storage_class_specifiers", S.getLangOpts())) {
switch (SC) {
case SCS_extern:
case SCS_private_extern:
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 181a56f..2c99a35 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -299,7 +299,6 @@ void Sema::Initialize() {
if (getLangOpts().OpenCL) {
getOpenCLOptions().addSupport(
Context.getTargetInfo().getSupportedOpenCLOpts(), getLangOpts());
- getOpenCLOptions().enableSupportedCore(getLangOpts());
addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
addImplicitTypedef("event_t", Context.OCLEventTy);
if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) {
@@ -309,25 +308,13 @@ void Sema::Initialize() {
addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy));
addImplicitTypedef("atomic_uint",
Context.getAtomicType(Context.UnsignedIntTy));
- auto AtomicLongT = Context.getAtomicType(Context.LongTy);
- addImplicitTypedef("atomic_long", AtomicLongT);
- auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy);
- addImplicitTypedef("atomic_ulong", AtomicULongT);
addImplicitTypedef("atomic_float",
Context.getAtomicType(Context.FloatTy));
- auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
- addImplicitTypedef("atomic_double", AtomicDoubleT);
// OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
// 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
- auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
- addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
- auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
- addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
auto AtomicSizeT = Context.getAtomicType(Context.getSizeType());
addImplicitTypedef("atomic_size_t", AtomicSizeT);
- auto AtomicPtrDiffT = Context.getAtomicType(Context.getPointerDiffType());
- addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT);
// OpenCL v2.0 s6.13.11.6:
// - The atomic_long and atomic_ulong types are supported if the
@@ -341,20 +328,42 @@ void Sema::Initialize() {
// atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and
// cl_khr_int64_extended_atomics extensions are supported.
std::vector<QualType> Atomic64BitTypes;
- Atomic64BitTypes.push_back(AtomicLongT);
- Atomic64BitTypes.push_back(AtomicULongT);
- Atomic64BitTypes.push_back(AtomicDoubleT);
- if (Context.getTypeSize(AtomicSizeT) == 64) {
- Atomic64BitTypes.push_back(AtomicSizeT);
- Atomic64BitTypes.push_back(AtomicIntPtrT);
- Atomic64BitTypes.push_back(AtomicUIntPtrT);
- Atomic64BitTypes.push_back(AtomicPtrDiffT);
+ if (getOpenCLOptions().isSupported("cl_khr_int64_base_atomics",
+ getLangOpts()) &&
+ getOpenCLOptions().isSupported("cl_khr_int64_extended_atomics",
+ getLangOpts())) {
+ if (getOpenCLOptions().isSupported("cl_khr_fp64", getLangOpts())) {
+ auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
+ addImplicitTypedef("atomic_double", AtomicDoubleT);
+ setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64");
+ Atomic64BitTypes.push_back(AtomicDoubleT);
+ }
+ auto AtomicLongT = Context.getAtomicType(Context.LongTy);
+ auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy);
+ auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
+ auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
+ auto AtomicPtrDiffT =
+ Context.getAtomicType(Context.getPointerDiffType());
+
+ addImplicitTypedef("atomic_long", AtomicLongT);
+ addImplicitTypedef("atomic_ulong", AtomicULongT);
+ addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
+ addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
+ addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT);
+
+ Atomic64BitTypes.push_back(AtomicLongT);
+ Atomic64BitTypes.push_back(AtomicULongT);
+ if (Context.getTypeSize(AtomicSizeT) == 64) {
+ Atomic64BitTypes.push_back(AtomicSizeT);
+ Atomic64BitTypes.push_back(AtomicIntPtrT);
+ Atomic64BitTypes.push_back(AtomicUIntPtrT);
+ Atomic64BitTypes.push_back(AtomicPtrDiffT);
+ }
}
+
for (auto &I : Atomic64BitTypes)
setOpenCLExtensionForType(I,
"cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");
-
- setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64");
}
setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64");
@@ -362,9 +371,11 @@ void Sema::Initialize() {
#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
setOpenCLExtensionForType(Context.Id, Ext);
#include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
- addImplicitTypedef(#ExtType, Context.Id##Ty); \
- setOpenCLExtensionForType(Context.Id##Ty, #Ext);
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+ if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \
+ addImplicitTypedef(#ExtType, Context.Id##Ty); \
+ setOpenCLExtensionForType(Context.Id##Ty, #Ext); \
+ }
#include "clang/Basic/OpenCLExtensionTypes.def"
}
@@ -2511,7 +2522,7 @@ bool Sema::isOpenCLDisabledDecl(Decl *FD) {
if (Loc == OpenCLDeclExtMap.end())
return false;
for (auto &I : Loc->second) {
- if (!getOpenCLOptions().isEnabled(I))
+ if (!getOpenCLOptions().isAvailableOption(I, getLangOpts()))
return true;
}
return false;
@@ -2527,7 +2538,8 @@ bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
return false;
bool Disabled = false;
for (auto &I : Loc->second) {
- if (I != CurrOpenCLExtension && !getOpenCLOptions().isEnabled(I)) {
+ if (I != CurrOpenCLExtension &&
+ !getOpenCLOptions().isAvailableOption(I, getLangOpts())) {
Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo
<< I << SrcRange;
Disabled = true;
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 671820a..22ec2c7 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2916,8 +2916,8 @@ void CastOperation::CheckCStyleCast() {
}
}
- if (Self.getLangOpts().OpenCL &&
- !Self.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
+ if (Self.getLangOpts().OpenCL && !Self.getOpenCLOptions().isAvailableOption(
+ "cl_khr_fp16", Self.getLangOpts())) {
if (DestType->isHalfType()) {
Self.Diag(SrcExpr.get()->getBeginLoc(), diag::err_opencl_cast_to_half)
<< DestType << SrcExpr.get()->getSourceRange();
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e390159..46315d3 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -837,7 +837,8 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) {
}
static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
- if (!S.getOpenCLOptions().isEnabled("cl_khr_subgroups")) {
+ if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups",
+ S.getLangOpts())) {
S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
<< 1 << Call->getDirectCallee() << "cl_khr_subgroups";
return true;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c3502e0..b962bd9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6750,7 +6750,8 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D,
}
// OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
- if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+ if (!Se.getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers",
+ Se.getLangOpts())) {
QualType NR = R.getCanonicalType();
while (NR->isPointerType() || NR->isMemberFunctionPointerType() ||
NR->isReferenceType()) {
@@ -6765,7 +6766,8 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D,
}
}
- if (!Se.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
+ if (!Se.getOpenCLOptions().isAvailableOption("cl_khr_fp16",
+ Se.getLangOpts())) {
// OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and
// half array type (unless the cl_khr_fp16 extension is enabled).
if (Se.Context.getBaseElementType(R)->isHalfType()) {
@@ -7888,7 +7890,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
// OpenCL v1.2 s6.8 - The static qualifier is valid only in program
// scope.
if (getLangOpts().OpenCLVersion == 120 &&
- !getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers") &&
+ !getOpenCLOptions().isAvailableOption("cl_clang_storage_class_specifiers",
+ getLangOpts()) &&
NewVD->isStaticLocal()) {
Diag(NewVD->getLocation(), diag::err_static_function_scope);
NewVD->setInvalidDecl();
@@ -8660,7 +8663,8 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
// OpenCL extension spec v1.2 s9.5:
// This extension adds support for half scalar and vector types as built-in
// types that can be used for arithmetic operations, conversions etc.
- if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16") && PT->isHalfType())
+ if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16", S.getLangOpts()) &&
+ PT->isHalfType())
return InvalidKernelParam;
if (PT->isRecordType())
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d2b7dd8..81eec3d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -658,7 +658,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
return E;
// OpenCL usually rejects direct accesses to values of 'half' type.
- if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled("cl_khr_fp16") &&
+ if (getLangOpts().OpenCL &&
+ !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
T->isHalfType()) {
Diag(E->getExprLoc(), diag::err_opencl_half_load_store)
<< 0 << T;
@@ -830,10 +831,10 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
if (BTy && (BTy->getKind() == BuiltinType::Half ||
BTy->getKind() == BuiltinType::Float)) {
if (getLangOpts().OpenCL &&
- !getOpenCLOptions().isEnabled("cl_khr_fp64")) {
- if (BTy->getKind() == BuiltinType::Half) {
- E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
- }
+ !getOpenCLOptions().isAvailableOption("cl_khr_fp64", getLangOpts())) {
+ if (BTy->getKind() == BuiltinType::Half) {
+ E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
+ }
} else {
E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
}
@@ -3820,7 +3821,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
} else if (Literal.isFloatingLiteral()) {
QualType Ty;
if (Literal.isHalf){
- if (getOpenCLOptions().isEnabled("cl_khr_fp16"))
+ if (getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()))
Ty = Context.HalfTy;
else {
Diag(Tok.getLocation(), diag::err_half_const_requires_fp16);
@@ -3844,8 +3845,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
if (Ty->castAs<BuiltinType>()->getKind() != BuiltinType::Float) {
Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
}
- } else if (getLangOpts().OpenCL &&
- !getOpenCLOptions().isEnabled("cl_khr_fp64")) {
+ } else if (getLangOpts().OpenCL && !getOpenCLOptions().isAvailableOption(
+ "cl_khr_fp64", getLangOpts())) {
// Impose single-precision float type when cl_khr_fp64 is not enabled.
Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
@@ -12934,8 +12935,9 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
// OpenCL v1.2 s6.1.1.1 p2:
// The half data type can only be used to declare a pointer to a buffer that
// contains half values
- if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled("cl_khr_fp16") &&
- LHSType->isHalfType()) {
+ if (getLangOpts().OpenCL &&
+ !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
+ LHSType->isHalfType()) {
Diag(Loc, diag::err_opencl_half_load_store) << 1
<< LHSType.getUnqualifiedType();
return QualType();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 2f4e134..faf71ba 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5607,8 +5607,8 @@ static bool TryOCLZeroOpaqueTypeInitialization(Sema &S,
// We should allow zero initialization for all types defined in the
// cl_intel_device_side_avc_motion_estimation extension, except
// intel_sub_group_avc_mce_payload_t and intel_sub_group_avc_mce_result_t.
- if (S.getOpenCLOptions().isEnabled(
- "cl_intel_device_side_avc_motion_estimation") &&
+ if (S.getOpenCLOptions().isAvailableOption(
+ "cl_intel_device_side_avc_motion_estimation", S.getLangOpts()) &&
DestType->isOCLIntelSubgroupAVCType()) {
if (DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
DestType->isOCLIntelSubgroupAVCMceResultType())
@@ -8795,8 +8795,8 @@ ExprResult InitializationSequence::Perform(Sema &S,
unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
unsigned FilterMode = (0x30 & SamplerValue) >> 4;
if (FilterMode != 1 && FilterMode != 2 &&
- !S.getOpenCLOptions().isEnabled(
- "cl_intel_device_side_avc_motion_estimation"))
+ !S.getOpenCLOptions().isAvailableOption(
+ "cl_intel_device_side_avc_motion_estimation", S.getLangOpts()))
S.Diag(Kind.getLocation(),
diag::warn_sampler_initializer_invalid_bits)
<< "Filter Mode";
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 0eafff4..5f5b036 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2088,7 +2088,8 @@ QualType Sema::BuildPointerType(QualType T,
}
if (T->isFunctionType() && getLangOpts().OpenCL &&
- !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+ !getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers",
+ getLangOpts())) {
Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
return QualType();
}
@@ -2162,7 +2163,8 @@ QualType Sema::BuildReferenceType(QualType T, bool SpelledAsLValue,
return QualType();
if (T->isFunctionType() && getLangOpts().OpenCL &&
- !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+ !getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers",
+ getLangOpts())) {
Diag(Loc, diag::err_opencl_function_pointer) << /*reference*/ 1;
return QualType();
}
@@ -2894,7 +2896,8 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
}
if (T->isFunctionType() && getLangOpts().OpenCL &&
- !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+ !getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers",
+ getLangOpts())) {
Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
return QualType();
}
@@ -5004,7 +5007,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// FIXME: This really should be in BuildFunctionType.
if (T->isHalfType()) {
if (S.getLangOpts().OpenCL) {
- if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
+ if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16",
+ S.getLangOpts())) {
S.Diag(D.getIdentifierLoc(), diag::err_opencl_invalid_return)
<< T << 0 /*pointer hint*/;
D.setInvalidType(true);
@@ -5029,7 +5033,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// (s6.9.e and s6.12.5 OpenCL v2.0) except for printf.
// We also allow here any toolchain reserved identifiers.
if (FTI.isVariadic &&
- !S.getOpenCLOptions().isEnabled("__cl_clang_variadic_functions") &&
+ !S.getOpenCLOptions().isAvailableOption(
+ "__cl_clang_variadic_functions", S.getLangOpts()) &&
!(D.getIdentifier() &&
((D.getIdentifier()->getName() == "printf" &&
(LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) ||
@@ -5224,7 +5229,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// Disallow half FP parameters.
// FIXME: This really should be in BuildFunctionType.
if (S.getLangOpts().OpenCL) {
- if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
+ if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16",
+ S.getLangOpts())) {
S.Diag(Param->getLocation(), diag::err_opencl_invalid_param)
<< ParamTy << 0;
D.setInvalidType();