Add NullStmt::Clone and use it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71823 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 5165d2a..99e4972 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -290,6 +290,8 @@
/// \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 02f5eee..f8f6e06 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -98,6 +98,10 @@
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 e747236..50d5d44 100644
--- a/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -480,7 +480,7 @@
}
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) {