[cfe-commits] r64681 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/CodeGen/CGExpr.cpp
Chris Lattner
sabre at nondot.org
Mon Feb 16 14:14:05 PST 2009
Author: lattner
Date: Mon Feb 16 16:14:05 2009
New Revision: 64681
URL: http://llvm.org/viewvc/llvm-project?rev=64681&view=rev
Log:
introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=64681&r1=64680&r2=64681&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Feb 16 16:14:05 2009
@@ -2086,6 +2086,10 @@
return SourceRange(getBase()->getLocStart(), AccessorLoc);
}
+ /// isArrow - Return true if the base expression is a pointer to vector,
+ /// return false if the base expression is a vector.
+ bool isArrow() const;
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ExtVectorElementExprClass;
}
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=64681&r1=64680&r2=64681&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Feb 16 16:14:05 2009
@@ -1294,6 +1294,12 @@
return false;
}
+/// isArrow - Return true if the base expression is a pointer to vector,
+/// return false if the base expression is a vector.
+bool ExtVectorElementExpr::isArrow() const {
+ return getBase()->getType()->isPointerType();
+}
+
unsigned ExtVectorElementExpr::getNumElements() const {
if (const VectorType *VT = getType()->getAsVectorType())
return VT->getNumElements();
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=64681&r1=64680&r2=64681&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 16 16:14:05 2009
@@ -797,12 +797,13 @@
LValue Base;
// ExtVectorElementExpr's base can either be a vector or pointer to vector.
- if (const PointerType *PT = E->getBase()->getType()->getAsPointerType()) {
- llvm::Value *Ptr = EmitScalarExpr(E->getBase());
- Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
- } else {
+ if (!E->isArrow()) {
assert(E->getBase()->getType()->isVectorType());
Base = EmitLValue(E->getBase());
+ } else {
+ const PointerType *PT = E->getBase()->getType()->getAsPointerType();
+ llvm::Value *Ptr = EmitScalarExpr(E->getBase());
+ Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
}
// Encode the element access list into a vector of unsigned indices.
More information about the cfe-commits
mailing list