From d497206844a894a0557e927adf29b34fe960dffd Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 8 Aug 2009 02:50:17 +0000 Subject: [PATCH] Get rid of Stmt::Clone now that we can reference count statements instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78452 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Expr.h | 16 ------- include/clang/AST/ExprCXX.h | 8 ---- include/clang/AST/ExprObjC.h | 6 --- include/clang/AST/Stmt.h | 6 --- lib/AST/Expr.cpp | 55 ------------------------ lib/AST/ExprCXX.cpp | 22 ---------- lib/AST/Stmt.cpp | 12 ------ lib/Sema/SemaTemplateDeduction.cpp | 3 +- lib/Sema/SemaTemplateInstantiateExpr.cpp | 2 +- lib/Sema/SemaTemplateInstantiateStmt.cpp | 6 +-- 10 files changed, 5 insertions(+), 131 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index d4b622ed04..23fd420914 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -374,8 +374,6 @@ public: 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 @@ public: 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 @@ public: /// \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 @@ public: 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 @@ public: Expr *getSubExpr() { return cast(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 @@ public: /// \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 @@ public: /// \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 @@ public: return SourceRange(); } - ImplicitValueInitExpr *Clone(ASTContext &C) const; - // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 008e6af2b7..a254e9914a 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -221,8 +221,6 @@ public: 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 @@ public: 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 @@ public: return SourceRange(TyBeginLoc, RParenLoc); } - CXXZeroInitValueExpr* Clone(ASTContext &C) const; - static bool classof(const Stmt *T) { return T->getStmtClass() == CXXZeroInitValueExprClass; } @@ -882,8 +876,6 @@ public: virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - UnresolvedFunctionNameExpr* Clone(ASTContext &C) const; - static bool classof(const Stmt *T) { return T->getStmtClass() == UnresolvedFunctionNameExprClass; } diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 16c5d6e0ea..d04d4977a0 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -34,8 +34,6 @@ public: explicit ObjCStringLiteral(EmptyShell Empty) : Expr(ObjCStringLiteralClass, Empty) {} - ObjCStringLiteral* Clone(ASTContext &C) const; - StringLiteral *getString() { return cast(String); } const StringLiteral *getString() const { return cast(String); } void setString(StringLiteral *S) { String = S; } @@ -106,8 +104,6 @@ public: 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 @@ public: explicit ObjCProtocolExpr(EmptyShell Empty) : Expr(ObjCProtocolExprClass, Empty) {} - ObjCProtocolExpr *Clone(ASTContext &C) const; - ObjCProtocolDecl *getProtocol() const { return TheProtocol; } void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; } diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 5a4c93d695..b86717728c 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -339,8 +339,6 @@ public: /// \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 @@ public: return SourceRange(ContinueLoc); } - ContinueStmt* Clone(ASTContext &C) const; - static bool classof(const Stmt *T) { return T->getStmtClass() == ContinueStmtClass; } @@ -982,8 +978,6 @@ public: virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); } - BreakStmt* Clone(ASTContext &C) const; - static bool classof(const Stmt *T) { return T->getStmtClass() == BreakStmtClass; } diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 0f3cbe18d9..2c07de6c79 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -28,36 +28,6 @@ using namespace clang; // 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(Val)) - ClonedVal = IntLit->Clone(C); - else - ClonedVal = cast(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 @@ StringLiteral *StringLiteral::CreateEmpty(ASTContext &C, unsigned NumStrs) { 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(StrData)); Expr::DoDestroy(C); @@ -1564,22 +1529,6 @@ ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo, RBracloc = RBrac; } -ObjCStringLiteral* ObjCStringLiteral::Clone(ASTContext &C) const { - // Clone the string literal. - StringLiteral *NewString = - String ? cast(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 @@ void DesignatedInitExpr::DoDestroy(ASTContext &C) { Expr::DoDestroy(C); } -ImplicitValueInitExpr *ImplicitValueInitExpr::Clone(ASTContext &C) const { - return new (C) ImplicitValueInitExpr(getType()); -} - //===----------------------------------------------------------------------===// // ExprIterator. //===----------------------------------------------------------------------===// diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 67d62a94ec..454dc14b6c 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -123,12 +123,6 @@ Stmt::child_iterator UnresolvedFunctionNameExpr::child_begin() { 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_begin() { 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); -} diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index a0ef5a6428..cd8fba6b7a 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -92,18 +92,6 @@ bool Stmt::CollectingStats(bool enable) { 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 diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 7fb159fec7..b3d370ab12 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -328,8 +328,7 @@ static QualType getUnqualifiedArrayType(ASTContext &Context, QualType T, 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()); } diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp index 1e97f5fcc4..186c98cf53 100644 --- a/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -147,7 +147,7 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) { // 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()]; diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp index 565b95b329..80ff5eb082 100644 --- a/lib/Sema/SemaTemplateInstantiateStmt.cpp +++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp @@ -81,7 +81,7 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) { } 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 @@ TemplateStmtInstantiator::VisitIndirectGotoStmt(IndirectGotoStmt *S) { } 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 -- 2.40.0