summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/AST/Expr.cpp7
-rw-r--r--clang/include/clang/AST/Expr.h3
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp
index 9b5fc78d741..625634d7877 100644
--- a/clang/AST/Expr.cpp
+++ b/clang/AST/Expr.cpp
@@ -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;
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index c2f147b2def..ab7b4171480 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -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;
OpenPOWER on IntegriCloud