Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClingMethodInfo.h
Go to the documentation of this file.
1// @(#)root/core/meta:$Id$
2// Author: Paul Russo 30/07/2012
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TClingMethodInfo
13#define ROOT_TClingMethodInfo
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TClingMethodInfo //
18// //
19// Emulation of the CINT MethodInfo class. //
20// //
21// The CINT C++ interpreter provides an interface to metadata about //
22// a function through the MethodInfo class. This class provides the //
23// same functionality, using an interface as close as possible to //
24// MethodInfo but the typedef metadata comes from the Clang C++ //
25// compiler, not CINT. //
26// //
27//////////////////////////////////////////////////////////////////////////
28
29#include "TClingDeclInfo.h"
30#include "TClingMemberIter.h"
31#include "TDictionary.h"
32#include "TString.h"
33
34#include "llvm/ADT/SmallVector.h"
35
36#include <string>
37
38namespace clang {
39 class Decl;
40 class FunctionDecl;
41}
42
43namespace cling {
44 class Interpreter;
45}
46
47namespace ROOT {
48 namespace TMetaUtils {
49 class TNormalizedCtxt;
50 }
51}
52
53class TClingClassInfo;
54class TClingTypeInfo;
55
56/// Iterate over FunctionDecl and UsingShadowDecls of FunctionDecl, within a scope,
57/// recursing through "transparent" scopes (see DCIter::HandleInlineDeclContext()).
59
61 using Vec_t = llvm::SmallVector<clang::CXXMethodDecl *,4>;
62 Vec_t fDefDataSpecFuns; // Special functions materialized from DefinitionData.
63 size_t fIDefDataSpecFuns = 0; // Current element in fDefDataSpecFuns.
64
65public:
66 SpecFuncIter() = default;
67 SpecFuncIter(cling::Interpreter *interp, clang::DeclContext *DC,
68 llvm::SmallVectorImpl<clang::CXXMethodDecl*> &&specFuncs);
69
70 bool IsValid() const { return fIDefDataSpecFuns < fDefDataSpecFuns.size(); }
71
72 bool Next() {
74 return IsValid();
75 }
76
77 clang::FunctionDecl *operator->() const {
78 return operator*();
79 }
80
81 clang::FunctionDecl *operator*() const {
82 return IsValid() ? fDefDataSpecFuns[fIDefDataSpecFuns] : nullptr;
83 }
84};
85
87
88protected:
89 const clang::Decl *
90 InstantiateTemplateWithDefaults(const clang::RedeclarableTemplateDecl *TD) const final;
91
92 bool ShouldSkip(const clang::Decl* FD) const final;
93 bool ShouldSkip(const clang::UsingShadowDecl* USD) const final;
94
95 clang::Decl *AdvanceUnfiltered() final {
97 return *fSpecFuncIter;
99 }
100
101public:
103 TClingCXXRecMethIter(cling::Interpreter *interp, clang::DeclContext *DC,
104 llvm::SmallVectorImpl<clang::CXXMethodDecl*> &&specFuncs):
105 TClingMemberIter(interp, DC), fSpecFuncIter(interp, DC, std::move(specFuncs)) {}
106
107 const clang::Decl *Get() const final {
108 if (!IsValid())
109 return nullptr;
110
112 return *fSpecFuncIter;
113
114 return TClingMemberIter::Get();
115 }
116
117 bool IsValid() const final {
119 }
120
121};
122
123
124class TClingMethodInfo final : public TClingDeclInfo {
125private:
126 cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
127 bool fFirstTime; // Flag for first time incrementing iterator, cint semantics are weird.
128 TClingCXXRecMethIter fIter; // Our iterator.
129 std::string fTitle; // The meta info for the method.
130
131 const clang::Decl* GetDeclSlow() const;
132
133public:
134 explicit TClingMethodInfo(cling::Interpreter *interp)
135 : TClingDeclInfo(nullptr), fInterp(interp), fFirstTime(true), fTitle("") {}
136
137 // Takes concrete decl and disables the iterator.
138 TClingMethodInfo(cling::Interpreter *, const clang::Decl *);
139 TClingMethodInfo(cling::Interpreter *, TClingClassInfo *);
140
141 const clang::FunctionDecl *GetAsFunctionDecl() const;
142 const clang::UsingShadowDecl *GetAsUsingShadowDecl() const;
143
144 /// Get the FunctionDecl, or if this represents a UsingShadowDecl, the underlying target FunctionDecl.
145 const clang::FunctionDecl *GetTargetFunctionDecl() const;
146
148 cling::Interpreter *GetInterpreter() const { return fInterp; }
149 void CreateSignature(TString &signature) const;
150 void Init(const clang::FunctionDecl *);
151 void *InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
152
153 const clang::Decl *GetDecl() const override {
154 if (const clang::Decl* SingleDecl = TClingDeclInfo::GetDecl())
155 return SingleDecl;
156 return GetDeclSlow();
157 }
158 int NArg() const;
159 int NDefaultArg() const;
160 int Next();
161 long Property() const;
162 long ExtraProperty() const;
163 TClingTypeInfo *Type() const;
164 std::string GetMangledName() const;
165 const char *GetPrototype();
166 const char *Name() const override;
167 const char *TypeName() const;
168 const char *Title();
169};
170
171#endif // ROOT_TClingMethodInfo
The file contains a base class of TCling*Info classes.
clang::FunctionDecl * operator->() const
clang::FunctionDecl * operator*() const
llvm::SmallVector< clang::CXXMethodDecl *, 4 > Vec_t
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
const clang::Decl * Get() const final
clang::Decl * AdvanceUnfiltered() final
TClingCXXRecMethIter(cling::Interpreter *interp, clang::DeclContext *DC, llvm::SmallVectorImpl< clang::CXXMethodDecl * > &&specFuncs)
bool ShouldSkip(const clang::Decl *FD) const final
TClingCXXRecMethIter()=default
Emulation of the CINT ClassInfo class.
virtual const clang::Decl * GetDecl() const
Iterate over all DeclT-s (or UsingShadowDecl-s pointing to DeclT-s) of a decl context,...
virtual const clang::Decl * Get() const
virtual clang::Decl * AdvanceUnfiltered()
virtual bool IsValid() const
Emulation of the CINT MethodInfo class.
std::string GetMangledName() const
const char * TypeName() const
cling::Interpreter * GetInterpreter() const
const clang::FunctionDecl * GetAsFunctionDecl() const
const char * Name() const override
const clang::UsingShadowDecl * GetAsUsingShadowDecl() const
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) 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
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 void * DeclId_t
Basic string class.
Definition TString.h:136
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...