Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClingDeclInfo.cxx
Go to the documentation of this file.
1/// \file TClingDeclInfo.cxx
2///
3/// \brief The file contains a base class of TCling*Info classes.
4///
5/// \author Vassil Vassilev <vvasilev@cern.ch>
6///
7/// \date March, 2019
8///
9/*************************************************************************
10 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
11 * All rights reserved. *
12 * *
13 * For the licensing terms see $ROOTSYS/LICENSE. *
14 * For the list of contributors see $ROOTSYS/README/CREDITS. *
15 *************************************************************************/
16
17#include "TClingDeclInfo.h"
18
19#include "TDictionary.h"
20
21#include "clang/AST/ASTContext.h"
22#include "clang/AST/Decl.h"
23
24using namespace clang;
25
26// pin the vtable here.
28
29const char* TClingDeclInfo::Name() const
30{
31 if (!IsValid())
32 return 0;
33
34 if (!fNameCache.empty())
35 return fNameCache.c_str();
36
37 const Decl* D = GetDecl();
38 if (!isa<NamedDecl>(D))
39 return 0;
40
41 const NamedDecl* ND = cast<NamedDecl>(D);
42 clang::PrintingPolicy policy(ND->getASTContext().getPrintingPolicy());
43 llvm::raw_string_ostream stream(fNameCache);
44 ND->getNameForDiagnostic(stream, policy, /*Qualified=*/false);
45 stream.flush();
46 return fNameCache.c_str();
47}
48
49long TClingDeclInfo::Property(long property, clang::QualType &qt) const
50{
51 if (!IsValid()) {
52 return 0L;
53 }
54 if (qt.isConstQualified()) {
55 property |= kIsConstant;
56 }
57 while (1) {
58 if (qt->isArrayType()) {
59 property |= kIsArray;
60 qt = llvm::cast<clang::ArrayType>(qt)->getElementType();
61 continue;
62 }
63 else if (qt->isReferenceType()) {
64 property |= kIsReference;
65 qt = llvm::cast<clang::ReferenceType>(qt)->getPointeeType();
66 continue;
67 }
68 else if (qt->isPointerType()) {
69 property |= kIsPointer;
70 if (qt.isConstQualified()) {
71 property |= kIsConstPointer;
72 }
73 qt = llvm::cast<clang::PointerType>(qt)->getPointeeType();
74 continue;
75 }
76 else if (qt->isMemberPointerType()) {
77 qt = llvm::cast<clang::MemberPointerType>(qt)->getPointeeType();
78 continue;
79 }
80 break;
81 }
82 if (qt->isBuiltinType()) {
83 property |= kIsFundamental;
84 }
85 if (qt.isConstQualified()) {
86 property |= kIsConstant;
87 }
88 return property;
89}
The file contains a base class of TCling*Info classes.
@ kIsPointer
Definition TDictionary.h:78
@ kIsConstant
Definition TDictionary.h:88
@ kIsReference
Definition TDictionary.h:82
@ kIsConstPointer
Definition TDictionary.h:90
@ kIsFundamental
Definition TDictionary.h:70
@ kIsArray
Definition TDictionary.h:79
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
virtual ~TClingDeclInfo()
virtual const char * Name() const
virtual bool IsValid() const
long Property(long property, clang::QualType &qt) const
std::string fNameCache
virtual const clang::Decl * GetDecl() const