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.SuppressUnwrittenScope =
false;
118 Policy.SuppressInitializers =
false;
119 Policy.AnonymousTagLocations =
false;
121 raw_string_ostream out(buf);
122 E->printPretty(out,
nullptr, Policy, 0);
126 interp.evaluate(buf, V);
132 return GetDecl()->getMinRequiredArguments();
136 bool withAccessControl)
138 return fInterp->compileFunction(wrapper_name, wrapper,
false ,
143 PrintingPolicy Policy) {
149 cling::utils::Transform::Config Config;
150 QT = cling::utils::Transform::GetPartiallyDesugaredType(C, QT, Config,
true);
151 QT.getAsStringInternal(type_name, Policy);
158 PrintingPolicy Policy(Context.getPrintingPolicy());
159 Policy.SuppressTagKeyword =
true;
160 Policy.SuppressUnwrittenScope =
true;
161 if (
const TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
163 QualType QT(TD->getTypeForDecl(), 0);
165 }
else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
167 raw_string_ostream stream(
name);
168 ND->getNameForDiagnostic(stream, Policy,
true);
174 string &type_name,
EReferenceType &refType,
bool &isPointer,
int indent_level,
181 const FunctionDecl *FD =
GetDecl();
182 ASTContext &C = FD->getASTContext();
183 PrintingPolicy Policy(C.getPrintingPolicy());
185 if (QT->isRecordType() && forArgument) {
189 if (QT->isFunctionPointerType()) {
190 string fp_typedef_name;
194 type_name = nm.str();
195 raw_string_ostream OS(fp_typedef_name);
196 QT.print(OS, Policy, type_name);
199 indent(typedefbuf, indent_level);
200 typedefbuf <<
"typedef " << fp_typedef_name <<
";\n";
202 }
else if (QT->isMemberPointerType()) {
203 string mp_typedef_name;
207 type_name = nm.str();
208 raw_string_ostream OS(mp_typedef_name);
209 QT.print(OS, Policy, type_name);
212 indent(typedefbuf, indent_level);
213 typedefbuf <<
"typedef " << mp_typedef_name <<
";\n";
215 }
else if (QT->isPointerType()) {
217 QT = cast<clang::PointerType>(QT)->getPointeeType();
218 }
else if (QT->isReferenceType()) {
221 QT = cast<ReferenceType>(QT)->getPointeeType();
224 if (QT->isArrayType()) {
225 string ar_typedef_name;
229 type_name = ar.str();
230 raw_string_ostream OS(ar_typedef_name);
231 QT.print(OS, Policy, type_name);
234 indent(typedefbuf, indent_level);
235 typedefbuf <<
"typedef " << ar_typedef_name <<
";\n";
243 CXXRecordDecl *RD = QT->getAsCXXRecordDecl();
250 RD = RD->getDefinition();
251 assert(RD &&
"expecting a definition");
253 if (RD->hasSimpleCopyConstructor())
256 for (
auto *Ctor : RD->ctors()) {
257 if (Ctor->isCopyConstructor()) {
258 return Ctor->isDeleted();
262 assert(0 &&
"did not find a copy constructor?");
269 ostringstream &callbuf,
const string &class_name,
276 const FunctionDecl *FD =
GetDecl();
278 callbuf <<
"new " << class_name <<
"(";
281 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
283 for (
unsigned i = 0U; i <
N; ++i) {
284 const ParmVarDecl *PVD = FD->getParamDecl(i);
285 QualType Ty = PVD->getType();
286 QualType QT = Ty.getCanonicalType();
289 bool isPointer =
false;
291 refType, isPointer, indent_level,
true);
298 indent(callbuf, indent_level + 1);
302 callbuf <<
"(" << type_name.c_str() <<
303 (refType ==
kLValueReference ?
"&" :
"&&") <<
")*(" << type_name.c_str() <<
"*)args["
305 }
else if (isPointer) {
306 callbuf <<
"*(" << type_name.c_str() <<
"**)args["
314 callbuf <<
"static_cast<" << type_name <<
"&&>(";
316 callbuf <<
"*(" << type_name.c_str() <<
"*)args[" << i <<
"]";
326 ostringstream &callbuf,
const string &class_name,
int indent_level)
333 const FunctionDecl *FD =
GetDecl();
346 bool ShouldCastFunction = !isa<CXXMethodDecl>(FD) &&
N == FD->getNumParams();
347 if (ShouldCastFunction) {
350 callbuf << return_type <<
" (&)";
353 for (
unsigned i = 0U; i <
N; ++i) {
360 indent(callbuf, indent_level + 1);
363 const ParmVarDecl *PVD = FD->getParamDecl(i);
364 QualType Ty = PVD->getType();
365 QualType QT = Ty.getCanonicalType();
366 std::string arg_type;
367 ASTContext &C = FD->getASTContext();
371 if (FD->isVariadic())
379 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
382 callbuf <<
"((const " << class_name <<
"*)obj)->";
384 callbuf <<
"((" << class_name <<
"*)obj)->";
385 }
else if (
const NamedDecl *ND =
389 callbuf << class_name <<
"::";
395 llvm::raw_string_ostream stream(
name);
396 FD->getNameForDiagnostic(stream, FD->getASTContext().getPrintingPolicy(),
false);
400 if (ShouldCastFunction) callbuf <<
")";
405 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
407 for (
unsigned i = 0U; i <
N; ++i) {
408 const ParmVarDecl *PVD = FD->getParamDecl(i);
409 QualType Ty = PVD->getType();
410 QualType QT = Ty.getCanonicalType();
413 bool isPointer =
false;
414 collect_type_info(QT, typedefbuf, callbuf, type_name, refType, isPointer, indent_level,
true);
422 indent(callbuf, indent_level + 1);
427 callbuf <<
"(" << type_name.c_str() <<
428 (refType ==
kLValueReference ?
"&" :
"&&") <<
")*(" << type_name.c_str() <<
"*)args["
430 }
else if (isPointer) {
431 callbuf <<
"*(" << type_name.c_str() <<
"**)args["
439 callbuf <<
"static_cast<" << type_name <<
"&&>(";
441 callbuf <<
"*(" << type_name.c_str() <<
"*)args[" << i <<
"]";
451 ostringstream &buf,
int indent_level)
462 indent(buf, indent_level);
463 buf <<
"if (ret) {\n";
466 ostringstream typedefbuf;
467 ostringstream callbuf;
471 indent(callbuf, indent_level);
472 callbuf <<
"(*(" << class_name <<
"**)ret) = ";
481 indent(callbuf, indent_level);
482 callbuf <<
"return;\n";
486 buf << typedefbuf.str() << callbuf.str();
489 for (
int i = 0; i < indent_level; ++i) {
493 for (
int i = 0; i < indent_level; ++i) {
499 ostringstream typedefbuf;
500 ostringstream callbuf;
501 for (
int i = 0; i < indent_level; ++i) {
506 for (
int i = 0; i < indent_level; ++i) {
509 callbuf <<
"return;\n";
510 buf << typedefbuf.str() << callbuf.str();
513 for (
int i = 0; i < indent_level; ++i) {
527 return fMethod->GetDecl()->getDeclContext();
532 const FunctionDecl *FD =
GetDecl();
533 assert(FD &&
"generate_wrapper called without a function decl!");
538 ASTContext &Context = FD->getASTContext();
545 bool needInstantiation =
false;
546 const FunctionDecl *Definition =
nullptr;
547 if (!FD->isDefined(Definition)) {
548 FunctionDecl::TemplatedKind TK = FD->getTemplatedKind();
550 case FunctionDecl::TK_NonTemplate: {
560 case FunctionDecl::TK_FunctionTemplate: {
563 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template!");
566 case FunctionDecl::TK_MemberSpecialization: {
573 if (!FD->isTemplateInstantiation()) {
586 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
588 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a member function "
589 "instantiation with no pattern!");
592 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
593 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
596 (PTK == FunctionDecl::TK_NonTemplate) ||
599 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
600 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
605 }
else if (!
Pattern->hasBody()) {
606 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a member function "
607 "instantiation with no body!");
610 if (FD->isImplicitlyInstantiable()) {
611 needInstantiation =
true;
614 case FunctionDecl::TK_FunctionTemplateSpecialization: {
619 if (!FD->isTemplateInstantiation()) {
632 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
634 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template"
635 "instantiation with no pattern!");
638 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
639 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
642 (PTK == FunctionDecl::TK_NonTemplate) ||
645 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
646 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
653 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template"
654 "instantiation with no body!");
657 if (FD->isImplicitlyInstantiable()) {
658 needInstantiation =
true;
661 case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
669 if (!FD->isTemplateInstantiation()) {
682 const FunctionDecl *
Pattern = FD->getTemplateInstantiationPattern();
684 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a dependent function template"
685 "instantiation with no pattern!");
688 FunctionDecl::TemplatedKind PTK =
Pattern->getTemplatedKind();
689 TemplateSpecializationKind PTSK =
Pattern->getTemplateSpecializationKind();
692 (PTK == FunctionDecl::TK_NonTemplate) ||
695 ((PTK != FunctionDecl::TK_FunctionTemplate) &&
696 ((PTSK == TSK_Undeclared) || (PTSK == TSK_ExplicitSpecialization)))) {
703 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a dependent function template"
704 "instantiation with no body!");
707 if (FD->isImplicitlyInstantiable()) {
708 needInstantiation =
true;
714 ::Error(
"TClingCallFunc::make_wrapper",
"Unhandled template kind!");
736 if (needInstantiation) {
737 clang::FunctionDecl *FDmod =
const_cast<clang::FunctionDecl *
>(FD);
738 clang::Sema &S =
fInterp->getSema();
740 cling::Interpreter::PushTransactionRAII RAII(
fInterp);
741 S.InstantiateFunctionDefinition(SourceLocation(), FDmod,
744 if (!FD->isDefined(Definition)) {
745 ::Error(
"TClingCallFunc::make_wrapper",
"Failed to force template instantiation!");
750 FunctionDecl::TemplatedKind TK = Definition->getTemplatedKind();
752 case FunctionDecl::TK_NonTemplate: {
754 if (Definition->isDeleted()) {
755 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted function!");
757 }
else if (Definition->isLateTemplateParsed()) {
758 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
769 case FunctionDecl::TK_FunctionTemplate: {
772 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a function template!");
775 case FunctionDecl::TK_MemberSpecialization: {
779 if (Definition->isDeleted()) {
780 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted member function "
781 "of a specialization!");
783 }
else if (Definition->isLateTemplateParsed()) {
784 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
785 "member function of a specialization!");
795 case FunctionDecl::TK_FunctionTemplateSpecialization: {
800 if (Definition->isDeleted()) {
801 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted function "
802 "template specialization!");
804 }
else if (Definition->isLateTemplateParsed()) {
805 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
806 "function template specialization!");
816 case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
824 if (Definition->isDeleted()) {
825 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a deleted dependent function "
826 "template specialization!");
828 }
else if (Definition->isLateTemplateParsed()) {
829 ::Error(
"TClingCallFunc::make_wrapper",
"Cannot make wrapper for a late template parsed "
830 "dependent function template specialization!");
843 ::Error(
"TClingCallFunc::make_wrapper",
"Unhandled template kind!");
849 unsigned num_params = FD->getNumParams();
861 wrapper_name = buf.str();
867 int indent_level = 0;
869 buf <<
"#pragma clang diagnostic push\n"
870 "#pragma clang diagnostic ignored \"-Wformat-security\"\n"
871 "__attribute__((used)) "
872 "__attribute__((annotate(\"__cling__ptrcheck(off)\")))\n"
873 "extern \"C\" void ";
875 buf <<
"(void* obj, int nargs, void** args, void* ret)\n"
878 if (min_args == num_params) {
884 for (
unsigned N = min_args;
N <= num_params; ++
N) {
885 indent(buf, indent_level);
886 buf <<
"if (nargs == " <<
N <<
") {\n";
890 indent(buf, indent_level);
896 "#pragma clang diagnostic pop";
902 ostringstream &buf,
int indent_level)
913 const FunctionDecl *FD =
GetDecl();
914 if (
const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
916 auto SpecMemKind =
fInterp->getSema().getSpecialMember(CD);
917 if ((
N == 0 && SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor) ||
919 (SpecMemKind == clang::CXXSpecialMemberKind::CopyConstructor || SpecMemKind == clang::CXXSpecialMemberKind::MoveConstructor))) {
930 QualType QT = FD->getReturnType().getCanonicalType();
931 if (QT->isVoidType()) {
932 ostringstream typedefbuf;
933 ostringstream callbuf;
934 indent(callbuf, indent_level);
935 make_narg_call(
"void",
N, typedefbuf, callbuf, class_name, indent_level);
937 indent(callbuf, indent_level);
938 callbuf <<
"return;\n";
939 buf << typedefbuf.str() << callbuf.str();
941 indent(buf, indent_level);
945 bool isPointer =
false;
947 buf <<
"if (ret) {\n";
950 ostringstream typedefbuf;
951 ostringstream callbuf;
955 indent(callbuf, indent_level);
956 callbuf <<
"new (ret) ";
958 refType, isPointer, indent_level,
false);
962 callbuf <<
"(" << type_name.c_str();
966 }
else if (isPointer) {
975 make_narg_call(type_name,
N, typedefbuf, callbuf, class_name, indent_level);
980 indent(callbuf, indent_level);
981 callbuf <<
"return;\n";
985 buf << typedefbuf.str() << callbuf.str();
988 indent(buf, indent_level);
990 indent(buf, indent_level);
994 ostringstream typedefbuf;
995 ostringstream callbuf;
996 indent(callbuf, indent_level);
997 callbuf <<
"(void)(";
998 make_narg_call(type_name,
N, typedefbuf, callbuf, class_name, indent_level);
1000 indent(callbuf, indent_level);
1001 callbuf <<
"return;\n";
1002 buf << typedefbuf.str() << callbuf.str();
1005 indent(buf, indent_level);
1012 static map<const Decl *, void *> gWrapperStore;
1018 auto I = gWrapperStore.find(D);
1019 if (
I != gWrapperStore.end())
1022 string wrapper_name;
1033 gWrapperStore.insert(make_pair(D, F));
1035 ::Error(
"TClingCallFunc::make_wrapper",
1036 "Failed to compile\n ==== SOURCE BEGIN ====\n%s\n ==== SOURCE END ====",
1044 SmallVector<void *, 8> vp_ary;
1045 const unsigned num_args =
fArgVals.size();
1048 const FunctionDecl *FD =
GetDecl();
1052 ::Error(
"TClingCallFunc::exec",
1053 "Not enough arguments provided for %s (%d instead of the minimum %d)",
1057 }
else if (!isa<CXXMethodDecl>(FD) && num_args > FD->getNumParams()) {
1058 ::Error(
"TClingCallFunc::exec",
1059 "Too many arguments provided for %s (%d instead of the minimum %d)",
1064 if (
auto CXXMD = dyn_cast<CXXMethodDecl>(FD))
1065 if (!address && CXXMD && !CXXMD->isStatic() && !isa<CXXConstructorDecl>(FD)) {
1066 ::Error(
"TClingCallFunc::exec",
1067 "The method %s is called without an object.",
1072 vp_ary.reserve(num_args);
1073 for (
unsigned i = 0; i < num_args; ++i) {
1081 bool implicitThisPassed = i == 0 && isa<CXXMethodDecl>(FD) && num_args - FD->getNumParams() == 1;
1082 if (implicitThisPassed)
1083 QT = cast<CXXMethodDecl>(FD)->getThisType();
1085 QT = FD->getParamDecl(i)->getType();
1086 QT = QT.getCanonicalType();
1087 if (QT->isReferenceType() || QT->isRecordType()) {
1090 vp_ary.push_back(
fArgVals[i].getPtr());
1095 ASTContext &C = FD->getASTContext();
1096 if (QT->isBuiltinType() && !C.hasSameType(QT,
fArgVals[i].getType())) {
1097 switch(QT->getAs<BuiltinType>()->getKind()) {
1104#define X(type, name) \
1105 case BuiltinType::name: fArgVals[i] = cling::Value::Create(*fInterp, fArgVals[i].castAs<type>()); break;
1106 CLING_VALUE_BUILTIN_TYPES
1110 vp_ary.push_back(
fArgVals[i].getPtrAddress());
1114 (*fWrapper)(address, (
int)num_args, (
void **)vp_ary.data(),
ret);
1119 const FunctionDecl *FD =
GetDecl();
1122 if (llvm::isa<CXXConstructorDecl>(FD)) {
1124 ASTContext &Context = FD->getASTContext();
1126 QualType ClassTy(TD->getTypeForDecl(), 0);
1127 QT = Context.getLValueReferenceType(ClassTy);
1130 QT = FD->getReturnType().getCanonicalType();
1133 if (QT->isRecordType() || QT->isMemberDataPointerType())
1134 return exec(address,
ret.getPtr());
1136 exec(address,
ret.getPtrAddress());
1143 SmallVector<Expr *, 4> exprs;
1144 fInterp->getLookupHelper().findArgList(ArgList, exprs,
1145 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
1146 : cling::LookupHelper::NoDiagnostics);
1147 for (SmallVectorImpl<Expr *>::const_iterator
I = exprs.begin(),
1148 E = exprs.end();
I != E; ++
I) {
1151 if (!val.isValid()) {
1153 ::Error(
"TClingCallFunc::EvaluateArgList",
1154 "Bad expression in parameter %d of '%s'!",
1155 (
int)(
I - exprs.begin()),
1167 ::Error(
"TClingCallFunc::Exec(address, interpVal)",
1168 "Called with no wrapper, not implemented!");
1171 if (!interpVal || !interpVal->
GetValAddr()) {
1172 exec(address,
nullptr);
1175 cling::Value *val =
reinterpret_cast<cling::Value *
>(interpVal->
GetValAddr());
1179template <
typename T>
1184 ::Error(
"TClingCallFunc::ExecT",
1185 "Called with no wrapper, not implemented!");
1194 if (
ret.needsManagedAllocation())
1197 return ret.castAs<T>();
1216 int nargs ,
void *
ret)
1220 ::Error(
"TClingCallFunc::ExecWithArgsAndReturn(address, args, ret)",
1221 "Called with no wrapper, not implemented!");
1224 (*fWrapper)(address, nargs,
const_cast<void **
>(args),
ret);
1231 ::Error(
"TClingCallFunc::ExecWithReturn(address, ret)",
1232 "Called with no wrapper, not implemented!");
1240 const std::string &type_name,
1241 void *address ,
unsigned long nary )
1244 ::Error(
"TClingCallFunc::ExecDefaultConstructor",
"Invalid class info!");
1253 clang::Decl *D =
const_cast<clang::Decl *
>(info->
GetDecl());
1255 if (Cpp::IsClass(D) || Cpp::IsConstructor(D)) {
1257 return Cpp::Construct(D, address, nary);
1260 ::Error(
"TClingCallFunc::ExecDefaultConstructor",
"ClassInfo missing a valid Scope/Constructor");
1265 unsigned long nary ,
bool withFree )
1268 ::Error(
"TClingCallFunc::ExecDestructor",
"Invalid class info!");
1274 if (Cpp::Destruct(address, info->
GetDecl(), nary, withFree))
1277 ::Error(
"TClingCallFunc::ExecDestructor",
"Called with no wrapper, not implemented!");
1330 ::Error(
"TClingCallFunc::IFacePtr(kind)",
1331 "Attempt to get interface while invalid.");
1350 for (
int i = 0; i < nparam; ++i) {
1364 SetFunc(info, method, arglist,
false, poffset);
1376 ::Error(
"TClingCallFunc::SetFunc",
"Class info is invalid!");
1379 if (!strcmp(arglist,
")")) {
1421 ::Error(
"TClingCallFunc::SetFuncProto",
"Class info is invalid!");
1433 const llvm::SmallVectorImpl<clang::QualType> &
proto,
Longptr_t *poffset,
1440 const llvm::SmallVectorImpl<clang::QualType> &
proto,
1450 ::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 *)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__LOCKGUARD_CLING(mutex)
externTInterpreter * gCling
externTVirtualMutex * gInterpreterMutex
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