From d19cd90b266181c4a8d186adfa20ccebe73336cc Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 15 May 2009 00:21:21 +0000 Subject: [PATCH] Add NullStmt::Clone and use it git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71823 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Stmt.h | 2 ++ lib/AST/Stmt.cpp | 4 ++++ lib/Sema/SemaTemplateInstantiateExpr.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 5165d2ab2e..99e49722af 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -290,6 +290,8 @@ 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; } diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 02f5eee828..f8f6e067e1 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -98,6 +98,10 @@ bool Stmt::CollectingStats(bool enable) { return StatSwitch; } +NullStmt* NullStmt::Clone(ASTContext &C) const { + return new (C) NullStmt(SemiLoc); +} + void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { if (this->Body) C.Deallocate(Body); diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp index e747236204..50d5d4442f 100644 --- a/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -480,7 +480,7 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) { } Sema::OwningStmtResult TemplateStmtInstantiator::VisitNullStmt(NullStmt *S) { - return SemaRef.Owned(new (SemaRef.Context) NullStmt(S->getSemiLoc())); + return SemaRef.Owned(S->Clone(SemaRef.Context)); } Sema::OwningStmtResult TemplateStmtInstantiator::VisitLabelStmt(LabelStmt *S) { -- 2.40.0