[cfe-commits] r78452 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/ExprObjC.h include/clang/AST/Stmt.h lib/AST/Expr.cpp lib/AST/ExprCXX.cpp lib/AST/Stmt.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp lib/Sema/SemaTemplateInstantiateStmt.cpp

Anders Carlsson andersca at mac.com
Fri Aug 7 19:50:17 PDT 2009


Author: andersca
Date: Fri Aug  7 21:50:17 2009
New Revision: 78452

URL: http://llvm.org/viewvc/llvm-project?rev=78452&view=rev
Log:
Get rid of Stmt::Clone now that we can reference count statements instead.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/include/clang/AST/ExprObjC.h
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/ExprCXX.cpp
    cfe/trunk/lib/AST/Stmt.cpp
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Aug  7 21:50:17 2009
@@ -374,8 +374,6 @@
   explicit PredefinedExpr(EmptyShell Empty) 
     : Expr(PredefinedExprClass, Empty) { }
 
-  PredefinedExpr* Clone(ASTContext &C) const;
-
   IdentType getIdentType() const { return Type; }
   void setIdentType(IdentType IT) { Type = IT; }
 
@@ -414,8 +412,6 @@
   explicit IntegerLiteral(EmptyShell Empty) 
     : Expr(IntegerLiteralClass, Empty) { }
 
-  IntegerLiteral* Clone(ASTContext &C) const;
-  
   const llvm::APInt &getValue() const { return Value; }
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
 
@@ -448,8 +444,6 @@
   /// \brief Construct an empty character literal.
   CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }
 
-  CharacterLiteral* Clone(ASTContext &C) const;
-
   SourceLocation getLoc() const { return Loc; }
   bool isWide() const { return IsWide; }
   
@@ -484,8 +478,6 @@
   explicit FloatingLiteral(EmptyShell Empty) 
     : Expr(FloatingLiteralClass, Empty), Value(0.0) { }
 
-  FloatingLiteral* Clone(ASTContext &C) const;
-
   const llvm::APFloat &getValue() const { return Value; }
   void setValue(const llvm::APFloat &Val) { Value = Val; }
 
@@ -536,8 +528,6 @@
   Expr *getSubExpr() { return cast<Expr>(Val); }
   void setSubExpr(Expr *E) { Val = E; }
 
-  ImaginaryLiteral* Clone(ASTContext &C) const;
-
   virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == ImaginaryLiteralClass; 
@@ -594,8 +584,6 @@
   /// \brief Construct an empty string literal.
   static StringLiteral *CreateEmpty(ASTContext &C, unsigned NumStrs);
 
-  StringLiteral* Clone(ASTContext &C) const;
-  
   const char *getStrData() const { return StrData; }
   unsigned getByteLength() const { return ByteLength; }
 
@@ -1869,8 +1857,6 @@
   /// \brief Build an empty GNU __null expression.
   explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }
 
-  GNUNullExpr* Clone(ASTContext &C) const;
-
   /// getTokenLocation - The location of the __null token.
   SourceLocation getTokenLocation() const { return TokenLoc; }
   void setTokenLocation(SourceLocation L) { TokenLoc = L; }
@@ -2391,8 +2377,6 @@
     return SourceRange();
   }
 
-  ImplicitValueInitExpr *Clone(ASTContext &C) const;
-
   // Iterators
   virtual child_iterator child_begin();
   virtual child_iterator child_end(); 

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Aug  7 21:50:17 2009
@@ -221,8 +221,6 @@
   CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 
     Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
 
-  CXXBoolLiteralExpr* Clone(ASTContext &C) const;
-
   bool getValue() const { return Value; }
 
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
@@ -244,8 +242,6 @@
   CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
     Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {}
 
-  CXXNullPtrLiteralExpr* Clone(ASTContext &C) const;
-
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
 
   static bool classof(const Stmt *T) {
@@ -630,8 +626,6 @@
     return SourceRange(TyBeginLoc, RParenLoc);
   }
     
-  CXXZeroInitValueExpr* Clone(ASTContext &C) const;
-
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == CXXZeroInitValueExprClass;
   }
@@ -882,8 +876,6 @@
 
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
 
-  UnresolvedFunctionNameExpr* Clone(ASTContext &C) const;
-
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == UnresolvedFunctionNameExprClass;
   }

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Fri Aug  7 21:50:17 2009
@@ -34,8 +34,6 @@
   explicit ObjCStringLiteral(EmptyShell Empty)
     : Expr(ObjCStringLiteralClass, Empty) {}
 
-  ObjCStringLiteral* Clone(ASTContext &C) const;
-
   StringLiteral *getString() { return cast<StringLiteral>(String); }
   const StringLiteral *getString() const { return cast<StringLiteral>(String); }
   void setString(StringLiteral *S) { String = S; }
@@ -106,8 +104,6 @@
   explicit ObjCSelectorExpr(EmptyShell Empty)
    : Expr(ObjCSelectorExprClass, Empty) {}
 
-  ObjCSelectorExpr *Clone(ASTContext &C) const;
-  
   Selector getSelector() const { return SelName; }
   void setSelector(Selector S) { SelName = S; }
   
@@ -148,8 +144,6 @@
   explicit ObjCProtocolExpr(EmptyShell Empty)
     : Expr(ObjCProtocolExprClass, Empty) {}
 
-  ObjCProtocolExpr *Clone(ASTContext &C) const;
-  
   ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
   void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
     

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Aug  7 21:50:17 2009
@@ -339,8 +339,6 @@
   /// \brief Build an empty null statement.
   explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) { }
 
-  NullStmt* Clone(ASTContext &C) const;
-
   SourceLocation getSemiLoc() const { return SemiLoc; }
   void setSemiLoc(SourceLocation L) { SemiLoc = L; }
 
@@ -955,8 +953,6 @@
     return SourceRange(ContinueLoc); 
   }
 
-  ContinueStmt* Clone(ASTContext &C) const;
-
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == ContinueStmtClass; 
   }
@@ -982,8 +978,6 @@
 
   virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
 
-  BreakStmt* Clone(ASTContext &C) const;
-
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == BreakStmtClass; 
   }

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Aug  7 21:50:17 2009
@@ -28,36 +28,6 @@
 // Primary Expressions.
 //===----------------------------------------------------------------------===//
 
-PredefinedExpr* PredefinedExpr::Clone(ASTContext &C) const {
-  return new (C) PredefinedExpr(Loc, getType(), Type);
-}
-
-IntegerLiteral* IntegerLiteral::Clone(ASTContext &C) const {
-  return new (C) IntegerLiteral(Value, getType(), Loc);
-}
-
-CharacterLiteral* CharacterLiteral::Clone(ASTContext &C) const {
-  return new (C) CharacterLiteral(Value, IsWide, getType(), Loc);
-}
-
-FloatingLiteral* FloatingLiteral::Clone(ASTContext &C) const {
-  return new (C) FloatingLiteral(Value, IsExact, getType(), Loc);
-}
-
-ImaginaryLiteral* ImaginaryLiteral::Clone(ASTContext &C) const {
-  // FIXME: Use virtual Clone(), once it is available
-  Expr *ClonedVal = 0;
-  if (const IntegerLiteral *IntLit = dyn_cast<IntegerLiteral>(Val))
-    ClonedVal = IntLit->Clone(C);
-  else
-    ClonedVal = cast<FloatingLiteral>(Val)->Clone(C);
-  return new (C) ImaginaryLiteral(ClonedVal, getType());
-}
-
-GNUNullExpr* GNUNullExpr::Clone(ASTContext &C) const {
-  return new (C) GNUNullExpr(getType(), TokenLoc);
-}
-
 /// getValueAsApproximateDouble - This returns the value as an inaccurate
 /// double.  Note that this may cause loss of precision, but is useful for
 /// debugging dumps, etc.
@@ -106,11 +76,6 @@
   return SL;
 }
 
-StringLiteral* StringLiteral::Clone(ASTContext &C) const {
-  return Create(C, StrData, ByteLength, IsWide, getType(),
-                TokLocs, NumConcatenated);
-}
-
 void StringLiteral::DoDestroy(ASTContext &C) {
   C.Deallocate(const_cast<char*>(StrData));
   Expr::DoDestroy(C);
@@ -1564,22 +1529,6 @@
   RBracloc = RBrac;
 }
 
-ObjCStringLiteral* ObjCStringLiteral::Clone(ASTContext &C) const {
-  // Clone the string literal.
-  StringLiteral *NewString = 
-    String ? cast<StringLiteral>(String)->Clone(C) : 0;
-  
-  return new (C) ObjCStringLiteral(NewString, getType(), AtLoc);
-}
-
-ObjCSelectorExpr *ObjCSelectorExpr::Clone(ASTContext &C) const {
-  return new (C) ObjCSelectorExpr(getType(), SelName, AtLoc, RParenLoc);
-}
-
-ObjCProtocolExpr *ObjCProtocolExpr::Clone(ASTContext &C) const {
-  return new (C) ObjCProtocolExpr(getType(), TheProtocol, AtLoc, RParenLoc);
-}
-
 // constructor for class messages. 
 // FIXME: clsName should be typed to ObjCInterfaceType
 ObjCMessageExpr::ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
@@ -1835,10 +1784,6 @@
   Expr::DoDestroy(C);
 }
 
-ImplicitValueInitExpr *ImplicitValueInitExpr::Clone(ASTContext &C) const {
-  return new (C) ImplicitValueInitExpr(getType());
-}
-
 //===----------------------------------------------------------------------===//
 //  ExprIterator.
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Fri Aug  7 21:50:17 2009
@@ -123,12 +123,6 @@
 Stmt::child_iterator UnresolvedFunctionNameExpr::child_end() {
   return child_iterator();
 }
-
-UnresolvedFunctionNameExpr* 
-UnresolvedFunctionNameExpr::Clone(ASTContext &C) const {
-  return new (C) UnresolvedFunctionNameExpr(Name, getType(), Loc);
-}
-
 // UnaryTypeTraitExpr
 Stmt::child_iterator UnaryTypeTraitExpr::child_begin() {
   return child_iterator();
@@ -515,19 +509,3 @@
 Stmt::child_iterator CXXUnresolvedMemberExpr::child_end() {
   return child_iterator(&Base + 1);
 }
-
-//===----------------------------------------------------------------------===//
-//  Cloners
-//===----------------------------------------------------------------------===//
-
-CXXBoolLiteralExpr* CXXBoolLiteralExpr::Clone(ASTContext &C) const {
-  return new (C) CXXBoolLiteralExpr(Value, getType(), Loc);
-}
-
-CXXNullPtrLiteralExpr* CXXNullPtrLiteralExpr::Clone(ASTContext &C) const {
-  return new (C) CXXNullPtrLiteralExpr(getType(), Loc);
-}
-
-CXXZeroInitValueExpr* CXXZeroInitValueExpr::Clone(ASTContext &C) const {
-  return new (C) CXXZeroInitValueExpr(getType(), TyBeginLoc, RParenLoc);
-}

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Fri Aug  7 21:50:17 2009
@@ -92,18 +92,6 @@
   return StatSwitch;
 }
 
-NullStmt* NullStmt::Clone(ASTContext &C) const {
-  return new (C) NullStmt(SemiLoc);
-}
-
-ContinueStmt* ContinueStmt::Clone(ASTContext &C) const {
-  return new (C) ContinueStmt(ContinueLoc);
-}
-
-BreakStmt* BreakStmt::Clone(ASTContext &C) const {
-  return new (C) BreakStmt(BreakLoc);
-}
-
 void SwitchStmt::DoDestroy(ASTContext &Ctx) {
   // Destroy the SwitchCase statements in this switch. In the normal
   // case, this loop will merely decrement the reference counts from 

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Aug  7 21:50:17 2009
@@ -328,8 +328,7 @@
   if (Elt == DSAT->getElementType())
     return T;
   
-  // FIXME: Clone expression!
-  return Context.getDependentSizedArrayType(Elt, DSAT->getSizeExpr(),
+  return Context.getDependentSizedArrayType(Elt, DSAT->getSizeExpr()->Retain(),
                                             DSAT->getSizeModifier(), 0,
                                             SourceRange());
 }

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Fri Aug  7 21:50:17 2009
@@ -147,7 +147,7 @@
     // arguments left unspecified.
     if (NTTP->getPosition() >= TemplateArgs.size() ||
         TemplateArgs[NTTP->getPosition()].isNull())
-      return SemaRef.Owned(E); // FIXME: Clone the expression!
+      return SemaRef.Owned(E->Retain());
     
     const TemplateArgument &Arg = TemplateArgs[NTTP->getPosition()]; 
     

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp?rev=78452&r1=78451&r2=78452&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp Fri Aug  7 21:50:17 2009
@@ -81,7 +81,7 @@
 }
 
 Sema::OwningStmtResult TemplateStmtInstantiator::VisitNullStmt(NullStmt *S) {
-  return SemaRef.Owned(S->Clone(SemaRef.Context));
+  return SemaRef.Owned(S->Retain());
 }
 
 Sema::OwningStmtResult TemplateStmtInstantiator::VisitLabelStmt(LabelStmt *S) {
@@ -112,12 +112,12 @@
 }
 
 Sema::OwningStmtResult TemplateStmtInstantiator::VisitBreakStmt(BreakStmt *S) {
-  return SemaRef.Owned(S->Clone(SemaRef.Context));
+  return SemaRef.Owned(S->Retain());
 }
 
 Sema::OwningStmtResult 
 TemplateStmtInstantiator::VisitContinueStmt(ContinueStmt *S) {
-  return SemaRef.Owned(S->Clone(SemaRef.Context));
+  return SemaRef.Owned(S->Retain());
 }
 
 Sema::OwningStmtResult





More information about the cfe-commits mailing list