]> granicus.if.org Git - clang/commitdiff
add OCUVectorComponent::getNumComponents()
authorChris Lattner <sabre@nondot.org>
Fri, 3 Aug 2007 16:00:20 +0000 (16:00 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 3 Aug 2007 16:00:20 +0000 (16:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40778 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp
include/clang/AST/Expr.h

index 9b5fc78d741a728211686e4358bc25272c5c1d01..625634d7877c2d25407fc95f729ef1d2a27296d0 100644 (file)
@@ -583,6 +583,11 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
   return isIntegerConstantExpr(Val, Ctx, 0, true) && Val == 0;
 }
 
+unsigned OCUVectorComponent::getNumComponents() const {
+  return strlen(Accessor.getName());
+}
+
+
 /// getComponentType - Determine whether the components of this access are
 /// "point" "color" or "texture" elements.
 OCUVectorComponent::ComponentType OCUVectorComponent::getComponentType() const {
@@ -615,7 +620,7 @@ bool OCUVectorComponent::containsDuplicateComponents() const {
 /// getEncodedElementAccess - We encode fields with two bits per component.
 unsigned OCUVectorComponent::getEncodedElementAccess() const {
   const char *compStr = Accessor.getName();
-  unsigned length = strlen(compStr);
+  unsigned length = getNumComponents();
 
   unsigned Result = 0;
   
index c2f147b2def12be15234bb43e922b53b5438aeae..ab7b417148079614255d334247d8316114a93696 100644 (file)
@@ -486,6 +486,9 @@ public:
   
   IdentifierInfo &getAccessor() const { return Accessor; }
   
+  /// getNumComponents - Get the number of components being selected.
+  unsigned getNumComponents() const;
+  
   /// getComponentType - Determine whether the components of this access are
   /// "point" "color" or "texture" elements.
   ComponentType getComponentType() const;