30#include "clang/Basic/SourceLocation.h"
31#include "clang/Basic/SourceManager.h"
32#include "clang/AST/DeclCXX.h"
33#include "clang/AST/ASTContext.h"
34#include "clang/AST/DeclTemplate.h"
43 clang::ASTContext& ctx = D->getASTContext();
44 clang::SourceManager& SM = ctx.getSourceManager();
45 clang::SourceLocation SL = D->getLocation();
50 SL = SM.getExpansionLoc(SL);
52 if (SL.isValid() && SL.isFileID()) {
53 clang::PresumedLoc PLoc = SM.getPresumedLoc(SL);
54 return PLoc.getFilename();
63 if (srcname==
nullptr) {
66 if((strcmp(srcname,filename)==0)) {
71 char i1name[_MAX_PATH];
72 char fullfile[_MAX_PATH];
73 _fullpath( i1name, srcname, _MAX_PATH );
74 _fullpath( fullfile, filename, _MAX_PATH );
75 if((stricmp(i1name, fullfile)==0))
return 1;
77 struct stat statBufItem;
79 if ( ( 0 == stat( filename, & statBufItem ) )
80 && ( 0 == stat( srcname, & statBuf ) )
81 && ( statBufItem.st_dev == statBuf.st_dev )
82 && ( statBufItem.st_ino == statBuf.st_ino )
83 && ( statBufItem.st_size == statBuf.st_size )
84 && ( statBufItem.st_mtime == statBuf.st_mtime )
93 : fIndex(index),fLineNumber(lineno),fSelFileName(selFileName),fIsSelected(sel),fMatchFound(false),fCXXRecordDecl(nullptr),fRequestedType(nullptr),fInterp(&interp)
95 fAttributes.insert(AttributesMap_t::value_type(attributeName, attributeValue));
110 AttributesMap_t::const_iterator iter =
fAttributes.find(attributeName);
118 AttributesMap_t::const_iterator iter =
fAttributes.find(attributeName);
121 returnValue = retVal ? iter->second :
"";
128 std::string localAttributeValue(attributeValue);
130 int pos = attributeName.find(
"pattern");
131 int pos_file = attributeName.find(
"file_pattern");
134 if (attributeName ==
"name" || pos> -1){
135 while(std::isspace(*localAttributeValue.begin())) localAttributeValue.erase(localAttributeValue.begin());
136 while(std::isspace(*localAttributeValue.rbegin()))localAttributeValue.erase(localAttributeValue.length()-1);
138 fAttributes.insert(AttributesMap_t::value_type(attributeName, localAttributeValue));
163 for (
int i = 0; i < level; ++i) {
169 for (
auto&& attr : orderedAttributes) {
170 out<<tabs<<attr.first<<
" = "<<attr.second<<std::endl;
174 out<<tabs<<
"No attributes"<<std::endl;
186 const std::string&
name,
187 const std::string& prototype,
188 bool isLinkdef)
const
206 const std::string& name_value =
fName;
207 const std::string& pattern_value =
fPattern;
210 const clang::CXXRecordDecl *D = llvm::dyn_cast<clang::CXXRecordDecl>(decl);
211 bool isTypedefNametoRecordDecl =
false;
215 const clang::TypedefNameDecl* typedefNameDecl = llvm::dyn_cast<clang::TypedefNameDecl> (decl);
216 isTypedefNametoRecordDecl = typedefNameDecl &&
222 if ( target && D && target == D ) {
228 if (name_value ==
name) {
232 (
fCXXRecordDecl != (
void*)-1 && isTypedefNametoRecordDecl && !decl->hasOwningModule())){
235 const clang::CXXRecordDecl *target
245 if ( target && D && target == D ) {
253 const std::string& file_name_value =
fFileName;
266 if (!strncmp(
name.c_str(),
"R__Init", 7) ||
267 strstr(
name.c_str(),
"::R__Init")) {
270 if (!
name.compare(0, 24,
"ROOT::R__dummyintdefault")) {
273 if (!
name.compare(0, 27,
"ROOT::R__dummyVersionNumber")) {
276 if (!
name.compare(0, 22,
"ROOT::R__dummyStreamer")) {
279 if (
name.find(
"(anonymous namespace)") != std::string::npos) {
302 if (!patternMatched && !isLinkdef) {
303 std::string auxName(
name);
304 std::string &nameNoSpaces = auxName;
305 nameNoSpaces.erase(std::remove_if(nameNoSpaces.begin(), nameNoSpaces.end(), isspace),
307 if (
name.size() != nameNoSpaces.size()) {
318 if (!patternMatched &&
323 if (
name.size() != auxName.size()) {
330 if (patternMatched) {
350 if (!prototype.empty()) {
374 std::string temp = pattern;
379 if (pattern.size()==1 && pattern ==
"*"){
384 while (!temp.empty()){
385 pos = temp.find(
"*");
393 out.push_back(split);
399 temp = temp.substr(1);
401 else if (pos == (
int)(temp.length()-1)) {
402 if (pos > 0 && temp.at(pos-1) ==
'\\') {
403 split += temp.substr(0, temp.length()-2);
404 split += temp.at(pos);
405 out.push_back(split);
409 temp = temp.substr(0, (temp.length()-1));
412 if (pos > 0 && temp.at(pos-1) ==
'\\') {
413 split += temp.substr(0, pos-1);
414 split += temp.at(pos);
418 temp = temp.substr(pos);
423 split += temp.substr(0, pos);
426 split = temp.substr(0, pos);
429 temp = temp.substr(pos);
430 out.push_back(split);
446 bool begin = pattern.front() ==
'*';
447 if (pattern.size() == 1 && begin) {
452 std::list<std::string>::const_iterator it = patterns_list.begin();
453 bool end = pattern.back() ==
'*';
456 const std::string& last = patterns_list.back();
457 size_t pos_end =
test.rfind(last);
459 if (pos_end == std::string::npos) {
465 int len = last.length();
466 if ((pos_end+len) <
test.length()) {
472 size_t pos1 =
test.find(*it);
475 if (pos1 == std::string::npos || (!begin && pos1 != 0)) {
483 int len = (*it).length();
484 int pos_colon =
test.find(
"::", pos1+len);
486 if (pos_colon > -1) {
492 if (patterns_list.size() > 1) {
493 if (((*it).length())+pos1 > pos_end) {
502 for (; it != patterns_list.end(); ++it) {
504 size_t pos2 =
test.find(*it);
553 std::cout<<
"Error - A pattern selection without sub patterns." <<std::endl;
static bool R__match_filename(const char *srcname, const char *filename)
static const char * R__GetDeclSourceFileName(const clang::Decl *D)
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
bool fHasFilePatternAttribute
bool GetAttributeValue(const std::string &attributeName, std::string &returnValue) const
bool CheckPattern(const std::string &test, const std::string &pattern, const std::list< std::string > &patterns_list, bool isLinkdef) const
bool fHasPatternAttribute
void SetSelected(ESelect sel)
void ProcessPattern(const std::string &pattern, std::list< std::string > &out) const
const clang::CXXRecordDecl * fCXXRecordDecl
bool fHasProtoNameAttribute
std::list< std::string > fSubPatterns
virtual void DebugPrint() const
EMatchType Match(const clang::NamedDecl *decl, const std::string &name, const std::string &prototype, bool isLinkdef) const
void SetCXXRecordDecl(const clang::CXXRecordDecl *decl, const clang::Type *typeptr)
bool GetMatchFound() const
const clang::Type * GetRequestedType() const
std::string fProtoPattern
const AttributesMap_t & GetAttributes() const
ESelect GetSelected() const
bool HasAttributeWithName(const std::string &attributeName) const
AttributesMap_t fAttributes
bool fHasProtoPatternAttribute
cling::Interpreter * fInterp
const clang::Type * fRequestedType
bool fHasFileNameAttribute
void SetMatchFound(bool match)
std::unordered_map< std::string, std::string > AttributesMap_t
void PrintAttributes(int level) const
std::list< std::string > fFileSubPatterns
BaseSelectionRule(ESelect sel)
virtual void Print(std::ostream &out) const =0
bool fHasFromTypedefAttribute
std::string InsertStd(const char *tname)
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.