Fix void Value across Interpreters

They have different ASTContexts, so the VoidTy is different.
This commit is contained in:
Jonas Hahnfeld 2023-07-19 17:04:49 +02:00 committed by jenkins
parent 6466a6dfe9
commit ebd3404baa
2 changed files with 5 additions and 1 deletions

View File

@ -146,7 +146,7 @@ namespace cling {
const clang::ASTContext &C) { const clang::ASTContext &C) {
using namespace clang; using namespace clang;
if (C.hasSameType(QT, C.VoidTy)) if (QT->isVoidType())
return Value::kVoid; return Value::kVoid;
if (const auto *ET = dyn_cast<EnumType>(QT.getTypePtr())) if (const auto *ET = dyn_cast<EnumType>(QT.getTypePtr()))

View File

@ -33,5 +33,9 @@ const char* argV[1] = {"cling"};
ChildInterp.declare("void foo(int i){ printf(\"foo(int) = %d\\n\", i); }\n"); ChildInterp.declare("void foo(int i){ printf(\"foo(int) = %d\\n\", i); }\n");
ChildInterp.echo("foo()"); //CHECK: (int) 42 ChildInterp.echo("foo()"); //CHECK: (int) 42
ChildInterp.execute("foo(1)"); //CHECK: foo(int) = 1 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 .q