1 // deprecated macro check implementation ---------------------------------------------// 2 // Protect against ourself: boostinspect:ndprecated_macros 3 4 // Copyright Eric Niebler 2010. 5 // Based on the assert_macro_check checker by Marshall Clow 6 // 7 // Distributed under the Boost Software License, Version 1.0. 8 // (See accompanying file LICENSE_1_0.txt or copy at 9 // http://www.boost.org/LICENSE_1_0.txt) 10 11 #include "deprecated_macro_check.hpp" 12 #include <functional> 13 #include "boost/regex.hpp" 14 #include "boost/lexical_cast.hpp" 15 #include "boost/filesystem/operations.hpp" 16 17 namespace fs = boost::filesystem; 18 19 namespace 20 { 21 const char * boost150macros [] = { 22 "BOOST_NO_0X_HDR_ARRAY", 23 "BOOST_NO_0X_HDR_CHRONO", 24 "BOOST_NO_0X_HDR_CODECVT", 25 "BOOST_NO_0X_HDR_CONDITION_VARIABLE", 26 "BOOST_NO_0X_HDR_FORWARD_LIST", 27 "BOOST_NO_0X_HDR_FUTURE", 28 "BOOST_NO_0X_HDR_INITIALIZER_LIST", 29 "BOOST_NO_INITIALIZER_LISTS", 30 "BOOST_NO_0X_HDR_MUTEX", 31 "BOOST_NO_0X_HDR_RANDOM", 32 "BOOST_NO_0X_HDR_RATIO", 33 "BOOST_NO_0X_HDR_REGEX", 34 "BOOST_NO_0X_HDR_SYSTEM_ERROR", 35 "BOOST_NO_0X_HDR_THREAD", 36 "BOOST_NO_0X_HDR_TUPLE", 37 "BOOST_NO_0X_HDR_TYPE_TRAITS", 38 "BOOST_NO_0X_HDR_TYPEINDEX", 39 "BOOST_NO_0X_HDR_UNORDERED_SET", 40 "BOOST_NO_0X_HDR_UNORDERED_MAP", 41 "BOOST_NO_STD_UNORDERED", 42 NULL 43 }; 44 45 const char * boost151macros [] = { 46 "BOOST_NO_AUTO_DECLARATIONS", 47 "BOOST_NO_AUTO_MULTIDECLARATIONS", 48 "BOOST_NO_CHAR16_T", 49 "BOOST_NO_CHAR32_T", 50 "BOOST_NO_TEMPLATE_ALIASES", 51 "BOOST_NO_CONSTEXPR", 52 "BOOST_NO_DECLTYPE", 53 "BOOST_NO_DECLTYPE_N3276", 54 "BOOST_NO_DEFAULTED_FUNCTIONS", 55 "BOOST_NO_DELETED_FUNCTIONS", 56 "BOOST_NO_EXPLICIT_CONVERSION_OPERATORS", 57 "BOOST_NO_EXTERN_TEMPLATE", 58 "BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS", 59 "BOOST_NO_LAMBDAS", 60 "BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS", 61 "BOOST_NO_NOEXCEPT", 62 "BOOST_NO_NULLPTR", 63 "BOOST_NO_RAW_LITERALS", 64 "BOOST_NO_RVALUE_REFERENCES", 65 "BOOST_NO_SCOPED_ENUMS", 66 "BOOST_NO_STATIC_ASSERT", 67 "BOOST_NO_STD_UNORDERED", 68 "BOOST_NO_UNICODE_LITERALS", 69 "BOOST_NO_UNIFIED_INITIALIZATION_SYNTAX", 70 "BOOST_NO_VARIADIC_TEMPLATES", 71 "BOOST_NO_VARIADIC_MACROS", 72 "BOOST_NO_NUMERIC_LIMITS_LOWEST", 73 NULL 74 }; 75 76 const char * boost153macros [] = { 77 "BOOST_HAS_STATIC_ASSERT", 78 "BOOST_HAS_RVALUE_REFS", 79 "BOOST_HAS_VARIADIC_TMPL", 80 "BOOST_HAS_CHAR16_T", 81 "BOOST_HAS_CHAR32_T", 82 NULL 83 }; 84 } // unnamed namespace 85 86 87 namespace boost 88 { 89 namespace inspect 90 { deprecated_macro_check()91 deprecated_macro_check::deprecated_macro_check() 92 : m_files_with_errors(0) 93 , m_from_boost_root( 94 fs::exists(search_root_path() / "boost") && 95 fs::exists(search_root_path() / "libs")) 96 { 97 register_signature( ".c" ); 98 register_signature( ".cpp" ); 99 register_signature( ".cxx" ); 100 register_signature( ".h" ); 101 register_signature( ".hpp" ); 102 register_signature( ".hxx" ); 103 register_signature( ".ipp" ); 104 } 105 inspect(const string & library_name,const path & full_path,const string & contents)106 void deprecated_macro_check::inspect( 107 const string & library_name, 108 const path & full_path, // example: c:/foo/boost/filesystem/path.hpp 109 const string & contents ) // contents of file to be inspected 110 { 111 if (contents.find( "boostinspect:" "ndprecated_macros" ) != string::npos) 112 return; 113 114 const char **ptr; 115 long errors = 0; 116 for ( ptr = boost150macros; *ptr != NULL; ++ptr ) 117 { 118 if ( contents.find( *ptr ) != string::npos ) { 119 ++errors; 120 error( library_name, full_path, string ( "Boost macro deprecated in 1.50: " ) + *ptr ); 121 } 122 } 123 124 for ( ptr = boost151macros; *ptr != NULL; ++ptr ) 125 { 126 if ( contents.find( *ptr ) != string::npos ) { 127 ++errors; 128 error( library_name, full_path, string ( "Boost macro deprecated in 1.51: " ) + *ptr ); 129 } 130 } 131 132 for ( ptr = boost153macros; *ptr != NULL; ++ptr ) 133 { 134 if ( contents.find( *ptr ) != string::npos ) { 135 ++errors; 136 error( library_name, full_path, string ( "Boost macro deprecated in 1.53: " ) + *ptr ); 137 } 138 } 139 140 if(errors > 0) 141 ++m_files_with_errors; 142 } 143 } // namespace inspect 144 } // namespace boost 145 146 147