27 #include "clang/Basic/SourceLocation.h" 28 #include "clang/Basic/SourceManager.h" 29 #include "clang/AST/DeclCXX.h" 30 #include "clang/AST/ASTContext.h" 31 #include "clang/AST/DeclTemplate.h" 40 clang::ASTContext& ctx = D->getASTContext();
41 clang::SourceManager& SM = ctx.getSourceManager();
42 clang::SourceLocation SL = D->getLocation();
47 SL = SM.getExpansionLoc(SL);
49 if (SL.isValid() && SL.isFileID()) {
50 clang::PresumedLoc PLoc = SM.getPresumedLoc(SL);
51 return PLoc.getFilename();
63 if((strcmp(srcname,filename)==0)) {
68 char i1name[_MAX_PATH];
69 char fullfile[_MAX_PATH];
70 _fullpath( i1name, srcname, _MAX_PATH );
71 _fullpath( fullfile, filename, _MAX_PATH );
72 if((stricmp(i1name, fullfile)==0))
return 1;
74 struct stat statBufItem;
76 if ( ( 0 == stat( filename, & statBufItem ) )
77 && ( 0 == stat( srcname, & statBuf ) )
78 && ( statBufItem.st_dev == statBuf.st_dev )
79 && ( statBufItem.st_ino == statBuf.st_ino )
80 && ( statBufItem.st_size == statBuf.st_size )
81 && ( statBufItem.st_mtime == statBuf.st_mtime )
90 : fIndex(index),fLineNumber(lineno),fSelFileName(selFileName),fIsSelected(sel),fMatchFound(false),fCXXRecordDecl(0),fRequestedType(0),fInterp(&interp)
92 fAttributes.insert(AttributesMap_t::value_type(attributeName, attributeValue));
107 AttributesMap_t::const_iterator iter =
fAttributes.find(attributeName);
115 AttributesMap_t::const_iterator iter =
fAttributes.find(attributeName);
118 returnValue = retVal ? iter->second :
"";
125 std::string localAttributeValue(attributeValue);
127 int pos = attributeName.find(
"pattern");
128 int pos_file = attributeName.find(
"file_pattern");
131 if (attributeName ==
"name" || pos> -1){
132 while(std::isspace(*localAttributeValue.begin())) localAttributeValue.erase(localAttributeValue.begin());
133 while(std::isspace(*localAttributeValue.rbegin()))localAttributeValue.erase(localAttributeValue.length()-1);
135 fAttributes.insert(AttributesMap_t::value_type(attributeName, localAttributeValue));
160 for (
int i = 0; i < level; ++i) {
166 for (
auto&& attr : orderedAttributes) {
167 out<<tabs<<attr.first<<
" = "<<attr.second<<std::endl;
171 out<<tabs<<
"No attributes"<<std::endl;
183 const std::string&
name,
184 const std::string& prototype,
185 bool isLinkdef)
const 204 const std::string& name_value =
fName;
205 const std::string& pattern_value =
fPattern;
208 const clang::CXXRecordDecl *D = llvm::dyn_cast<clang::CXXRecordDecl>(decl);
209 bool isTypedefNametoRecordDecl =
false;
213 const clang::TypedefNameDecl* typedefNameDecl = llvm::dyn_cast<clang::TypedefNameDecl> (decl);
214 isTypedefNametoRecordDecl = typedefNameDecl &&
220 if ( target && D && target == D ) {
226 if (name_value == name) {
231 const clang::CXXRecordDecl *target
241 if ( target && D && target == D ) {
249 const std::string& file_name_value =
fFileName;
262 if (!strncmp(name.c_str(),
"R__Init", 7) ||
263 strstr(name.c_str(),
"::R__Init")) {
266 if (!name.compare(0, 24,
"ROOT::R__dummyintdefault")) {
269 if (!name.compare(0, 27,
"ROOT::R__dummyVersionNumber")) {
272 if (!name.compare(0, 22,
"ROOT::R__dummyStreamer")) {
275 if (name.find(
"(anonymous namespace)") != std::string::npos) {
298 if (!patternMatched && !isLinkdef) {
299 std::string auxName(name);
300 std::string &nameNoSpaces = auxName;
301 nameNoSpaces.erase(std::remove_if(nameNoSpaces.begin(), nameNoSpaces.end(), isspace),
303 if (name.size() != nameNoSpaces.size()) {
314 if (!patternMatched &&
319 if (name.size() != auxName.size()) {
326 if (patternMatched) {
346 if (!prototype.empty()) {
375 if (pattern.size()==1 && pattern ==
"*"){
380 while (!temp.empty()){
381 pos = temp.find(
"*");
389 out.push_back(split);
395 temp = temp.substr(1);
397 else if (pos == (
int)(temp.length()-1)) {
398 if (pos > 0 && temp.at(pos-1) ==
'\\') {
399 split += temp.substr(0, temp.length()-2);
400 split += temp.at(pos);
401 out.push_back(split);
405 temp = temp.substr(0, (temp.length()-1));
408 if (pos > 0 && temp.at(pos-1) ==
'\\') {
409 split += temp.substr(0, pos-1);
410 split += temp.at(pos);
414 temp = temp.substr(pos);
419 split += temp.substr(0, pos);
422 split = temp.substr(0, pos);
425 temp = temp.substr(pos);
426 out.push_back(split);
442 bool begin = pattern.front() ==
'*';
443 if (pattern.size() == 1 && begin) {
448 std::list<std::string>::const_iterator it = patterns_list.begin();
449 size_t pos1, pos2, pos3;
450 pos1= pos2= pos3= std::string::npos;
451 bool end = pattern.back() ==
'*';
454 const std::string& last = patterns_list.back();
455 size_t pos_end = test.rfind(last);
457 if (pos_end == std::string::npos) {
463 int len = last.length();
464 if ((pos_end+len) < test.length()) {
470 pos1 = test.find(*it);
473 if (pos1 == std::string::npos || (!begin && pos1 != 0)) {
481 int len = (*it).length();
482 int pos_colon = test.find(
"::", pos1+len);
484 if (pos_colon > -1) {
490 if (patterns_list.size() > 1) {
491 if (((*it).length())+pos1 > pos_end) {
500 for (; it != patterns_list.end(); ++it) {
502 pos2 = test.find(*it);
551 std::cout<<
"Error - A pattern selection without sub patterns." <<std::endl;
bool fHasProtoNameAttribute
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
void ProcessPattern(const std::string &pattern, std::list< std::string > &out) const
EMatchType Match(const clang::NamedDecl *decl, const std::string &name, const std::string &prototype, bool isLinkdef) const
virtual void DebugPrint() const
ESelect GetSelected() const
bool GetMatchFound() const
bool fHasProtoPatternAttribute
std::list< std::string > fSubPatterns
std::list< std::string > fFileSubPatterns
std::string InsertStd(const char *tname)
const clang::Type * fRequestedType
const clang::Type * GetRequestedType() const
static const char * R__GetDeclSourceFileName(const clang::Decl *D)
bool fHasPatternAttribute
const AttributesMap_t & GetAttributes() const
void PrintAttributes(int level) const
virtual void Print(std::ostream &out) const =0
bool fHasFromTypedefAttribute
AttributesMap_t fAttributes
bool CheckPattern(const std::string &test, const std::string &pattern, const std::list< std::string > &patterns_list, bool isLinkdef) const
std::string fProtoPattern
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
static bool R__match_filename(const char *srcname, const char *filename)
bool fHasFilePatternAttribute
std::unordered_map< std::string, std::string > AttributesMap_t
bool GetAttributeValue(const std::string &attributeName, std::string &returnValue) const
Type
enumeration specifying the integration types.
cling::Interpreter * fInterp
void SetSelected(ESelect sel)
BaseSelectionRule(ESelect sel)
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
void SetCXXRecordDecl(const clang::CXXRecordDecl *decl, const clang::Type *typeptr)
void SetMatchFound(bool match)
const clang::CXXRecordDecl * fCXXRecordDecl
bool HasAttributeWithName(const std::string &attributeName) const
bool fHasFileNameAttribute