Skip to content

Commit 48d703e

Browse files
committed
Revert "[clang][Interp] Implement dynamic memory allocation handling (#70306)"
This reverts commit fa133d3. It looks like this has some more serious problems: https://lab.llvm.org/buildbot/#/builders/39/builds/528 As well as build failures on MacOS.
1 parent ba3dcec commit 48d703e

19 files changed

+8
-1196
lines changed

clang/lib/AST/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ add_clang_library(clangAST
7575
Interp/InterpBuiltin.cpp
7676
Interp/Floating.cpp
7777
Interp/EvaluationResult.cpp
78-
Interp/DynamicAllocator.cpp
7978
Interp/Interp.cpp
8079
Interp/InterpBlock.cpp
8180
Interp/InterpFrame.cpp

clang/lib/AST/Interp/Compiler.cpp

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,109 +2771,6 @@ bool Compiler<Emitter>::VisitCXXInheritedCtorInitExpr(
27712771
return this->emitCall(F, 0, E);
27722772
}
27732773

2774-
template <class Emitter>
2775-
bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
2776-
assert(classifyPrim(E->getType()) == PT_Ptr);
2777-
const Expr *Init = E->getInitializer();
2778-
QualType ElementType = E->getAllocatedType();
2779-
std::optional<PrimType> ElemT = classify(ElementType);
2780-
unsigned PlacementArgs = E->getNumPlacementArgs();
2781-
bool IsNoThrow = false;
2782-
2783-
// FIXME: Better diagnostic. diag::note_constexpr_new_placement
2784-
if (PlacementArgs != 0) {
2785-
// The only new-placement list we support is of the form (std::nothrow).
2786-
//
2787-
// FIXME: There is no restriction on this, but it's not clear that any
2788-
// other form makes any sense. We get here for cases such as:
2789-
//
2790-
// new (std::align_val_t{N}) X(int)
2791-
//
2792-
// (which should presumably be valid only if N is a multiple of
2793-
// alignof(int), and in any case can't be deallocated unless N is
2794-
// alignof(X) and X has new-extended alignment).
2795-
if (PlacementArgs != 1 || !E->getPlacementArg(0)->getType()->isNothrowT())
2796-
return this->emitInvalid(E);
2797-
2798-
if (!this->discard(E->getPlacementArg(0)))
2799-
return false;
2800-
IsNoThrow = true;
2801-
}
2802-
2803-
const Descriptor *Desc;
2804-
if (ElemT) {
2805-
if (E->isArray())
2806-
Desc = nullptr; // We're not going to use it in this case.
2807-
else
2808-
Desc = P.createDescriptor(E, *ElemT, Descriptor::InlineDescMD,
2809-
/*IsConst=*/false, /*IsTemporary=*/false,
2810-
/*IsMutable=*/false);
2811-
} else {
2812-
Desc = P.createDescriptor(
2813-
E, ElementType.getTypePtr(),
2814-
E->isArray() ? std::nullopt : Descriptor::InlineDescMD,
2815-
/*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false, Init);
2816-
}
2817-
2818-
if (E->isArray()) {
2819-
std::optional<const Expr *> ArraySizeExpr = E->getArraySize();
2820-
if (!ArraySizeExpr)
2821-
return false;
2822-
PrimType SizeT = classifyPrim((*ArraySizeExpr)->getType());
2823-
2824-
if (!this->visit(*ArraySizeExpr))
2825-
return false;
2826-
2827-
if (ElemT) {
2828-
// N primitive elements.
2829-
if (!this->emitAllocN(SizeT, *ElemT, E, IsNoThrow, E))
2830-
return false;
2831-
} else {
2832-
// N Composite elements.
2833-
if (!this->emitAllocCN(SizeT, Desc, IsNoThrow, E))
2834-
return false;
2835-
}
2836-
2837-
if (Init && !this->visitInitializer(Init))
2838-
return false;
2839-
2840-
} else {
2841-
// Allocate just one element.
2842-
if (!this->emitAlloc(Desc, E))
2843-
return false;
2844-
2845-
if (Init) {
2846-
if (ElemT) {
2847-
if (!this->visit(Init))
2848-
return false;
2849-
2850-
if (!this->emitInit(*ElemT, E))
2851-
return false;
2852-
} else {
2853-
// Composite.
2854-
if (!this->visitInitializer(Init))
2855-
return false;
2856-
}
2857-
}
2858-
}
2859-
2860-
if (DiscardResult)
2861-
return this->emitPopPtr(E);
2862-
2863-
return true;
2864-
}
2865-
2866-
template <class Emitter>
2867-
bool Compiler<Emitter>::VisitCXXDeleteExpr(const CXXDeleteExpr *E) {
2868-
const Expr *Arg = E->getArgument();
2869-
2870-
// Arg must be an lvalue.
2871-
if (!this->visit(Arg))
2872-
return false;
2873-
2874-
return this->emitFree(E->isArrayForm(), E);
2875-
}
2876-
28772774
template <class Emitter>
28782775
bool Compiler<Emitter>::VisitExpressionTraitExpr(const ExpressionTraitExpr *E) {
28792776
assert(Ctx.getLangOpts().CPlusPlus);

clang/lib/AST/Interp/Compiler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
190190
bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E);
191191
bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
192192
bool VisitStmtExpr(const StmtExpr *E);
193-
bool VisitCXXNewExpr(const CXXNewExpr *E);
194-
bool VisitCXXDeleteExpr(const CXXDeleteExpr *E);
195193

196194
// Statements.
197195
bool visitCompoundStmt(const CompoundStmt *S);

clang/lib/AST/Interp/DynamicAllocator.cpp

Lines changed: 0 additions & 118 deletions
This file was deleted.

clang/lib/AST/Interp/DynamicAllocator.h

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)