tool for detecting mismatch between friend init_attr and containing class #371

Added a check and warning message in ICG that warns you if a friend function
starts with "init_attr" but does not match the current class name.
This commit is contained in:
Alex Lin 2017-03-10 09:36:58 -06:00
parent aab6ce3c9e
commit a1bc45548b

View File

@ -310,6 +310,11 @@ bool CXXRecordVisitor::VisitFriendDecl( clang::FriendDecl *fd ) {
if ( ! friend_str.find(init_func) ) {
//std::cout << " found a friend!" << std::endl ;
cval.setHasInitAttrFriend(true) ;
} else if ( ! friend_str.find("init_attr") ) {
std::cerr << bold(color(WARNING,"Warning")) << " " << cval.getFileName() << ":" <<
ci.getSourceManager().getSpellingLineNumber(fd->getSourceRange().getBegin()) << ":" << std::endl ;
std::cerr << " friend " << friend_str << " does not match expected name " <<
init_func << std::endl ;
}
}
}