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 {
325325 const StrValue &asStr () const { return const_cast <Value *>(this )->asStr (); }
326326
327327public:
328- // ---- Query helpers ----
328+ // ---- BuiltinKind Query helpers ----
329329 bool hasBuiltinThis (BuiltinKind K) const {
330330 if (isBuiltin ())
331331 return asBuiltin ().getKind () == K;
@@ -451,16 +451,16 @@ class REPL_EXTERNAL_VISIBILITY Value final {
451451 void destroy () {
452452 switch (VKind) {
453453 case K_Builtin:
454- reinterpret_cast < Builtins *>( &Data)->~Builtins ();
454+ (( Builtins *)( char *) &Data)->~Builtins ();
455455 break ;
456456 case K_Array:
457- reinterpret_cast < ArrValue *>( &Data)->~ArrValue ();
457+ (( ArrValue *)( char *) &Data)->~ArrValue ();
458458 break ;
459459 case K_Pointer:
460- reinterpret_cast < PtrValue *>( &Data)->~PtrValue ();
460+ (( PtrValue *)( char *) &Data)->~PtrValue ();
461461 break ;
462462 case K_Str:
463- reinterpret_cast < StrValue *>( &Data)->~StrValue ();
463+ (( StrValue *)( char *) &Data)->~StrValue ();
464464 break ;
465465 default :
466466 break ;
@@ -525,7 +525,7 @@ class ValueResultManager {
525525 ASTContext &Ctx;
526526 llvm::orc::MemoryAccess &MemAcc;
527527 Value LastVal;
528- llvm::DenseMap<ValueId, clang:: QualType> IdToType;
528+ llvm::DenseMap<ValueId, QualType> IdToType;
529529 llvm::DenseMap<ValueId, ValueCleanup> IdToValCleanup;
530530};
531531
Original file line number Diff line number Diff line change @@ -302,9 +302,6 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> Instance,
302302 return ;
303303 }
304304 }
305-
306- ValMgr = ValueResultManager::Create (IncrExecutor->GetExecutionEngine (),
307- getASTContext ());
308305}
309306
310307Interpreter::~Interpreter () {
@@ -676,9 +673,11 @@ llvm::Error Interpreter::CreateExecutor(JITConfig Config) {
676673 Executor =
677674 std::make_unique<IncrementalExecutor>(*TSCtx, *JITBuilder, Config, Err);
678675#endif
679- if (!Err)
676+ if (!Err) {
680677 IncrExecutor = std::move (Executor);
681-
678+ ValMgr = ValueResultManager::Create (IncrExecutor->GetExecutionEngine (),
679+ getASTContext ());
680+ }
682681 return Err;
683682}
684683
Original file line number Diff line number Diff line change @@ -239,8 +239,14 @@ void Value::print(llvm::raw_ostream &Out, ASTContext &Ctx) const {
239239
240240void ValueCleanup::operator ()(Value &V) {
241241 using namespace llvm ;
242+
243+ if (!V.isPointer () || V.getAddr () != 0 )
244+ return ;
245+
242246 LLVM_DEBUG (dbgs () << " ValueCleanup: destroying value at Addr=" << V.getAddr ()
243247 << " , Type=" << V.getType ().getAsString () << " \n " );
248+ assert (!DtorWrapperFn.isNull () &&
249+ " Expected valid destructor wrapper function address, but found null" );
244250 if (ObjDtor) {
245251 auto ObjDtorAddrOrErr = ObjDtor (V.getType ());
246252 if (ObjDtorAddrOrErr && !ObjDtorAddrOrErr->isNull ()) {
@@ -260,6 +266,9 @@ void ValueCleanup::operator()(Value &V) {
260266 }
261267 }
262268
269+ assert (!DtorFn.isNull () &&
270+ " Expected valid destructor function address, but found null" );
271+
263272 Error E = Error::success ();
264273 orc::ExecutorAddr Addr (V.getAddr ());
265274 LLVM_DEBUG (dbgs () << " ValueCleanup: calling raw destructor, Addr="
You can’t perform that action at this time.
0 commit comments