From ebd3404baa4fc287e0f010b21f36a263512c8a64 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 19 Jul 2023 17:04:49 +0200 Subject: [PATCH] Fix void Value across Interpreters They have different ASTContexts, so the VoidTy is different. --- lib/Interpreter/Value.cpp | 2 +- test/MultipleInterpreters/MultipleInterpreters.C | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Interpreter/Value.cpp b/lib/Interpreter/Value.cpp index b7aed930..fb996382 100644 --- a/lib/Interpreter/Value.cpp +++ b/lib/Interpreter/Value.cpp @@ -146,7 +146,7 @@ namespace cling { const clang::ASTContext &C) { using namespace clang; - if (C.hasSameType(QT, C.VoidTy)) + if (QT->isVoidType()) return Value::kVoid; if (const auto *ET = dyn_cast(QT.getTypePtr())) diff --git a/test/MultipleInterpreters/MultipleInterpreters.C b/test/MultipleInterpreters/MultipleInterpreters.C index 4155d8df..fe11eaf5 100644 --- a/test/MultipleInterpreters/MultipleInterpreters.C +++ b/test/MultipleInterpreters/MultipleInterpreters.C @@ -33,5 +33,9 @@ const char* argV[1] = {"cling"}; ChildInterp.declare("void foo(int i){ printf(\"foo(int) = %d\\n\", i); }\n"); ChildInterp.echo("foo()"); //CHECK: (int) 42 ChildInterp.execute("foo(1)"); //CHECK: foo(int) = 1 + + // The following should not crash, even if the child interpreter has a + // different ASTContext.VoidTy. + ChildInterp.echo("(void)1"); } .q