[ClangImporter] Use new CXXThisExpr::Create function

The constructor takes a new arg which `Create` now handles. Use it
instead.
This commit is contained in:
Ben Barham
2024-03-21 20:25:59 -07:00
parent b33055038e
commit 0c0c4ea7c3
3 changed files with 8 additions and 7 deletions

View File

@@ -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 =

View File

@@ -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);

View File

@@ -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));