I end up with GlobalDecl.h:33: void clang::GlobalDecl::Init(const clang::Decl*): Assertion `!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!"' failed.
when invoking “getAddressOfGlobal” in the loop below for a destructor (similarly for constructors):
cling::Transaction* tp = 0;
auto const dcr = cling->declare("#include <string>;\n ...", &tp);
if (cling::Interpreter::kSuccess != dcr) return;
assert(tp);
for (auto dg = tp->decls_begin(); dg != tp->decls_end(); ++dg) {
if (!dg->m_DGR.isSingleDecl()) continue;
auto fd = llvm::dyn_cast<clang::FunctionDecl>(dg->m_DGR.getSingleDecl());
if (!fd) continue;
auto fn = fd->getNameAsString();
bool from_jit = false;
void* fm = cling->getAddressOfGlobal(fd, &from_jit);
...
}
How can i tell when a FunctionDecl is a ctor/dtor? (In my case these are ~basic_string and basic_string, not JIT-ed symbols, and i am not interested in them, so skipping getAddressOfGlobal() would be fine.)