[cfe-commits] r94279 - in /cfe/trunk/lib/Sema: SemaInit.cpp SemaInit.h

Anders Carlsson andersca at mac.com
Fri Jan 22 20:34:53 PST 2010


Author: andersca
Date: Fri Jan 22 22:34:47 2010
New Revision: 94279

URL: http://llvm.org/viewvc/llvm-project?rev=94279&view=rev
Log:
Separate EK_ArrayOrVectorElement into EK_ArrayElement and EK_VectorElement; arrays and vectors are pretty different beasts in C++. Doug, please review/comment.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/SemaInit.h

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=94279&r1=94278&r2=94279&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Jan 22 22:34:47 2010
@@ -382,7 +382,8 @@
     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 @@
 
 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 @@
   case EK_New:
   case EK_Temporary:
   case EK_Base:
-  case EK_ArrayOrVectorElement:
+  case EK_ArrayElement:
+  case EK_VectorElement:
     return DeclarationName();
   }
   
@@ -1882,7 +1887,8 @@
   case EK_New:
   case EK_Temporary:
   case EK_Base:
-  case EK_ArrayOrVectorElement:
+  case EK_ArrayElement:
+  case EK_VectorElement:
     return 0;
   }
   
@@ -2916,7 +2922,8 @@
     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 @@
   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 @@
   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);
   }

Modified: cfe/trunk/lib/Sema/SemaInit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.h?rev=94279&r1=94278&r2=94279&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.h (original)
+++ cfe/trunk/lib/Sema/SemaInit.h Fri Jan 22 22:34:47 2010
@@ -57,9 +57,12 @@
     /// \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 @@
   /// \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;
   }
 };





More information about the cfe-commits mailing list