From 0c0c4ea7c33b4c71a90c2139088ac8e1f7d4b51e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 21 Mar 2024 20:25:59 -0700 Subject: [PATCH] [ClangImporter] Use new `CXXThisExpr::Create` function The constructor takes a new arg which `Create` now handles. Use it instead. --- lib/ClangImporter/ClangDerivedConformances.cpp | 4 ++-- lib/ClangImporter/ClangImporter.cpp | 6 +++--- lib/ClangImporter/SwiftDeclSynthesizer.cpp | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ClangImporter/ClangDerivedConformances.cpp b/lib/ClangImporter/ClangDerivedConformances.cpp index 9219140eff6..eaea4af632c 100644 --- a/lib/ClangImporter/ClangDerivedConformances.cpp +++ b/lib/ClangImporter/ClangDerivedConformances.cpp @@ -264,8 +264,8 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl, clang::UnresolvedSet<1> ops; auto qualType = clang::QualType(classDecl->getTypeForDecl(), 0); - auto arg = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), qualType, false); + auto arg = clang::CXXThisExpr::Create(clangCtx, clang::SourceLocation(), + qualType, false); arg->setType(clang::QualType(classDecl->getTypeForDecl(), 0)); clang::OverloadedOperatorKind opKind = diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index e5427c01415..f2c956d623e 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -5211,9 +5211,9 @@ static clang::CXXMethodDecl *synthesizeCxxBaseGetterAccessorMethod( // Returns the expression that accesses the base field from derived type. auto createFieldAccess = [&]() -> clang::Expr * { - auto *thisExpr = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), newMethod->getThisType(), - /*IsImplicit=*/false); + auto *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); clang::QualType baseClassPtr = clangCtx.getRecordType(baseClass); baseClassPtr.addConst(); baseClassPtr = clangCtx.getPointerType(baseClassPtr); diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index 3391ed98f93..5ab4a9037be 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -2114,8 +2114,9 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( auto diagState = clangSema.DelayedDiagnostics.push(diagPool); // Construct the method's body. - clang::Expr *thisExpr = new (clangCtx) clang::CXXThisExpr( - clang::SourceLocation(), newMethod->getThisType(), /*IsImplicit=*/false); + clang::Expr *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); if (castThisToNonConstThis) { auto baseClassPtr = clangCtx.getPointerType(clangCtx.getRecordType(derivedClass));