Logo ROOT  
Reference Guide
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 "clang/AST/ASTContext.h"
20#include "clang/AST/Decl.h"
21
22using namespace clang;
23
24// pin the vtable here.
26
28{
29 if (!IsValid())
30 return 0;
31
32 if (!fNameCache.empty())
33 return fNameCache.c_str();
34
35 const Decl* D = GetDecl();
36 if (!isa<NamedDecl>(D))
37 return 0;
38
39 const NamedDecl* ND = cast<NamedDecl>(D);
40 clang::PrintingPolicy policy(ND->getASTContext().getPrintingPolicy());
41 llvm::raw_string_ostream stream(fNameCache);
42 ND->getNameForDiagnostic(stream, policy, /*Qualified=*/false);
43 stream.flush();
44 return fNameCache.c_str();
45}
The file contains a base class of TCling*Info classes.
virtual ~TClingDeclInfo()
virtual const char * Name()
virtual bool IsValid() const
std::string fNameCache
virtual const clang::Decl * GetDecl() const