[cfe-commits] r135257 - in /cfe/trunk: include/clang/AST/Expr.h lib/CodeGen/CGExprScalar.cpp

John McCall rjmccall at apple.com
Thu Jul 14 23:56:33 PDT 2011


Author: rjmccall
Date: Fri Jul 15 01:56:33 2011
New Revision: 135257

URL: http://llvm.org/viewvc/llvm-project?rev=135257&view=rev
Log:
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.


Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=135257&r1=135256&r2=135257&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Jul 15 01:56:33 2011
@@ -4149,11 +4149,14 @@
 /// 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 @@
             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 @@
   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
 

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=135257&r1=135256&r2=135257&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Jul 15 01:56:33 2011
@@ -2578,7 +2578,7 @@
 
 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.





More information about the cfe-commits mailing list