diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 28 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 13 |
2 files changed, 31 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 8dada8ca949..181a3818abe 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2040,7 +2040,7 @@ QualType Sema::BuildReferenceType(QualType T, bool SpelledAsLValue, return Context.getRValueReferenceType(T); } -/// \brief Build a Pipe type. +/// \brief Build a Read-only Pipe type. /// /// \param T The type to which we'll be building a Pipe. /// @@ -2048,11 +2048,20 @@ QualType Sema::BuildReferenceType(QualType T, bool SpelledAsLValue, /// /// \returns A suitable pipe type, if there are no errors. Otherwise, returns a /// NULL type. -QualType Sema::BuildPipeType(QualType T, SourceLocation Loc) { - assert(!T->isObjCObjectType() && "Should build ObjCObjectPointerType"); +QualType Sema::BuildReadPipeType(QualType T, SourceLocation Loc) { + return Context.getReadPipeType(T); +} - // Build the pipe type. - return Context.getPipeType(T); +/// \brief Build a Write-only Pipe type. +/// +/// \param T The type to which we'll be building a Pipe. +/// +/// \param Loc We do not use it for now. +/// +/// \returns A suitable pipe type, if there are no errors. Otherwise, returns a +/// NULL type. +QualType Sema::BuildWritePipeType(QualType T, SourceLocation Loc) { + return Context.getWritePipeType(T); } /// Check whether the specified array size makes the array type a VLA. If so, @@ -4531,7 +4540,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } case DeclaratorChunk::Pipe: { - T = S.BuildPipeType(T, DeclType.Loc ); + T = S.BuildReadPipeType(T, DeclType.Loc); + processTypeAttrs(state, T, TAL_DeclSpec, + D.getDeclSpec().getAttributes().getList()); break; } } @@ -6681,6 +6692,11 @@ static void HandleOpenCLAccessAttr(QualType &CurType, const AttributeList &Attr, S.Diag(TypedefTy->getDecl()->getLocStart(), diag::note_opencl_typedef_access_qualifier) << PrevAccessQual; + } else if (CurType->isPipeType()) { + if (Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) { + QualType ElemType = CurType->getAs<PipeType>()->getElementType(); + CurType = S.Context.getWritePipeType(ElemType); + } } } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 26d7222445b..a52234663d7 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1059,7 +1059,8 @@ public: QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc); /// \brief Build a new pipe type given its value type. - QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc); + QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, + bool isReadPipe); /// \brief Build a new template name given a nested name specifier, a flag /// indicating whether the "template" keyword was provided, and the template @@ -5483,7 +5484,9 @@ QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB, QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) { - Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc()); + const PipeType *PT = Result->getAs<PipeType>(); + bool isReadPipe = PT->isReadOnly(); + Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe); if (Result.isNull()) return QualType(); } @@ -11839,8 +11842,10 @@ QualType TreeTransform<Derived>::RebuildAtomicType(QualType ValueType, template<typename Derived> QualType TreeTransform<Derived>::RebuildPipeType(QualType ValueType, - SourceLocation KWLoc) { - return SemaRef.BuildPipeType(ValueType, KWLoc); + SourceLocation KWLoc, + bool isReadPipe) { + return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc) + : SemaRef.BuildWritePipeType(ValueType, KWLoc); } template<typename Derived> |