diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 97 |
3 files changed, 34 insertions, 72 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 738b40ad44a..08ec2619bd0 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -2557,7 +2557,7 @@ void CastOperation::CheckCStyleCast() { llvm::APSInt CastInt; if (SrcExpr.get()->EvaluateAsInt(CastInt, Self.Context)) { if (0 == CastInt) { - Kind = CK_ZeroToOCLEvent; + Kind = CK_ZeroToOCLOpaqueType; return; } Self.Diag(OpRange.getBegin(), diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index eb1dd8975d1..1349b5af6aa 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4236,14 +4236,9 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_Zero_Event_Conversion: - From = ImpCastExprToType(From, ToType, - CK_ZeroToOCLEvent, - From->getValueKind()).get(); - break; - case ICK_Zero_Queue_Conversion: From = ImpCastExprToType(From, ToType, - CK_ZeroToOCLQueue, + CK_ZeroToOCLOpaqueType, From->getValueKind()).get(); break; diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 597b7ba59e7..29119a7ded9 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3261,8 +3261,7 @@ void InitializationSequence::Step::Destroy() { case SK_StdInitializerList: case SK_StdInitializerListConstructorCall: case SK_OCLSamplerInit: - case SK_OCLZeroEvent: - case SK_OCLZeroQueue: + case SK_OCLZeroOpaqueType: break; case SK_ConversionSequence: @@ -3548,16 +3547,9 @@ void InitializationSequence::AddOCLSamplerInitStep(QualType T) { Steps.push_back(S); } -void InitializationSequence::AddOCLZeroEventStep(QualType T) { +void InitializationSequence::AddOCLZeroOpaqueTypeStep(QualType T) { Step S; - S.Kind = SK_OCLZeroEvent; - S.Type = T; - Steps.push_back(S); -} - -void InitializationSequence::AddOCLZeroQueueStep(QualType T) { - Step S; - S.Kind = SK_OCLZeroQueue; + S.Kind = SK_OCLZeroOpaqueType; S.Type = T; Steps.push_back(S); } @@ -5260,39 +5252,31 @@ static bool TryOCLSamplerInitialization(Sema &S, return true; } -// -// OpenCL 1.2 spec, s6.12.10 -// -// The event argument can also be used to associate the -// async_work_group_copy with a previous async copy allowing -// an event to be shared by multiple async copies; otherwise -// event should be zero. -// -static bool TryOCLZeroEventInitialization(Sema &S, - InitializationSequence &Sequence, - QualType DestType, - Expr *Initializer) { - if (!S.getLangOpts().OpenCL || !DestType->isEventT() || - !Initializer->isIntegerConstantExpr(S.getASTContext()) || - (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0)) +static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, + InitializationSequence &Sequence, + QualType DestType, + Expr *Initializer) { + if (!S.getLangOpts().OpenCL) return false; - Sequence.AddOCLZeroEventStep(DestType); - return true; -} + // + // OpenCL 1.2 spec, s6.12.10 + // + // The event argument can also be used to associate the + // async_work_group_copy with a previous async copy allowing + // an event to be shared by multiple async copies; otherwise + // event should be zero. + // + if (DestType->isEventT() || DestType->isQueueT()) { + if (!Initializer->isIntegerConstantExpr(S.getASTContext()) || + (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0)) + return false; -static bool TryOCLZeroQueueInitialization(Sema &S, - InitializationSequence &Sequence, - QualType DestType, - Expr *Initializer) { - if (!S.getLangOpts().OpenCL || S.getLangOpts().OpenCLVersion < 200 || - !DestType->isQueueT() || - !Initializer->isIntegerConstantExpr(S.getASTContext()) || - (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0)) - return false; + Sequence.AddOCLZeroOpaqueTypeStep(DestType); + return true; + } - Sequence.AddOCLZeroQueueStep(DestType); - return true; + return false; } InitializationSequence::InitializationSequence(Sema &S, @@ -5566,12 +5550,9 @@ void InitializationSequence::InitializeFrom(Sema &S, if (TryOCLSamplerInitialization(S, *this, DestType, Initializer)) return; - if (TryOCLZeroEventInitialization(S, *this, DestType, Initializer)) + if (TryOCLZeroOpaqueTypeInitialization(S, *this, DestType, Initializer)) return; - if (TryOCLZeroQueueInitialization(S, *this, DestType, Initializer)) - return; - // Handle initialization in C AddCAssignmentStep(DestType); MaybeProduceObjCObject(S, *this, Entity); @@ -7407,8 +7388,7 @@ InitializationSequence::Perform(Sema &S, case SK_ProduceObjCObject: case SK_StdInitializerList: case SK_OCLSamplerInit: - case SK_OCLZeroEvent: - case SK_OCLZeroQueue: { + case SK_OCLZeroOpaqueType: { assert(Args.size() == 1); CurInit = Args[0]; if (!CurInit.get()) return ExprError(); @@ -8062,21 +8042,12 @@ InitializationSequence::Perform(Sema &S, CK_IntToOCLSampler); break; } - case SK_OCLZeroEvent: { - assert(Step->Type->isEventT() && - "Event initialization on non-event type."); + case SK_OCLZeroOpaqueType: { + assert((Step->Type->isEventT() || Step->Type->isQueueT()) && + "Wrong type for initialization of OpenCL opaque type."); CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, - CK_ZeroToOCLEvent, - CurInit.get()->getValueKind()); - break; - } - case SK_OCLZeroQueue: { - assert(Step->Type->isQueueT() && - "Event initialization on non queue type."); - - CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, - CK_ZeroToOCLQueue, + CK_ZeroToOCLOpaqueType, CurInit.get()->getValueKind()); break; } @@ -8959,12 +8930,8 @@ void InitializationSequence::dump(raw_ostream &OS) const { OS << "OpenCL sampler_t from integer constant"; break; - case SK_OCLZeroEvent: - OS << "OpenCL event_t from zero"; - break; - - case SK_OCLZeroQueue: - OS << "OpenCL queue_t from zero"; + case SK_OCLZeroOpaqueType: + OS << "OpenCL opaque type from zero"; break; } |