[clang] [clang] Add `::_placement_new` expression for built-in global placement new (PR #72209)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 13 21:19:00 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 1609f1c2a5ecc0e0e28f433ec9205122478ddaa3 75cf305fe732d00be910a6aa0afe79953c5b7186 -- clang/include/clang/AST/ExprCXX.h clang/include/clang/AST/Stmt.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/ExprCXX.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/CodeGen/CGExprCXX.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Interpreter/Interpreter.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Parse/ParseObjc.cpp clang/lib/Parse/ParseTentative.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp clang/test/AST/ast-dump-expr.cpp clang/test/CodeGenCXX/new.cpp clang/test/SemaCXX/new-delete.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index d760af796a..b769ddb69c 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2283,8 +2283,8 @@ class CXXNewExpr final
SourceRange DirectInitRange);
/// Build a c++ builtin placement new expression
- CXXNewExpr(Expr *PlacementArg,
- SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
+ CXXNewExpr(Expr *PlacementArg, SourceRange TypeIdParens,
+ std::optional<Expr *> ArraySize,
CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
SourceRange DirectInitRange);
@@ -2308,8 +2308,9 @@ public:
static CXXNewExpr *
CreatePlacementNew(const ASTContext &Ctx, Expr *PlacementArg,
SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
- CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
- QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
+ CXXNewInitializationStyle InitializationStyle,
+ Expr *Initializer, QualType Ty,
+ TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
SourceRange DirectInitRange);
/// Create an empty c++ new expression.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ab9a0d0713..ec1d86f7ea 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6810,18 +6810,18 @@ public:
bool ListInitialization);
/// ActOnCXXNew - Parsed a C++ 'new' expression.
- ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, bool IsPlacementNewExpr,
- SourceLocation PlacementLParen,
- MultiExprArg PlacementArgs,
- SourceLocation PlacementRParen,
- SourceRange TypeIdParens, Declarator &D,
- Expr *Initializer);
ExprResult
- BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacementNewExpr, SourceLocation PlacementLParen,
- MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
- SourceRange TypeIdParens, QualType AllocType,
- TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
- SourceRange DirectInitRange, Expr *Initializer);
+ ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, bool IsPlacementNewExpr,
+ SourceLocation PlacementLParen, MultiExprArg PlacementArgs,
+ SourceLocation PlacementRParen, SourceRange TypeIdParens,
+ Declarator &D, Expr *Initializer);
+ ExprResult
+ BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacementNewExpr,
+ SourceLocation PlacementLParen, MultiExprArg PlacementArgs,
+ SourceLocation PlacementRParen, SourceRange TypeIdParens,
+ QualType AllocType, TypeSourceInfo *AllocTypeInfo,
+ std::optional<Expr *> ArraySize, SourceRange DirectInitRange,
+ Expr *Initializer);
/// Determine whether \p FD is an aligned allocation or deallocation
/// function that is unavailable.
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 3204fb69b3..625d86b84e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8104,16 +8104,16 @@ ExpectedStmt ASTNodeImporter::VisitCXXNewExpr(CXXNewExpr *E) {
if (E->isPlacementNewExpr())
return CXXNewExpr::CreatePlacementNew(
- Importer.getToContext(), ToPlacementArgs[0], ToTypeIdParens, ToArraySize,
- E->getInitializationStyle(), ToInitializer, ToType, ToAllocatedTypeSourceInfo,
- ToSourceRange, ToDirectInitRange);
+ Importer.getToContext(), ToPlacementArgs[0], ToTypeIdParens,
+ ToArraySize, E->getInitializationStyle(), ToInitializer, ToType,
+ ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
else
return CXXNewExpr::Create(
Importer.getToContext(), E->isGlobalNew(), ToOperatorNew,
ToOperatorDelete, E->passAlignment(), E->doesUsualArrayDeleteWantSize(),
- ToPlacementArgs, ToTypeIdParens, ToArraySize, E->getInitializationStyle(),
- ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
- ToDirectInitRange);
+ ToPlacementArgs, ToTypeIdParens, ToArraySize,
+ E->getInitializationStyle(), ToInitializer, ToType,
+ ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
}
ExpectedStmt ASTNodeImporter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 7c7f4c2f31..e47ddc4ab0 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -235,16 +235,17 @@ CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
setDependence(computeDependence(this));
}
-CXXNewExpr::CXXNewExpr(Expr *PlacementArg,
- SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
- CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
- QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
+CXXNewExpr::CXXNewExpr(Expr *PlacementArg, SourceRange TypeIdParens,
+ std::optional<Expr *> ArraySize,
+ CXXNewInitializationStyle InitializationStyle,
+ Expr *Initializer, QualType Ty,
+ TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
SourceRange DirectInitRange)
: CXXNewExpr(true, nullptr, nullptr, false, false,
ArrayRef<Expr *>(&PlacementArg, 1), TypeIdParens, ArraySize,
- InitializationStyle, Initializer, Ty,
- AllocatedTypeInfo, Range, DirectInitRange) {
- CXXNewExprBits.IsPlacementNewExpr = true;
+ InitializationStyle, Initializer, Ty, AllocatedTypeInfo, Range,
+ DirectInitRange) {
+ CXXNewExprBits.IsPlacementNewExpr = true;
}
CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
@@ -279,22 +280,20 @@ CXXNewExpr *CXXNewExpr::Create(
}
CXXNewExpr *CXXNewExpr::CreatePlacementNew(
- const ASTContext &Ctx, Expr *PlacementArg,
- SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
+ const ASTContext &Ctx, Expr *PlacementArg, SourceRange TypeIdParens,
+ std::optional<Expr *> ArraySize,
CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
SourceRange DirectInitRange) {
bool IsArray = ArraySize.has_value();
bool HasInit = Initializer != nullptr;
bool IsParenTypeId = TypeIdParens.isValid();
- void *Mem =
- Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
- IsArray + HasInit + 1, IsParenTypeId),
- alignof(CXXNewExpr));
+ void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
+ IsArray + HasInit + 1, IsParenTypeId),
+ alignof(CXXNewExpr));
return new (Mem)
- CXXNewExpr(PlacementArg, TypeIdParens,
- ArraySize, InitializationStyle, Initializer, Ty,
- AllocatedTypeInfo, Range, DirectInitRange);
+ CXXNewExpr(PlacementArg, TypeIdParens, ArraySize, InitializationStyle,
+ Initializer, Ty, AllocatedTypeInfo, Range, DirectInitRange);
}
CXXNewExpr *CXXNewExpr::CreateEmpty(const ASTContext &Ctx, bool IsArray,
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7652e22a6a..ecf761feca 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3185,8 +3185,8 @@ static bool HandleLValueIndirectMember(EvalInfo &Info, const Expr *E,
}
/// Get the size of the given type in char units.
-static bool HandleSizeof(EvalInfo &Info, SourceLocation Loc,
- QualType Type, CharUnits &Size) {
+static bool HandleSizeof(EvalInfo &Info, SourceLocation Loc, QualType Type,
+ CharUnits &Size) {
// sizeof(void), __alignof__(void), sizeof(function) = 1 as a gcc
// extension.
if (Type->isVoidType() || Type->isFunctionType()) {
@@ -9751,7 +9751,8 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
bool IsNothrow = false;
bool IsPlacement = false;
- if (E->isReservedPlacementNew() && Info.CurrentCall->isStdFunction() && !E->isArray()) {
+ if (E->isReservedPlacementNew() && Info.CurrentCall->isStdFunction() &&
+ !E->isArray()) {
// FIXME Support array placement new.
assert(E->getNumPlacementArgs() == 1);
if (!EvaluatePointer(E->getPlacementArg(0), Result, Info))
@@ -9759,7 +9760,8 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
if (Result.Designator.Invalid)
return false;
IsPlacement = true;
- } else if (E->isPlacementNewExpr() || !OperatorNew->isReplaceableGlobalAllocationFunction()) {
+ } else if (E->isPlacementNewExpr() ||
+ !OperatorNew->isReplaceableGlobalAllocationFunction()) {
Info.FFDiag(E, diag::note_constexpr_new_non_replaceable)
<< isa<CXXMethodDecl>(OperatorNew) << OperatorNew;
return false;
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 93ba4a0603..f05f516811 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -604,12 +604,13 @@ public:
SourceLocation(), Args, SourceLocation());
}
Expr *Args[] = {AllocCall.get()};
- ExprResult CXXNewCall = S.BuildCXXNew(
- E->getSourceRange(),
- /*UseGlobal=*/true, /*IsPlacementNewExpr=*/false,
- /*PlacementLParen=*/SourceLocation(), Args, /*PlacementRParen=*/SourceLocation(),
- /*TypeIdParens=*/SourceRange(), TSI->getType(), TSI, std::nullopt,
- E->getSourceRange(), E);
+ ExprResult CXXNewCall =
+ S.BuildCXXNew(E->getSourceRange(),
+ /*UseGlobal=*/true, /*IsPlacementNewExpr=*/false,
+ /*PlacementLParen=*/SourceLocation(), Args,
+ /*PlacementRParen=*/SourceLocation(),
+ /*TypeIdParens=*/SourceRange(), TSI->getType(), TSI,
+ std::nullopt, E->getSourceRange(), E);
assert(!CXXNewCall.isInvalid() &&
"Can't create runtime placement new call!");
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 18b2fd86e5..bca29fc83b 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3295,7 +3295,7 @@ static void SetupFixedPointError(const LangOptions &LangOpts,
bool &isInvalid) {
assert(!LangOpts.FixedPoint);
DiagID = diag::err_fixed_point_not_enabled;
- PrevSpec = ""; // Not used by diagnostic
+ PrevSpec = ""; // Not used by diagnostic
isInvalid = true;
}
@@ -5456,8 +5456,8 @@ bool Parser::isTypeSpecifierQualifier() {
return isTypeSpecifierQualifier();
case tok::coloncolon: // ::foo::bar
- if (NextToken().is(tok::kw_new) || // ::new
- NextToken().is(tok::kw_delete) || // ::delete
+ if (NextToken().is(tok::kw_new) || // ::new
+ NextToken().is(tok::kw_delete) || // ::delete
NextToken().is(tok::kw__placement_new)) // ::_placement_new
return false;
@@ -5650,8 +5650,8 @@ bool Parser::isDeclarationSpecifier(
case tok::coloncolon: // ::foo::bar
if (!getLangOpts().CPlusPlus)
return false;
- if (NextToken().is(tok::kw_new) || // ::new
- NextToken().is(tok::kw_delete) || // ::delete
+ if (NextToken().is(tok::kw_new) || // ::new
+ NextToken().is(tok::kw_delete) || // ::delete
NextToken().is(tok::kw__placement_new)) // ::_placement_new
return false;
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index f21680834c..1d3433f2d5 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -186,7 +186,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
if (Tok.is(tok::coloncolon)) {
// ::new and ::delete aren't nested-name-specifiers.
tok::TokenKind NextKind = NextToken().getKind();
- if (NextKind == tok::kw_new || NextKind == tok::kw_delete || NextKind == tok::kw__placement_new)
+ if (NextKind == tok::kw_new || NextKind == tok::kw_delete ||
+ NextKind == tok::kw__placement_new)
return false;
if (NextKind == tok::l_brace) {
@@ -3171,7 +3172,8 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType,
///
ExprResult
Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
- assert((Tok.is(tok::kw_new) || Tok.is(tok::kw__placement_new)) && "expected 'new' token");
+ assert((Tok.is(tok::kw_new) || Tok.is(tok::kw__placement_new)) &&
+ "expected 'new' token");
const bool IsPlacementNewExpr = Tok.is(tok::kw__placement_new);
ConsumeToken(); // Consume 'new'
@@ -3308,8 +3310,8 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
if (Initializer.isInvalid())
return Initializer;
- return Actions.ActOnCXXNew(Start, UseGlobal, IsPlacementNewExpr, PlacementLParen,
- PlacementArgs, PlacementRParen,
+ return Actions.ActOnCXXNew(Start, UseGlobal, IsPlacementNewExpr,
+ PlacementLParen, PlacementArgs, PlacementRParen,
TypeIdParens, DeclaratorInfo, Initializer.get());
}
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 623e3eb4ed..7d7a044a6b 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1444,8 +1444,8 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::coloncolon: { // ::foo::bar
const Token &Next = NextToken();
- if (Next.isOneOf(tok::kw_new, // ::new
- tok::kw_delete, // ::delete
+ if (Next.isOneOf(tok::kw_new, // ::new
+ tok::kw_delete, // ::delete
tok::kw__placement_new)) // ::_placement_new
return TPResult::False;
[[fallthrough]];
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b8e606b3a4..cf015caffa 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1875,10 +1875,10 @@ static bool doesUsualArrayDeleteWantSize(Sema &S, SourceLocation loc,
/// \param Initializer The initializing expression or initializer-list, or null
/// if there is none.
ExprResult
-Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, bool IsPlacementNewExpr,
- SourceLocation PlacementLParen, MultiExprArg PlacementArgs,
- SourceLocation PlacementRParen, SourceRange TypeIdParens,
- Declarator &D, Expr *Initializer) {
+Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
+ bool IsPlacementNewExpr, SourceLocation PlacementLParen,
+ MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
+ SourceRange TypeIdParens, Declarator &D, Expr *Initializer) {
std::optional<Expr *> ArraySize;
// If the specified type is an array, unwrap it and save the expression.
if (D.getNumTypeObjects() > 0 &&
@@ -1940,10 +1940,10 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, bool IsPlacementNewEx
if (ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer))
DirectInitRange = List->getSourceRange();
- return BuildCXXNew(SourceRange(StartLoc, D.getEndLoc()), UseGlobal, IsPlacementNewExpr,
- PlacementLParen, PlacementArgs, PlacementRParen,
- TypeIdParens, AllocType, TInfo, ArraySize, DirectInitRange,
- Initializer);
+ return BuildCXXNew(SourceRange(StartLoc, D.getEndLoc()), UseGlobal,
+ IsPlacementNewExpr, PlacementLParen, PlacementArgs,
+ PlacementRParen, TypeIdParens, AllocType, TInfo, ArraySize,
+ DirectInitRange, Initializer);
}
static bool isLegalArrayNewInitializer(CXXNewInitializationStyle Style,
@@ -1997,14 +1997,13 @@ void Sema::diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD,
}
}
-ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacementNewExpr,
- SourceLocation PlacementLParen,
- MultiExprArg PlacementArgs,
- SourceLocation PlacementRParen,
- SourceRange TypeIdParens, QualType AllocType,
- TypeSourceInfo *AllocTypeInfo,
- std::optional<Expr *> ArraySize,
- SourceRange DirectInitRange, Expr *Initializer) {
+ExprResult
+Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacementNewExpr,
+ SourceLocation PlacementLParen, MultiExprArg PlacementArgs,
+ SourceLocation PlacementRParen, SourceRange TypeIdParens,
+ QualType AllocType, TypeSourceInfo *AllocTypeInfo,
+ std::optional<Expr *> ArraySize, SourceRange DirectInitRange,
+ Expr *Initializer) {
SourceRange TypeRange = AllocTypeInfo->getTypeLoc().getSourceRange();
SourceLocation StartLoc = Range.getBegin();
@@ -2286,7 +2285,9 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacement
bool PassAlignment = getLangOpts().AlignedAllocation &&
Alignment > NewAlignment;
- bool HaveDependentPlacementTypes = AllocType->isDependentType() || Expr::hasAnyTypeDependentArguments(PlacementArgs);
+ bool HaveDependentPlacementTypes =
+ AllocType->isDependentType() ||
+ Expr::hasAnyTypeDependentArguments(PlacementArgs);
AllocationFunctionScope Scope = UseGlobal ? AFS_Global : AFS_Both;
if (!HaveDependentPlacementTypes && !IsPlacementNewExpr &&
@@ -2308,10 +2309,12 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacement
assert(UseGlobal);
QualType VoidPtr = Context.getPointerType(Context.VoidTy);
- InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, VoidPtr, false);
- ExprResult ArgE = PerformCopyInitialization(Entity, SourceLocation(), PlacementArgs[0], false, false);
+ InitializedEntity Entity =
+ InitializedEntity::InitializeParameter(Context, VoidPtr, false);
+ ExprResult ArgE = PerformCopyInitialization(Entity, SourceLocation(),
+ PlacementArgs[0], false, false);
if (ArgE.isInvalid())
- return ExprError();
+ return ExprError();
Expr *Arg = ArgE.getAs<Expr>();
CheckArrayAccess(Arg);
@@ -2499,9 +2502,9 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, bool IsPlacement
}
if (IsPlacementNewExpr)
- return CXXNewExpr::CreatePlacementNew(Context, PlacementArgs[0], TypeIdParens, ArraySize,
- InitStyle, Initializer, ResultType, AllocTypeInfo,
- Range, DirectInitRange);
+ return CXXNewExpr::CreatePlacementNew(
+ Context, PlacementArgs[0], TypeIdParens, ArraySize, InitStyle,
+ Initializer, ResultType, AllocTypeInfo, Range, DirectInitRange);
else
return CXXNewExpr::Create(Context, UseGlobal, OperatorNew, OperatorDelete,
PassAlignment, UsualArrayDeleteWantsSize,
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 5fc64fa50d..0c6abd7cad 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3343,7 +3343,8 @@ public:
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, bool IsPlacementNewExpr,
+ ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal,
+ bool IsPlacementNewExpr,
SourceLocation PlacementLParen,
MultiExprArg PlacementArgs,
SourceLocation PlacementRParen,
@@ -3351,16 +3352,10 @@ public:
TypeSourceInfo *AllocatedTypeInfo,
std::optional<Expr *> ArraySize,
SourceRange DirectInitRange, Expr *Initializer) {
- return getSema().BuildCXXNew(StartLoc, UseGlobal, IsPlacementNewExpr,
- PlacementLParen,
- PlacementArgs,
- PlacementRParen,
- TypeIdParens,
- AllocatedType,
- AllocatedTypeInfo,
- ArraySize,
- DirectInitRange,
- Initializer);
+ return getSema().BuildCXXNew(
+ StartLoc, UseGlobal, IsPlacementNewExpr, PlacementLParen, PlacementArgs,
+ PlacementRParen, TypeIdParens, AllocatedType, AllocatedTypeInfo,
+ ArraySize, DirectInitRange, Initializer);
}
/// Build a new C++ "delete" expression.
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 339b26d44c..16cd95dfce 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -1047,7 +1047,8 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
// where new can return NULL. If we end up supporting that option, we can
// consider adding a check for it here.
// C++11 [basic.stc.dynamic.allocation]p3.
- if (const auto *ProtoType = FD ? FD->getType()->getAs<FunctionProtoType>() : nullptr)
+ if (const auto *ProtoType =
+ FD ? FD->getType()->getAs<FunctionProtoType>() : nullptr)
if (!ProtoType->isNothrow())
if (auto dSymVal = symVal.getAs<DefinedOrUnknownSVal>())
State = State->assume(*dSymVal, true);
``````````
</details>
https://github.com/llvm/llvm-project/pull/72209
More information about the cfe-commits
mailing list