Index: include/clang/AST/Stmt.h =================================================================== --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -587,7 +587,7 @@ /// NullStmt - This is the null statement ";": C99 6.8.3p3. /// -class NullStmt : public Stmt { +class NullStmt final : public Stmt { SourceLocation SemiLoc; /// True if the null statement was preceded by an empty macro, e.g: @@ -595,18 +595,28 @@ /// #define CALL(x) /// CALL(0); /// @endcode - bool HasLeadingEmptyMacro = false; + bool HasLeadingEmptyMacro; + + NullStmt(SourceLocation L, bool hasLeadingEmptyMacro) + : Stmt(NullStmtClass), SemiLoc(L), + HasLeadingEmptyMacro(hasLeadingEmptyMacro) {} + + explicit NullStmt(EmptyShell Empty) + : Stmt(NullStmtClass, Empty), HasLeadingEmptyMacro(false) {} public: friend class ASTStmtReader; friend class ASTStmtWriter; - NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false) - : Stmt(NullStmtClass), SemiLoc(L), - HasLeadingEmptyMacro(hasLeadingEmptyMacro) {} + static NullStmt *Create(const ASTContext &C, SourceLocation L, + bool hasLeadingEmptyMacro = false) { + return new (C) NullStmt(L, hasLeadingEmptyMacro); + } /// Build an empty null statement. - explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {} + static NullStmt *CreateEmpty(const ASTContext &C) { + return new (C) NullStmt(EmptyShell{}); + } SourceLocation getSemiLoc() const { return SemiLoc; } void setSemiLoc(SourceLocation L) { SemiLoc = L; } Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -5044,8 +5044,8 @@ Stmt *ASTNodeImporter::VisitNullStmt(NullStmt *S) { SourceLocation ToSemiLoc = Importer.Import(S->getSemiLoc()); - return new (Importer.getToContext()) NullStmt(ToSemiLoc, - S->hasLeadingEmptyMacro()); + return NullStmt::Create(Importer.getToContext(), ToSemiLoc, + S->hasLeadingEmptyMacro()); } Stmt *ASTNodeImporter::VisitCompoundStmt(CompoundStmt *S) { Index: lib/Sema/SemaStmt.cpp =================================================================== --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -67,7 +67,7 @@ StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro) { - return new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro); + return NullStmt::Create(Context, SemiLoc, HasLeadingEmptyMacro); } StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -6650,7 +6650,7 @@ if (Then.isInvalid()) return StmtError(); } else { - Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc()); + Then = NullStmt::Create(getSema().Context, S->getThen()->getBeginLoc()); } // Transform the "else" branch. @@ -7511,13 +7511,13 @@ if (S->isIfExists()) break; - return new (getSema().Context) NullStmt(S->getKeywordLoc()); + return NullStmt::Create(getSema().Context, S->getKeywordLoc()); case Sema::IER_DoesNotExist: if (S->isIfNotExists()) break; - return new (getSema().Context) NullStmt(S->getKeywordLoc()); + return NullStmt::Create(getSema().Context, S->getKeywordLoc()); case Sema::IER_Dependent: Dependent = true; Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -3141,7 +3141,7 @@ break; case STMT_NULL: - S = new (Context) NullStmt(Empty); + S = NullStmt::CreateEmpty(Context); break; case STMT_COMPOUND: