35#include "cling/Interpreter/Interpreter.h"
36#include "cling/Interpreter/LookupHelper.h"
37#include "cling/Utils/AST.h"
39#include "clang/AST/ASTContext.h"
40#include "clang/AST/CXXInheritance.h"
41#include "clang/AST/Decl.h"
42#include "clang/AST/DeclBase.h"
43#include "clang/AST/DeclCXX.h"
44#include "clang/AST/DeclTemplate.h"
45#include "clang/AST/ExprCXX.h"
46#include "clang/AST/GlobalDecl.h"
47#include "clang/AST/Mangle.h"
48#include "clang/AST/PrettyPrinter.h"
49#include "clang/AST/Type.h"
50#include "clang/Basic/IdentifierTable.h"
51#include "clang/Sema/Lookup.h"
52#include "clang/Sema/Sema.h"
53#include "clang/Sema/Template.h"
54#include "clang/Sema/TemplateDeduction.h"
56#include "llvm/Support/Casting.h"
57#include "llvm/Support/raw_ostream.h"
65 llvm::SmallVectorImpl<clang::CXXMethodDecl *> &&
specFuncs)
67 auto *
CXXRD = llvm::dyn_cast<CXXRecordDecl>(
DC);
72 cling::Interpreter::PushTransactionRAII
RAII(
interp);
78 if (std::find(
CXXRD->decls_begin(),
CXXRD->decls_end(), D) ==
CXXRD->decls_end()) {
89 if (
const auto *
FD = llvm::dyn_cast<clang::FunctionDecl>(D)) {
92 if (
const auto *
RD = llvm::dyn_cast<clang::RecordDecl>(
FD->getDeclContext())) {
93 if (
const auto *
CXXMD = llvm::dyn_cast<clang::CXXMethodDecl>(
FD)) {
94 if (
RD->isAnonymousStructOrUnion() &&
108 if (
auto *
FD = llvm::dyn_cast<clang::FunctionDecl>(
USD->getTargetDecl())) {
109 if (
const auto *
CXXMD = llvm::dyn_cast<clang::CXXMethodDecl>(
FD)) {
111 if ((
SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor &&
CXXMD->getNumParams() == 0) ||
112 ((
SpecMemKind == clang::CXXSpecialMemberKind::CopyConstructor ||
SpecMemKind == clang::CXXSpecialMemberKind::MoveConstructor) &&
113 CXXMD->getNumParams() == 1)) {
134 using namespace clang;
138 const cling::LookupHelper &
LH =
interp->getLookupHelper();
173 if (!
TTP->hasDefaultArgument())
177 if (!
NTTP->hasDefaultArgument())
181 if (!
TTP->hasDefaultArgument())
186 assert(0 &&
"unexpected template parameter kind");
191 cling::Interpreter::PushTransactionRAII
RAII(
interp);
200 auto *
FTD =
const_cast<clang::FunctionTemplateDecl *
>(llvm::dyn_cast<clang::FunctionTemplateDecl>(
TD));
201 Sema::InstantiatingTemplate
Inst(
208 for (
const clang::ParmVarDecl *param :
templatedDecl->parameters()) {
209 QualType
paramType = param->getOriginalType();
242 if (!
ci || !
ci->IsValid()) {
245 clang::Decl *D =
const_cast<clang::Decl *
>(
ci->GetDecl());
246 auto *
DC = llvm::dyn_cast<clang::DeclContext>(D);
248 llvm::SmallVector<clang::CXXMethodDecl*, 8>
SpecFuncs;
250 if (
auto *
CXXRD = llvm::dyn_cast<CXXRecordDecl>(
DC)) {
255 cling::Interpreter::PushTransactionRAII
RAII(
interp);
264 if (
auto *
CXXCD = llvm::dyn_cast<clang::CXXConstructorDecl>(
ctor))
277 const clang::Decl *D)
281 Error(
"TClingMethodInfo",
"nullptr FunctionDecl passed!");
292 return (
const clang::Decl*)(
FD->getCanonicalDecl());
368 return cf.InterfaceMethod();
396 unsigned min_args = fd->getMinRequiredArguments();
453 clang::AccessSpecifier Access = clang::AS_public;
454 if (!
declAccess->getDeclContext()->isNamespace())
460 Access = clang::AS_public;
461 clang::CXXRecordDecl *
typeCXXRD = llvm::cast<RecordType>(
Type()->GetQualType())->getAsCXXRecordDecl();
463 if (
typeCXXRD->isDerivedFrom(llvm::dyn_cast<CXXRecordDecl>(fd->getDeclContext()),
basePaths)) {
468 if (
el.Access > Access)
472 Error(
"Property()",
"UsingDecl of ctor not shadowing a base ctor!");
476 if (fd->getAccess() > Access)
477 Access = fd->getAccess();
480 case clang::AS_public:
483 case clang::AS_protected:
486 case clang::AS_private:
490 if (
declAccess->getDeclContext()->isNamespace())
495 assert(
false &&
"Unexpected value for the access property value in Clang");
504 if (fd->isConstexpr())
506 if (fd->getStorageClass() == clang::SC_Static) {
509 clang::QualType
qt = fd->getReturnType().getCanonicalType();
513 if (
const clang::CXXMethodDecl *
md =
514 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
515 if (
md->getMethodQualifiers().hasConst()) {
518 if (
md->isVirtual()) {
521 if (
md->isPureVirtual()) {
524 if (
const clang::CXXConstructorDecl *cd =
525 llvm::dyn_cast<clang::CXXConstructorDecl>(
md)) {
526 if (cd->isExplicit()) {
530 else if (
const clang::CXXConversionDecl *cd =
531 llvm::dyn_cast<clang::CXXConversionDecl>(
md)) {
532 if (cd->isExplicit()) {
550 if (fd->isOverloadedOperator())
552 if (llvm::isa<clang::CXXConversionDecl>(fd))
554 if (llvm::isa<clang::CXXConstructorDecl>(fd))
556 if (llvm::isa<clang::CXXDestructorDecl>(fd))
560 if (fd->getTemplatedKind() != clang::FunctionDecl::TK_NonTemplate)
569 ti.Init(clang::QualType());
578 const clang::TypeDecl*
ctorClass = llvm::dyn_cast_or_null<clang::TypeDecl>
581 Error(
"TClingMethodInfo::Type",
"Cannot find DeclContext for constructor!");
583 clang::QualType
qt(
ctorClass->getTypeForDecl(), 0);
604 cling::Interpreter::PushTransactionRAII
RAII(
fInterp);
635 clang::QualType
qualType(
td->getTypeForDecl(),0);
639 }
else if (
const clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(
FD->getDeclContext())) {
641 clang::PrintingPolicy
policy(
FD->getASTContext().getPrintingPolicy());
642 llvm::raw_string_ostream stream(
name);
643 nd->getNameForDiagnostic(stream,
policy,
true);
654 if (
const clang::CXXMethodDecl *
md =
655 llvm::dyn_cast<clang::CXXMethodDecl>(
FD)) {
656 if (
md->getMethodQualifiers().hasConst()) {
713 cling::Interpreter::PushTransactionRAII
RAII(
fInterp);
717 fTitle = A->getAnnotation().str();
721 if (!
FD->isFromASTFile()) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
R__EXTERN TVirtualMutex * gInterpreterMutex
R__EXTERN TInterpreter * gCling
#define R__LOCKGUARD(mutex)
Iterate over FunctionDecl and UsingShadowDecls of FunctionDecl, within a scope, recursing through "tr...
bool IsValid() const final
const clang::Decl * InstantiateTemplateWithDefaults(const clang::RedeclarableTemplateDecl *TD) const final
bool ShouldSkip(const clang::Decl *FD) const final
Emulation of the CINT CallFunc class.
Emulation of the CINT ClassInfo class.
const clang::Decl * fDecl
virtual const char * Name() const
virtual bool IsValid() const
long Property(long property, clang::QualType &qt) const
bool Next()
Advance to next non-skipped; return false if no next decl exists.
cling::Interpreter * fInterp
cling::Interpreter * GetInterpreter() const
Emulation of the CINT MethodInfo class.
const char * DefaultValue() const
const TClingTypeInfo * Type() const
std::string GetMangledName() const
const char * TypeName() const
const clang::FunctionDecl * GetAsFunctionDecl() const
const char * Name() const override
const clang::UsingShadowDecl * GetAsUsingShadowDecl() const
const clang::FunctionDecl * GetTargetFunctionDecl() const
Get the FunctionDecl, or if this represents a UsingShadowDecl, the underlying target FunctionDecl.
const clang::Decl * GetDecl() const override
TClingCXXRecMethIter fIter
const char * GetPrototype()
void Init(const clang::FunctionDecl *)
long ExtraProperty() const
const clang::Decl * GetDeclSlow() const
void * InterfaceMethod() const
TClingMethodInfo(cling::Interpreter *interp)
void CreateSignature(TString &signature) const
TDictionary::DeclId_t GetDeclId() const
cling::Interpreter * fInterp
TClingTypeInfo * Type() const
Emulation of the CINT TypeInfo class.
const char * Name() const override
This class defines an interface to the cling C++ interpreter.