Logo ROOT  
Reference Guide
TClingTypedefInfo.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_TClingTypedefInfo
13#define ROOT_TClingTypedefInfo
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TClingTypedefInfo //
18// //
19// Emulation of the CINT TypedefInfo class. //
20// //
21// The CINT C++ interpreter provides an interface to metadata about //
22// a typedef through the TypedefInfo class. This class provides the //
23// same functionality, using an interface as close as possible to //
24// TypedefInfo but the typedef metadata comes from the Clang C++ //
25// compiler, not CINT. //
26// //
27//////////////////////////////////////////////////////////////////////////
28
29#include "TClingDeclInfo.h"
30
31#include "cling/Interpreter/Interpreter.h"
32#include "clang/AST/ASTContext.h"
33#include "clang/AST/Decl.h"
34#include "clang/Frontend/CompilerInstance.h"
35
36#include <vector>
37#include <string>
38
39namespace ROOT {
40 namespace TMetaUtils {
41 class TNormalizedCtxt;
42 }
43}
44
45class TClingTypedefInfo final : public TClingDeclInfo {
46
47private:
48
49 cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
50 bool fFirstTime; // We need to skip the first increment to support the cint Next() semantics.
51 bool fDescend; // Flag for signaling the need to descend on this advancement.
52 clang::DeclContext::decl_iterator fIter; // Current decl in scope.
53 std::vector<clang::DeclContext::decl_iterator> fIterStack; // Recursion stack for traversing nested scopes.
54 std::string fTitle; // The meta info for the typedef.
55
56public:
57
58 explicit TClingTypedefInfo(cling::Interpreter *interp)
59 : TClingDeclInfo(nullptr), fInterp(interp), fFirstTime(true), fDescend(false), fTitle("")
60 {
61 const clang::TranslationUnitDecl *TU = fInterp->getCI()->getASTContext().getTranslationUnitDecl();
62 const clang::DeclContext *DC = llvm::cast<clang::DeclContext>(TU);
63 cling::Interpreter::PushTransactionRAII RAII(fInterp);
64 fIter = DC->decls_begin();
65 }
66
67 explicit TClingTypedefInfo(cling::Interpreter *, const char *);
68
69 explicit TClingTypedefInfo(cling::Interpreter *, const clang::TypedefNameDecl *);
70
71 void Init(const char *name);
72 int InternalNext();
73 int Next();
74 long Property() const;
75 int Size() const;
76 const char *TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
77 const char *Name() const override;
78 const char *Title();
79
80};
81
82#endif // ROOT_TClingTypedefInfo
The file contains a base class of TCling*Info classes.
char name[80]
Definition: TGX11.cxx:109
Emulation of the CINT TypedefInfo class.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
long Property() const
Return a bit mask of metadata about the current typedef.
clang::DeclContext::decl_iterator fIter
TClingTypedefInfo(cling::Interpreter *interp)
const char * Name() const override
Get the name of the current typedef.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int InternalNext()
Increment the iterator, return true if new position is valid.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
std::vector< clang::DeclContext::decl_iterator > fIterStack
cling::Interpreter * fInterp
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21