diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -730,6 +730,11 @@ explicit CXXBoolLiteralExpr(EmptyShell Empty) : Expr(CXXBoolLiteralExprClass, Empty) {} + static CXXBoolLiteralExpr *Create(const ASTContext &C, bool Val, QualType Ty, + SourceLocation Loc) { + return new (C) CXXBoolLiteralExpr(Val, Ty, Loc); + } + bool getValue() const { return CXXBoolLiteralExprBits.Value; } void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; } diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -7922,8 +7922,8 @@ if (!ToLocationOrErr) return ToLocationOrErr.takeError(); - return new (Importer.getToContext()) CXXBoolLiteralExpr( - E->getValue(), *ToTypeOrErr, *ToLocationOrErr); + return CXXBoolLiteralExpr::Create(Importer.getToContext(), E->getValue(), + *ToTypeOrErr, *ToLocationOrErr); } ExpectedStmt ASTNodeImporter::VisitMemberExpr(MemberExpr *E) { diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7829,8 +7829,8 @@ E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(), Kind, T, Loc); } else if (T->isBooleanType()) { - E = new (Context) CXXBoolLiteralExpr(Arg.getAsIntegral().getBoolValue(), - T, Loc); + E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(), + T, Loc); } else if (T->isNullPtrType()) { E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc); } else {