aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-15 06:56:33 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-15 06:56:33 +0000
commitb33fb3670b996e6779925bb329abfbc42e470e08 (patch)
tree95c6d33ad880d07a2c4a91eabbb1e2db2ca5a4e3
parent1a65133b1123f54942bbdf5289e035d261e25352 (diff)
downloadllvm-b33fb3670b996e6779925bb329abfbc42e470e08.zip
llvm-b33fb3670b996e6779925bb329abfbc42e470e08.tar.gz
llvm-b33fb3670b996e6779925bb329abfbc42e470e08.tar.bz2
Fix the definition of AsTypeExpr. I'm still not sure this
is right --- shouldn't there be a TypeLoc in here somewhere? --- but at least it doesn't have a redundant QualType and a broken children() method. Noticed this while doing things in serialization. llvm-svn: 135257
-rw-r--r--clang/include/clang/AST/Expr.h26
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp2
2 files changed, 16 insertions, 12 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 5445a9d..11e384f 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4149,11 +4149,14 @@ public:
/// AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2]
/// This AST node provides support for reinterpreting a type to another
/// type of the same size.
-class AsTypeExpr : public Expr {
+class AsTypeExpr : public Expr { // Should this be an ExplicitCastExpr?
private:
- Expr* SrcExpr;
- QualType DstType;
+ Stmt *SrcExpr;
SourceLocation BuiltinLoc, RParenLoc;
+
+ friend class ASTReader;
+ friend class ASTStmtReader;
+ explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}
public:
AsTypeExpr(Expr* SrcExpr, QualType DstType,
@@ -4166,15 +4169,16 @@ public:
SrcExpr->isInstantiationDependent()),
(DstType->containsUnexpandedParameterPack() ||
SrcExpr->containsUnexpandedParameterPack())),
- SrcExpr(SrcExpr), DstType(DstType),
- BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
-
- /// \brief Build an empty __builtin_astype
- explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}
+ SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
/// getSrcExpr - Return the Expr to be converted.
- Expr *getSrcExpr() const { return SrcExpr; }
- QualType getDstType() const { return DstType; }
+ Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
+
+ /// getBuiltinLoc - Return the location of the __builtin_astype token.
+ SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
+
+ /// getRParenLoc - Return the location of final right parenthesis.
+ SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
@@ -4186,7 +4190,7 @@ public:
static bool classof(const AsTypeExpr *) { return true; }
// Iterators
- child_range children() { return child_range(); }
+ child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
};
} // end namespace clang
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 410e9a7..a73e667 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2578,7 +2578,7 @@ Value *ScalarExprEmitter::VisitBlockExpr(const BlockExpr *block) {
Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
Value *Src = CGF.EmitScalarExpr(E->getSrcExpr());
- const llvm::Type * DstTy = ConvertType(E->getDstType());
+ const llvm::Type *DstTy = ConvertType(E->getType());
// Going from vec4->vec3 or vec3->vec4 is a special case and requires
// a shuffle vector instead of a bitcast.