File tree Expand file tree Collapse file tree 3 files changed +19
-11
lines changed
include/clang/Interpreter Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ class REPL_EXTERNAL_VISIBILITY Value final {
325
325
const StrValue &asStr () const { return const_cast <Value *>(this )->asStr (); }
326
326
327
327
public:
328
- // ---- Query helpers ----
328
+ // ---- BuiltinKind Query helpers ----
329
329
bool hasBuiltinThis (BuiltinKind K) const {
330
330
if (isBuiltin ())
331
331
return asBuiltin ().getKind () == K;
@@ -451,16 +451,16 @@ class REPL_EXTERNAL_VISIBILITY Value final {
451
451
void destroy () {
452
452
switch (VKind) {
453
453
case K_Builtin:
454
- reinterpret_cast < Builtins *>( &Data)->~Builtins ();
454
+ (( Builtins *)( char *) &Data)->~Builtins ();
455
455
break ;
456
456
case K_Array:
457
- reinterpret_cast < ArrValue *>( &Data)->~ArrValue ();
457
+ (( ArrValue *)( char *) &Data)->~ArrValue ();
458
458
break ;
459
459
case K_Pointer:
460
- reinterpret_cast < PtrValue *>( &Data)->~PtrValue ();
460
+ (( PtrValue *)( char *) &Data)->~PtrValue ();
461
461
break ;
462
462
case K_Str:
463
- reinterpret_cast < StrValue *>( &Data)->~StrValue ();
463
+ (( StrValue *)( char *) &Data)->~StrValue ();
464
464
break ;
465
465
default :
466
466
break ;
@@ -525,7 +525,7 @@ class ValueResultManager {
525
525
ASTContext &Ctx;
526
526
llvm::orc::MemoryAccess &MemAcc;
527
527
Value LastVal;
528
- llvm::DenseMap<ValueId, clang:: QualType> IdToType;
528
+ llvm::DenseMap<ValueId, QualType> IdToType;
529
529
llvm::DenseMap<ValueId, ValueCleanup> IdToValCleanup;
530
530
};
531
531
Original file line number Diff line number Diff line change @@ -302,9 +302,6 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> Instance,
302
302
return ;
303
303
}
304
304
}
305
-
306
- ValMgr = ValueResultManager::Create (IncrExecutor->GetExecutionEngine (),
307
- getASTContext ());
308
305
}
309
306
310
307
Interpreter::~Interpreter () {
@@ -676,9 +673,11 @@ llvm::Error Interpreter::CreateExecutor(JITConfig Config) {
676
673
Executor =
677
674
std::make_unique<IncrementalExecutor>(*TSCtx, *JITBuilder, Config, Err);
678
675
#endif
679
- if (!Err)
676
+ if (!Err) {
680
677
IncrExecutor = std::move (Executor);
681
-
678
+ ValMgr = ValueResultManager::Create (IncrExecutor->GetExecutionEngine (),
679
+ getASTContext ());
680
+ }
682
681
return Err;
683
682
}
684
683
Original file line number Diff line number Diff line change @@ -239,8 +239,14 @@ void Value::print(llvm::raw_ostream &Out, ASTContext &Ctx) const {
239
239
240
240
void ValueCleanup::operator ()(Value &V) {
241
241
using namespace llvm ;
242
+
243
+ if (!V.isPointer () || V.getAddr () != 0 )
244
+ return ;
245
+
242
246
LLVM_DEBUG (dbgs () << " ValueCleanup: destroying value at Addr=" << V.getAddr ()
243
247
<< " , Type=" << V.getType ().getAsString () << " \n " );
248
+ assert (!DtorWrapperFn.isNull () &&
249
+ " Expected valid destructor wrapper function address, but found null" );
244
250
if (ObjDtor) {
245
251
auto ObjDtorAddrOrErr = ObjDtor (V.getType ());
246
252
if (ObjDtorAddrOrErr && !ObjDtorAddrOrErr->isNull ()) {
@@ -260,6 +266,9 @@ void ValueCleanup::operator()(Value &V) {
260
266
}
261
267
}
262
268
269
+ assert (!DtorFn.isNull () &&
270
+ " Expected valid destructor function address, but found null" );
271
+
263
272
Error E = Error::success ();
264
273
orc::ExecutorAddr Addr (V.getAddr ());
265
274
LLVM_DEBUG (dbgs () << " ValueCleanup: calling raw destructor, Addr="
You can’t perform that action at this time.
0 commit comments