diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-01-23 04:34:47 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-01-23 04:34:47 +0000 |
| commit | ed8d80d72bd8d956a7fa7354166b8f33106d24b9 (patch) | |
| tree | da3f1c265e96b8b3e4b0b9ce4d6bd86b3d46337b /clang/lib/Sema | |
| parent | 4a1aa119a3d78e3b41bb4f808290e871530b8316 (diff) | |
| download | bcm5719-llvm-ed8d80d72bd8d956a7fa7354166b8f33106d24b9.tar.gz bcm5719-llvm-ed8d80d72bd8d956a7fa7354166b8f33106d24b9.zip | |
Separate EK_ArrayOrVectorElement into EK_ArrayElement and EK_VectorElement; arrays and vectors are pretty different beasts in C++. Doug, please review/comment.
llvm-svn: 94279
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 27 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaInit.h | 9 |
2 files changed, 24 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 29209d97ff7..fd62e1afce4 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -382,7 +382,8 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity, if (hadError) return; - if (ElementEntity.getKind() == InitializedEntity::EK_ArrayOrVectorElement) + if (ElementEntity.getKind() == InitializedEntity::EK_ArrayElement || + ElementEntity.getKind() == InitializedEntity::EK_VectorElement) ElementEntity.setElementIndex(Init); if (Init >= NumInits || !ILE->getInit(Init)) { @@ -1828,12 +1829,15 @@ bool Sema::CheckInitList(const InitializedEntity &Entity, InitializedEntity::InitializedEntity(ASTContext &Context, unsigned Index, const InitializedEntity &Parent) - : Kind(EK_ArrayOrVectorElement), Parent(&Parent), Index(Index) + : Parent(&Parent), Index(Index) { - if (const ArrayType *AT = Context.getAsArrayType(Parent.getType())) + if (const ArrayType *AT = Context.getAsArrayType(Parent.getType())) { + Kind = EK_ArrayElement; Type = AT->getElementType(); - else + } else { + Kind = EK_VectorElement; Type = Parent.getType()->getAs<VectorType>()->getElementType(); + } } InitializedEntity InitializedEntity::InitializeBase(ASTContext &Context, @@ -1862,7 +1866,8 @@ DeclarationName InitializedEntity::getName() const { case EK_New: case EK_Temporary: case EK_Base: - case EK_ArrayOrVectorElement: + case EK_ArrayElement: + case EK_VectorElement: return DeclarationName(); } @@ -1882,7 +1887,8 @@ DeclaratorDecl *InitializedEntity::getDecl() const { case EK_New: case EK_Temporary: case EK_Base: - case EK_ArrayOrVectorElement: + case EK_ArrayElement: + case EK_VectorElement: return 0; } @@ -2916,7 +2922,8 @@ getAssignmentAction(const InitializedEntity &Entity) { return Sema::AA_Casting; case InitializedEntity::EK_Member: - case InitializedEntity::EK_ArrayOrVectorElement: + case InitializedEntity::EK_ArrayElement: + case InitializedEntity::EK_VectorElement: return Sema::AA_Initializing; } @@ -2934,7 +2941,8 @@ static bool shouldBindAsTemporary(const InitializedEntity &Entity, case InitializedEntity::EK_Variable: case InitializedEntity::EK_Base: case InitializedEntity::EK_Member: - case InitializedEntity::EK_ArrayOrVectorElement: + case InitializedEntity::EK_ArrayElement: + case InitializedEntity::EK_VectorElement: return false; case InitializedEntity::EK_Parameter: @@ -2980,7 +2988,8 @@ static Sema::OwningExprResult CopyIfRequiredForEntity(Sema &S, case InitializedEntity::EK_Temporary: case InitializedEntity::EK_Base: case InitializedEntity::EK_Member: - case InitializedEntity::EK_ArrayOrVectorElement: + case InitializedEntity::EK_ArrayElement: + case InitializedEntity::EK_VectorElement: // We don't need to copy for any of these initialized entities. return move(CurInit); } diff --git a/clang/lib/Sema/SemaInit.h b/clang/lib/Sema/SemaInit.h index 5eb819a6917..5c305545b09 100644 --- a/clang/lib/Sema/SemaInit.h +++ b/clang/lib/Sema/SemaInit.h @@ -57,9 +57,12 @@ public: /// \brief The entity being initialized is a non-static data member /// subobject. EK_Member, - /// \brief The entity being initialized is an element of an array + /// \brief The entity being initialized is an element of an array. + EK_ArrayElement, + /// \brief The entity being initialized is an element of a vector. /// or vector. - EK_ArrayOrVectorElement + EK_VectorElement + }; private: @@ -211,7 +214,7 @@ public: /// \brief If this is already the initializer for an array or vector /// element, sets the element index. void setElementIndex(unsigned Index) { - assert(getKind() == EK_ArrayOrVectorElement); + assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement); this->Index = Index; } }; |

