From a1bc45548b2790a61818ccced9f4a11ad5624225 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Fri, 10 Mar 2017 09:36:58 -0600 Subject: [PATCH] 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. --- trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp index 3bd544ee..8fd78dc4 100644 --- a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp @@ -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 ; } } }