36#include "cling/Interpreter/CompilationOptions.h"
37#include "cling/Interpreter/Interpreter.h"
38#include "cling/Interpreter/LookupHelper.h"
39#include "cling/Interpreter/Transaction.h"
40#include "cling/Interpreter/Value.h"
41#include "cling/Utils/AST.h"
43#include "clang/AST/ASTContext.h"
44#include "clang/AST/Decl.h"
45#include "clang/AST/DeclCXX.h"
46#include "clang/AST/GlobalDecl.h"
47#include "clang/AST/PrettyPrinter.h"
48#include "clang/AST/QualTypeNames.h"
49#include "clang/AST/RecordLayout.h"
50#include "clang/AST/Type.h"
51#include "clang/Frontend/CompilerInstance.h"
52#include "clang/Lex/Preprocessor.h"
53#include "clang/Sema/Sema.h"
54#include "clang/Sema/Lookup.h"
56#include "llvm/ADT/APInt.h"
57#include "llvm/ExecutionEngine/ExecutionEngine.h"
58#include "llvm/ExecutionEngine/GenericValue.h"
59#include "llvm/Support/Casting.h"
60#include "llvm/Support/raw_ostream.h"
61#include "llvm/IR/LLVMContext.h"
62#include "llvm/IR/DerivedTypes.h"
63#include "llvm/IR/Function.h"
64#include "llvm/IR/GlobalValue.h"
65#include "llvm/IR/Module.h"
66#include "llvm/IR/Type.h"
68#include "clang/Sema/SemaInternal.h"
76using llvm::APSInt, llvm::raw_string_ostream;
77using std::string, std::map, std::ostringstream, std::make_pair;
85indent(ostringstream &buf,
int indent_level)
87 for (
int i = 0; i < indent_level; ++i) {
94EvaluateExpr(cling::Interpreter &interp,
const Expr *E, cling::Value &V)
97 ASTContext &C = interp.getCI()->getASTContext();
98 clang::Expr::EvalResult evalRes;
99 if (E->EvaluateAsInt(evalRes, C, Expr::SE_NoSideEffects)) {
102 APSInt res = evalRes.Val.getInt();
104 V = cling::Value(C.IntTy, interp);
108 V.setLongLong(res.getSExtValue());
110 V.setULongLong(res.getZExtValue());
115 PrintingPolicy Policy(C.getPrintingPolicy());
116 Policy.SuppressTagKeyword =
true;
117 Policy.SuppressTagKeywordInAnonNames =
true;
118 Policy.SuppressUnwrittenScope =
false;
119 Policy.SuppressInitializers =
false;
120 Policy.AnonymousTagLocations =
false;
122 raw_string_ostream out(buf);
123 E->printPretty(out,
nullptr, Policy, 0);
127 interp.evaluate(buf, V);
133 return GetDecl()->getMinRequiredArguments();
137 bool withAccessControl)
139 return fInterp->compileFunction(wrapper_name, wrapper,
false ,
144 PrintingPolicy Policy) {
150 cling::utils::Transform::Config Config;
151 QT = cling::utils::Transform::GetPartiallyDesugaredType(C, QT, Config,
true);
152 QT.getAsStringInternal(type_name, Policy);
159 PrintingPolicy Policy(Context.getPrintingPolicy());
160 Policy.SuppressTagKeyword =
true;
161 Policy.SuppressTagKeywordInAnonNames =
true;
162 Policy.SuppressUnwrittenScope =
true;
163 if (
const TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
165 QualType QT = TD->getASTContext().getTypeDeclType(TD);
167 }
else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
169 raw_string_ostream stream(
name);
170 ND->getNameForDiagnostic(stream, Policy,
true);
176 string &type_name,
EReferenceType &refType,
bool &isPointer,
int indent_level,
183 const FunctionDecl *FD =
GetDecl();
184 ASTContext &C = FD->getASTContext();
185 PrintingPolicy Policy(C.getPrintingPolicy());
187 if (QT->isRecordType() && forArgument) {
191 if (QT->isFunctionPointerType()) {
192 string fp_typedef_name;
196 type_name = nm.str();
197 raw_string_ostream OS(fp_typedef_name);
198 QT.print(OS, Policy, type_name);
201 indent(typedefbuf, indent_level);
202 typedefbuf <<
"typedef " << fp_typedef_name <<
";\n";
204 }
else if (QT->isMemberPointerType()) {
205 string mp_typedef_name;
209 type_name = nm.str();
210 raw_string_ostream OS(mp_typedef_name);
211 QT.print(OS, Policy, type_name);
214 indent(typedefbuf, indent_level);
215 typedefbuf <<
"typedef " << mp_typedef_name <<
";\n";
217 }
else if (QT->isPointerType()) {
219 QT = cast<clang::PointerType>(QT)->getPointeeType();
220 }
else if (QT->isReferenceType()) {
223 QT = cast<ReferenceType>(QT)->getPointeeType();
226 if (QT->isArrayType()) {
227 string ar_typedef_name;
231 type_name = ar.str();
232 raw_string_ostream OS(ar_typedef_name);
233 QT.print(OS, Policy, type_name);
236 indent(typedefbuf, indent_level);
237 typedefbuf <<
"typedef " << ar_typedef_name <<
";\n";
245 CXXRecordDecl *RD = QT->getAsCXXRecordDecl();
252 RD = RD->getDefinition();
253 assert(RD &&
"expecting a definition");
255 if (RD->hasSimpleCopyConstructor())
258 for (
auto *Ctor : RD->ctors()) {
259 if (Ctor->isCopyConstructor()) {
260 return Ctor->isDeleted();
264 assert(0 &&
"did not find a copy constructor?");
271 ostringstream &callbuf,
const string &class_name,
278 const FunctionDecl *FD =
GetDecl();
280 callbuf <<
"new " << class_name <<
"(";
283 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
285 for (
unsigned i = 0U; i <
N; ++i) {
286 const ParmVarDecl *PVD = FD->getParamDecl(i);
287 QualType Ty = PVD->getType();
288 QualType QT = Ty.getCanonicalType();
291 bool isPointer =
false;
293 refType, isPointer, indent_level,
true);
300 indent(callbuf, indent_level + 1);
304 callbuf <<
"(" << type_name.c_str() <<
305 (refType ==
kLValueReference ?
"&" :
"&&") <<
")*(" << type_name.c_str() <<
"*)args["
307 }
else if (isPointer) {
308 callbuf <<
"*(" << type_name.c_str() <<
"**)args["
316 callbuf <<
"static_cast<" << type_name <<
"&&>(";
318 callbuf <<
"*(" << type_name.c_str() <<
"*)args[" << i <<
"]";
328 ostringstream &callbuf,
const string &class_name,
int indent_level)
335 const FunctionDecl *FD =
GetDecl();
348 bool ShouldCastFunction = !isa<CXXMethodDecl>(FD) &&
N == FD->getNumParams();
349 if (ShouldCastFunction) {
352 callbuf << return_type <<
" (&)";
355 for (
unsigned i = 0U; i <
N; ++i) {
362 indent(callbuf, indent_level + 1);
365 const ParmVarDecl *PVD = FD->getParamDecl(i);
366 QualType Ty = PVD->getType();
367 QualType QT = Ty.getCanonicalType();
368 std::string arg_type;
369 ASTContext &C = FD->getASTContext();
373 if (FD->isVariadic())
381 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
384 callbuf <<
"((const " << class_name <<
"*)obj)->";
386 callbuf <<
"((" << class_name <<
"*)obj)->";
387 }
else if (
const NamedDecl *ND =
391 callbuf << class_name <<
"::";
397 llvm::raw_string_ostream stream(
name);
398 FD->getNameForDiagnostic(stream, FD->getASTContext().getPrintingPolicy(),
false);
402 if (ShouldCastFunction) callbuf <<
")";
407 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
409 for (
unsigned i = 0U; i <
N; ++i) {
410 const ParmVarDecl *PVD = FD->getParamDecl(i);
411 QualType Ty = PVD->getType();
412 QualType QT = Ty.getCanonicalType();
415 bool isPointer =
false;
416 collect_type_info(QT, typedefbuf, callbuf, type_name, refType, isPointer, indent_level,
true);
424 indent(callbuf, indent_level + 1);
429 callbuf <<
"(" << type_name.c_str() <<
430 (refType ==
kLValueReference ?
"&" :
"&&") <<
")*(" << type_name.c_str() <<
"*)args["
432 }
else if (isPointer) {
433 callbuf <<
"*(" << type_name.c_str() <<
"**)args["
441 callbuf <<
"static_cast<" << type_name <<
"&&>(";
443 callbuf <<
"*(" << type_name.c_str() <<
"*)args[" << i <<
"]";
453 ostringstream &buf,
int indent_level)
464 indent(buf, indent_level);
465 buf <<
"if (ret) {\n";
468 ostringstream typedefbuf;
469 ostringstream callbuf;
473 indent(callbuf, indent_level);
474 callbuf <<
"(*(" << class_name <<
"**)ret) = ";
483 indent(callbuf, indent_level);
484 callbuf <<
"return;\n";
488 buf << typedefbuf.str() << callbuf.str();
491 for (
int i = 0; i < indent_level; ++i) {
495 for (
int i = 0; i < indent_level; ++i) {
501 ostringstream typedefbuf;
502 ostringstream callbuf;
503 for (
int i = 0; i < indent_level; ++i) {
508 for (
int i = 0; i < indent_level; ++i) {
511 callbuf <<
"return;\n";
512 buf << typedefbuf.str() << callbuf.str();
515 for (
int i = 0; i < indent_level; ++i) {
529 return fMethod->GetDecl()->getDeclContext();
534 const FunctionDecl *FD =
GetDecl();
535 assert(FD &&
"generate_wrapper called without a function decl!");
540 ASTContext &Context = FD->getASTContext();
547 bool needInstantiation =
false;
548 const FunctionDecl *Definition =
nullptr;
549 if (!FD->isDefined(Definition)) {
550 FunctionDecl::TemplatedKind TK = FD->getTemplatedKind();
552 case FunctionDecl::TK_NonTemplate: {
562 case FunctionDecl::TK_FunctionTemplate: {
565 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template!");
568 case FunctionDecl::TK_MemberSpecialization: {
575 if (!FD->isTemplateInstantiation()) {
588 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
590 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a member function "
591 "instantiation with no pattern!");
594 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
595 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
598 (PTK == FunctionDecl::TK_NonTemplate) ||
601 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
602 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
607 }
else if (!
Pattern->hasBody()) {
608 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a member function "
609 "instantiation with no body!");
612 if (FD->isImplicitlyInstantiable()) {
613 needInstantiation =
true;
616 case FunctionDecl::TK_FunctionTemplateSpecialization: {
621 if (!FD->isTemplateInstantiation()) {
634 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
636 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template"
637 "instantiation with no pattern!");
640 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
641 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
644 (PTK == FunctionDecl::TK_NonTemplate) ||
647 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
648 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
655 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template"
656 "instantiation with no body!");
659 if (FD->isImplicitlyInstantiable()) {
660 needInstantiation =
true;
663 case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
671 if (!FD->isTemplateInstantiation()) {
684 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
686 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a dependent function template"
687 "instantiation with no pattern!");
690 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
691 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
694 (PTK == FunctionDecl::TK_NonTemplate) ||
697 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
698 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
705 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a dependent function template"
706 "instantiation with no body!");
709 if (FD->isImplicitlyInstantiable()) {
710 needInstantiation =
true;
716 ::Error(
"TClingCallFunc::make_wrapper",
"Unhandled template kind!");
738 if (needInstantiation) {
739 clang::FunctionDecl *FDmod =
const_cast<clang::FunctionDecl *
>(FD);
740 clang::Sema &S =
fInterp->getSema();
742 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
743 S.InstantiateFunctionDefinition(SourceLocation(), FDmod,
746 if (!FD->isDefined(Definition)) {
747 ::Error(
"TClingCallFunc::make_wrapper",
"Failed to force template instantiation!");
752 FunctionDecl::TemplatedKind TK = Definition->getTemplatedKind();
754 case FunctionDecl::TK_NonTemplate: {
756 if (Definition->isDeleted()) {
757 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted function!");
759 }
else if (Definition->isLateTemplateParsed()) {
760 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
771 case FunctionDecl::TK_FunctionTemplate: {
774 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template!");
777 case FunctionDecl::TK_MemberSpecialization: {
781 if (Definition->isDeleted()) {
782 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted member function "
783 "of a specialization!");
785 }
else if (Definition->isLateTemplateParsed()) {
786 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
787 "member function of a specialization!");
797 case FunctionDecl::TK_FunctionTemplateSpecialization: {
802 if (Definition->isDeleted()) {
803 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted function "
804 "template specialization!");
806 }
else if (Definition->isLateTemplateParsed()) {
807 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
808 "function template specialization!");
818 case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
826 if (Definition->isDeleted()) {
827 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted dependent function "
828 "template specialization!");
830 }
else if (Definition->isLateTemplateParsed()) {
831 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
832 "dependent function template specialization!");
845 ::Error(
"TClingCallFunc::make_wrapper",
"Unhandled template kind!");
851 unsigned num_params = FD->getNumParams();
863 wrapper_name = buf.str();
869 int indent_level = 0;
871 buf <<
"#pragma clang diagnostic push\n"
872 "#pragma clang diagnostic ignored \"-Wformat-security\"\n"
873 "__attribute__((used)) "
874 "__attribute__((annotate(\"__cling__ptrcheck(off)\")))\n"
875 "extern \"C\" void ";
877 buf <<
"(void* obj, int nargs, void** args, void* ret)\n"
880 if (min_args == num_params) {
886 for (
unsigned N = min_args;
N <= num_params; ++
N) {
887 indent(buf, indent_level);
888 buf <<
"if (nargs == " <<
N <<
") {\n";
892 indent(buf, indent_level);
898 "#pragma clang diagnostic pop";
904 ostringstream &buf,
int indent_level)
915 const FunctionDecl *FD =
GetDecl();
916 if (
const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
918 auto SpecMemKind =
fInterp->getSema().getSpecialMember(CD);
919 if ((
N == 0 && SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor) ||
921 (SpecMemKind == clang::CXXSpecialMemberKind::CopyConstructor || SpecMemKind == clang::CXXSpecialMemberKind::MoveConstructor))) {
932 QualType QT = FD->getReturnType().getCanonicalType();
933 if (QT->isVoidType()) {
934 ostringstream typedefbuf;
935 ostringstream callbuf;
936 indent(callbuf, indent_level);
937 make_narg_call(
"void",
N, typedefbuf, callbuf, class_name, indent_level);
939 indent(callbuf, indent_level);
940 callbuf <<
"return;\n";
941 buf << typedefbuf.str() << callbuf.str();
943 indent(buf, indent_level);
947 bool isPointer =
false;
949 buf <<
"if (ret) {\n";
952 ostringstream typedefbuf;
953 ostringstream callbuf;
957 indent(callbuf, indent_level);
958 callbuf <<
"new (ret) ";
960 refType, isPointer, indent_level,
false);
964 callbuf <<
"(" << type_name.c_str();
968 }
else if (isPointer) {
977 make_narg_call(type_name,
N, typedefbuf, callbuf, class_name, indent_level);
982 indent(callbuf, indent_level);
983 callbuf <<
"return;\n";
987 buf << typedefbuf.str() << callbuf.str();
990 indent(buf, indent_level);
992 indent(buf, indent_level);
996 ostringstream typedefbuf;
997 ostringstream callbuf;
998 indent(callbuf, indent_level);
999 callbuf <<
"(void)(";
1000 make_narg_call(type_name,
N, typedefbuf, callbuf, class_name, indent_level);
1002 indent(callbuf, indent_level);
1003 callbuf <<
"return;\n";
1004 buf << typedefbuf.str() << callbuf.str();
1007 indent(buf, indent_level);
1014 static map<const Decl *, void *> gWrapperStore;
1020 auto I = gWrapperStore.find(D);
1021 if (I != gWrapperStore.end())
1024 string wrapper_name;
1035 gWrapperStore.insert(make_pair(D, F));
1037 ::Error(
"TClingCallFunc::make_wrapper",
1038 "Failed to compile\n ==== SOURCE BEGIN ====\n%s\n ==== SOURCE END ====",
1046 SmallVector<void *, 8> vp_ary;
1047 const unsigned num_args =
fArgVals.size();
1050 const FunctionDecl *FD =
GetDecl();
1054 ::Error(
"TClingCallFunc::exec",
1055 "Not enough arguments provided for %s (%d instead of the minimum %d)",
1059 }
else if (!isa<CXXMethodDecl>(FD) && num_args > FD->getNumParams()) {
1060 ::Error(
"TClingCallFunc::exec",
1061 "Too many arguments provided for %s (%d instead of the minimum %d)",
1066 if (
auto CXXMD = dyn_cast<CXXMethodDecl>(FD))
1067 if (!address && CXXMD && !CXXMD->isStatic() && !isa<CXXConstructorDecl>(FD)) {
1068 ::Error(
"TClingCallFunc::exec",
1069 "The method %s is called without an object.",
1074 vp_ary.reserve(num_args);
1075 for (
unsigned i = 0; i < num_args; ++i) {
1083 bool implicitThisPassed = i == 0 && isa<CXXMethodDecl>(FD) && num_args - FD->getNumParams() == 1;
1084 if (implicitThisPassed)
1085 QT = cast<CXXMethodDecl>(FD)->getThisType();
1087 QT = FD->getParamDecl(i)->getType();
1088 QT = QT.getCanonicalType();
1089 if (QT->isReferenceType() || QT->isRecordType()) {
1092 vp_ary.push_back(
fArgVals[i].getPtr());
1097 ASTContext &C = FD->getASTContext();
1098 if (QT->isBuiltinType() && !C.hasSameType(QT,
fArgVals[i].getType())) {
1099 switch(QT->getAs<BuiltinType>()->getKind()) {
1106#define X(type, name) \
1107 case BuiltinType::name: fArgVals[i] = cling::Value::Create(*fInterp, fArgVals[i].castAs<type>()); break;
1108 CLING_VALUE_BUILTIN_TYPES
1112 vp_ary.push_back(
fArgVals[i].getPtrAddress());
1116 (*fWrapper)(address, (
int)num_args, (
void **)vp_ary.data(), ret);
1121 const FunctionDecl *FD =
GetDecl();
1124 if (llvm::isa<CXXConstructorDecl>(FD)) {
1126 ASTContext &Context = FD->getASTContext();
1128 QualType ClassTy = TD->getASTContext().getTypeDeclType(TD);
1129 QT = Context.getLValueReferenceType(ClassTy);
1130 ret = cling::Value(QT, *
fInterp);
1132 QT = FD->getReturnType().getCanonicalType();
1133 ret = cling::Value(QT, *
fInterp);
1135 if (QT->isRecordType() || QT->isMemberDataPointerType())
1136 return exec(address, ret.getPtr());
1138 exec(address, ret.getPtrAddress());
1145 SmallVector<Expr *, 4> exprs;
1146 fInterp->getLookupHelper().findArgList(ArgList, exprs,
1147 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
1148 : cling::LookupHelper::NoDiagnostics);
1149 for (SmallVectorImpl<Expr *>::const_iterator I = exprs.begin(),
1150 E = exprs.end(); I != E; ++I) {
1153 if (!val.isValid()) {
1155 ::Error(
"TClingCallFunc::EvaluateArgList",
1156 "Bad expression in parameter %d of '%s'!",
1157 (
int)(I - exprs.begin()),
1169 ::Error(
"TClingCallFunc::Exec(address, interpVal)",
1170 "Called with no wrapper, not implemented!");
1173 if (!interpVal || !interpVal->
GetValAddr()) {
1174 exec(address,
nullptr);
1177 cling::Value *val =
reinterpret_cast<cling::Value *
>(interpVal->
GetValAddr());
1181template <
typename T>
1186 ::Error(
"TClingCallFunc::ExecT",
1187 "Called with no wrapper, not implemented!");
1196 if (ret.needsManagedAllocation())
1199 return ret.castAs<T>();
1204 return ExecT<Longptr_t>(address);
1209 return ExecT<long long>(address);
1214 return ExecT<double>(address);
1218 int nargs ,
void *ret)
1222 ::Error(
"TClingCallFunc::ExecWithArgsAndReturn(address, args, ret)",
1223 "Called with no wrapper, not implemented!");
1226 (*fWrapper)(address, nargs,
const_cast<void **
>(args), ret);
1233 ::Error(
"TClingCallFunc::ExecWithReturn(address, ret)",
1234 "Called with no wrapper, not implemented!");
1242 const std::string &type_name,
1243 void *address ,
unsigned long nary )
1246 ::Error(
"TClingCallFunc::ExecDefaultConstructor",
"Invalid class info!");
1255 clang::Decl *D =
const_cast<clang::Decl *
>(info->
GetDecl());
1257 if (Cpp::IsClass(D) || Cpp::IsConstructor(D)) {
1259 return Cpp::Construct(D, address, nary).data;
1262 ::Error(
"TClingCallFunc::ExecDefaultConstructor",
"ClassInfo missing a valid Scope/Constructor");
1267 unsigned long nary ,
bool withFree )
1270 ::Error(
"TClingCallFunc::ExecDestructor",
"Invalid class info!");
1276 if (Cpp::Destruct(address,
const_cast<clang::Decl *
>(info->
GetDecl()), withFree, nary))
1279 ::Error(
"TClingCallFunc::ExecDestructor",
"Called with no wrapper, not implemented!");
1332 ::Error(
"TClingCallFunc::IFacePtr(kind)",
1333 "Attempt to get interface while invalid.");
1352 for (
int i = 0; i < nparam; ++i) {
1366 SetFunc(info, method, arglist,
false, poffset);
1378 ::Error(
"TClingCallFunc::SetFunc",
"Class info is invalid!");
1381 if (!strcmp(arglist,
")")) {
1414 const char *proto,
bool objectIsConst,
Longptr_t *poffset,
1423 ::Error(
"TClingCallFunc::SetFuncProto",
"Class info is invalid!");
1435 const llvm::SmallVectorImpl<clang::QualType> &proto,
Longptr_t *poffset,
1442 const llvm::SmallVectorImpl<clang::QualType> &proto,
1452 ::Error(
"TClingCallFunc::SetFuncProto",
"Class info is invalid!");
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
static void EvaluateExpr(cling::Interpreter &interp, const Expr *E, cling::Value &V)
static bool IsCopyConstructorDeleted(QualType QT)
static void GetTypeAsString(QualType QT, string &type_name, ASTContext &C, PrintingPolicy Policy)
static unsigned long long gWrapperSerial
static void GetDeclName(const clang::Decl *D, ASTContext &Context, std::string &name)
static const string kIndentString(" ")
static void indent(ostringstream &buf, int indent_level)
void(* tcling_callfunc_Wrapper_t)(void *, int, void **, void *)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char mode
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
R__EXTERN TInterpreter * gCling
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
void * ExecDefaultConstructor(const TClingClassInfo *info, ROOT::TMetaUtils::EIOCtorCategory kind, const std::string &type_name, void *address=nullptr, unsigned long nary=0UL)
void ExecWithReturn(void *address, void *ret=nullptr)
void exec_with_valref_return(void *address, cling::Value &ret)
std::unique_ptr< TClingMethodInfo > fMethod
Current method, we own.
void collect_type_info(clang::QualType &QT, std::ostringstream &typedefbuf, std::ostringstream &callbuf, std::string &type_name, EReferenceType &refType, bool &isPointer, int indent_level, bool forArgument)
void SetArgs(const char *args)
size_t fMinRequiredArguments
Number of required arguments.
size_t CalculateMinRequiredArguments()
double ExecDouble(void *address)
void SetArgArray(Longptr_t *argArr, int narg)
tcling_callfunc_Wrapper_t make_wrapper()
void ExecDestructor(const TClingClassInfo *info, void *address=nullptr, unsigned long nary=0UL, bool withFree=true)
Longptr_t ExecInt(void *address)
const clang::DeclContext * GetDeclContext() const
void * compile_wrapper(const std::string &wrapper_name, const std::string &wrapper, bool withAccessControl=true)
void SetFuncProto(const TClingClassInfo *info, const char *method, const char *proto, Longptr_t *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
TInterpreter::CallFuncIFacePtr_t IFacePtr()
void exec(void *address, void *ret)
std::atomic< tcling_callfunc_Wrapper_t > fWrapper
Pointer to compiled wrapper, we do not own.
void make_narg_ctor(const unsigned N, std::ostringstream &typedefbuf, std::ostringstream &callbuf, const std::string &class_name, int indent_level)
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, Longptr_t *poffset)
const clang::FunctionDecl * GetDecl()
void EvaluateArgList(const std::string &ArgList)
const clang::Decl * GetFunctionOrShadowDecl() const
void ExecWithArgsAndReturn(void *address, const void *args[]=0, int nargs=0, void *ret=0)
void Exec(void *address, TInterpreterValue *interpVal=0)
TClingMethodInfo * FactoryMethod() const
int get_wrapper_code(std::string &wrapper_name, std::string &wrapper)
size_t GetMinRequiredArguments()
long long ExecInt64(void *address)
cling::Interpreter * fInterp
Cling interpreter, we do not own.
void make_narg_call(const std::string &return_type, const unsigned N, std::ostringstream &typedefbuf, std::ostringstream &callbuf, const std::string &class_name, int indent_level)
const clang::FunctionDecl * fDecl
Decl for the method.
void make_narg_call_with_return(const unsigned N, const std::string &class_name, std::ostringstream &buf, int indent_level)
llvm::SmallVector< cling::Value, 8 > fArgVals
Stored function arguments, we own.
void make_narg_ctor_with_return(const unsigned N, const std::string &class_name, std::ostringstream &buf, int indent_level)
Emulation of the CINT ClassInfo class.
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, Longptr_t *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) const
TClingMethodInfo GetMethod(const char *fname) const
virtual bool IsValid() const
virtual const clang::Decl * GetDecl() const
Emulation of the CINT MethodInfo class.
This class defines an interface to the cling C++ interpreter.
virtual const void * GetValAddr() const =0