Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79723 - in trunk: boost/config tools/inspect tools/inspect/build
From: marshall_at_[hidden]
Date: 2012-07-24 13:27:04


Author: marshall
Date: 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
New Revision: 79723
URL: http://svn.boost.org/trac/boost/changeset/79723

Log:
Added checking for deprecated macros in the inspect tool
Added:
   trunk/tools/inspect/deprecated_macro_check.cpp (contents, props changed)
   trunk/tools/inspect/deprecated_macro_check.hpp (contents, props changed)
Text files modified:
   trunk/boost/config/suffix.hpp | 1 +
   trunk/tools/inspect/build/Jamfile.v2 | 1 +
   trunk/tools/inspect/inspect.cpp | 24 ++++++++++++++++--------
   3 files changed, 18 insertions(+), 8 deletions(-)

Modified: trunk/boost/config/suffix.hpp
==============================================================================
--- trunk/boost/config/suffix.hpp (original)
+++ trunk/boost/config/suffix.hpp 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
@@ -1,4 +1,5 @@
 // Boost config.hpp configuration header file ------------------------------//
+// boostinspect:ndprecated_macros -- tell the inspect tool to ignore this file
 
 // Copyright (c) 2001-2003 John Maddock
 // Copyright (c) 2001 Darin Adler

Modified: trunk/tools/inspect/build/Jamfile.v2
==============================================================================
--- trunk/tools/inspect/build/Jamfile.v2 (original)
+++ trunk/tools/inspect/build/Jamfile.v2 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
@@ -19,6 +19,7 @@
     assert_macro_check.cpp
     copyright_check.cpp
     crlf_check.cpp
+ deprecated_macro_check.cpp
     end_check.cpp
     inspect.cpp
     license_check.cpp

Added: trunk/tools/inspect/deprecated_macro_check.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/inspect/deprecated_macro_check.cpp 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
@@ -0,0 +1,111 @@
+// assert_macro_check implementation ------------------------------------------------//
+
+// Copyright Eric Niebler 2010.
+// Based on the assert_macro_check checker by Marshall Clow
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include "deprecated_macro_check.hpp"
+#include <functional>
+#include "boost/regex.hpp"
+#include "boost/lexical_cast.hpp"
+#include "boost/filesystem/operations.hpp"
+
+namespace fs = boost::filesystem;
+
+namespace
+{
+ const char * boost150macros [] = {
+ "BOOST_NO_0X_HDR_ARRAY",
+ "BOOST_NO_0X_HDR_CHRONO",
+ "BOOST_NO_0X_HDR_CODECVT",
+ "BOOST_NO_0X_HDR_CONDITION_VARIABLE",
+ "BOOST_NO_0X_HDR_FORWARD_LIST",
+ "BOOST_NO_0X_HDR_FUTURE",
+ "BOOST_NO_0X_HDR_INITIALIZER_LIST",
+ "BOOST_NO_INITIALIZER_LISTS",
+ "BOOST_NO_0X_HDR_MUTEX",
+ "BOOST_NO_0X_HDR_RANDOM",
+ "BOOST_NO_0X_HDR_RATIO",
+ "BOOST_NO_0X_HDR_REGEX",
+ "BOOST_NO_0X_HDR_SYSTEM_ERROR",
+ "BOOST_NO_0X_HDR_THREAD",
+ "BOOST_NO_0X_HDR_TUPLE",
+ "BOOST_NO_0X_HDR_TYPE_TRAITS",
+ "BOOST_NO_0X_HDR_TYPEINDEX",
+ "BOOST_NO_0X_HDR_UNORDERED_SET",
+ "BOOST_NO_0X_HDR_UNORDERED_MAP",
+ "BOOST_NO_STD_UNORDERED",
+ NULL
+ };
+
+ const char * boost151macros [] = {
+ NULL
+ };
+} // unnamed namespace
+
+
+namespace boost
+{
+ namespace inspect
+ {
+ deprecated_macro_check::deprecated_macro_check()
+ : m_files_with_errors(0)
+ , m_from_boost_root(
+ fs::exists(fs::initial_path() / "boost") &&
+ fs::exists(fs::initial_path() / "libs"))
+ {
+ register_signature( ".c" );
+ register_signature( ".cpp" );
+ register_signature( ".cxx" );
+ register_signature( ".h" );
+ register_signature( ".hpp" );
+ register_signature( ".hxx" );
+ register_signature( ".ipp" );
+ }
+
+ void deprecated_macro_check::inspect(
+ const string & library_name,
+ const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
+ const string & contents ) // contents of file to be inspected
+ {
+ if (contents.find( "boostinspect:" "ndprecated_macros" ) != string::npos)
+ return;
+
+ // Check files iff (a) they are in the boost directory, or (b) they
+ // are in the src directory under libs.
+ if (m_from_boost_root) {
+ path relative( relative_to( full_path, fs::initial_path() ) );
+ path::const_iterator pbeg = relative.begin(), pend = relative.end();
+ if (pbeg != std::find(pbeg, pend, "boost") &&
+ !(pbeg == std::find(pbeg, pend, "libs") && pend != std::find(pbeg, pend, "src")))
+ return;
+ }
+
+ const char **ptr;
+ long errors = 0;
+ for ( ptr = boost150macros; *ptr != NULL; ++ptr )
+ {
+ if ( contents.find( *ptr ) != string::npos ) {
+ ++errors;
+ error( library_name, full_path, string ( "Deprecated Boost macro " ) + *ptr );
+ }
+ }
+
+ for ( ptr = boost151macros; *ptr != NULL; ++ptr )
+ {
+ if ( contents.find( *ptr ) != string::npos ) {
+ ++errors;
+ error( library_name, full_path, string ( "Deprecated Boost macro " ) + *ptr );
+ }
+ }
+
+ if(errors > 0)
+ ++m_files_with_errors;
+ }
+ } // namespace inspect
+} // namespace boost
+
+

Added: trunk/tools/inspect/deprecated_macro_check.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/inspect/deprecated_macro_check.hpp 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
@@ -0,0 +1,40 @@
+// deprecated_macro_check header --------------------------------------------------------//
+
+// Copyright Eric Niebler 2010.
+// Based on the apple_macro_check checker by Marshall Clow
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DEPRECATED_MACRO_CHECK_HPP
+#define BOOST_DEPRECATED_MACRO_CHECK_HPP
+
+#include "inspector.hpp"
+
+
+namespace boost
+{
+ namespace inspect
+ {
+ class deprecated_macro_check : public inspector
+ {
+ long m_files_with_errors;
+ bool m_from_boost_root;
+ public:
+
+ deprecated_macro_check();
+ virtual const char * name() const { return "*DEPRECATED-MACROS*"; }
+ virtual const char * desc() const { return "presence of deprecated BOOST macro in file (see docs for replacements)"; }
+
+ virtual void inspect(
+ const std::string & library_name,
+ const path & full_path,
+ const std::string & contents );
+
+ virtual ~deprecated_macro_check()
+ { std::cout << " " << m_files_with_errors << " files with a deprecated BOOST macro" << line_break(); }
+ };
+ }
+}
+
+#endif // BOOST_DEPRECATED_MACRO_CHECK_HPP

Modified: trunk/tools/inspect/inspect.cpp
==============================================================================
--- trunk/tools/inspect/inspect.cpp (original)
+++ trunk/tools/inspect/inspect.cpp 2012-07-24 13:27:03 EDT (Tue, 24 Jul 2012)
@@ -55,6 +55,7 @@
 #include "ascii_check.hpp"
 #include "apple_macro_check.hpp"
 #include "assert_macro_check.hpp"
+#include "deprecated_macro_check.hpp"
 #include "minmax_check.hpp"
 #include "unnamed_namespace_check.hpp"
 
@@ -582,6 +583,7 @@
          " -ascii\n"
          " -apple_macro\n"
          " -assert_macro\n"
+ " -deprecated_macro\n"
          " -minmax\n"
          " -unnamed\n"
          " default is all checks on; otherwise options specify desired checks"
@@ -752,8 +754,9 @@
   bool path_name_ck = true;
   bool tab_ck = true;
   bool ascii_ck = true;
- bool apple_ok = true;
- bool assert_ok = true;
+ bool apple_ck = true;
+ bool assert_ck = true;
+ bool deprecated_ck = true;
   bool minmax_ck = true;
   bool unnamed_ck = true;
   bool cvs = false;
@@ -786,8 +789,9 @@
     path_name_ck = false;
     tab_ck = false;
     ascii_ck = false;
- apple_ok = false;
- assert_ok = false;
+ apple_ck = false;
+ assert_ck = false;
+ deprecated_ck = false;
     minmax_ck = false;
     unnamed_ck = false;
   }
@@ -812,9 +816,11 @@
     else if ( std::strcmp( argv[1], "-ascii" ) == 0 )
       ascii_ck = true;
     else if ( std::strcmp( argv[1], "-apple_macro" ) == 0 )
- apple_ok = true;
+ apple_ck = true;
     else if ( std::strcmp( argv[1], "-assert_macro" ) == 0 )
- assert_ok = true;
+ assert_ck = true;
+ else if ( std::strcmp( argv[1], "-deprecated_macro" ) == 0 )
+ deprecated_ck = true;
     else if ( std::strcmp( argv[1], "-minmax" ) == 0 )
         minmax_ck = true;
     else if ( std::strcmp( argv[1], "-unnamed" ) == 0 )
@@ -858,10 +864,12 @@
       inspectors.push_back( inspector_element( new boost::inspect::tab_check ) );
   if ( ascii_ck )
       inspectors.push_back( inspector_element( new boost::inspect::ascii_check ) );
- if ( apple_ok )
+ if ( apple_ck )
       inspectors.push_back( inspector_element( new boost::inspect::apple_macro_check ) );
- if ( assert_ok )
+ if ( assert_ck )
       inspectors.push_back( inspector_element( new boost::inspect::assert_macro_check ) );
+ if ( deprecated_ck )
+ inspectors.push_back( inspector_element( new boost::inspect::deprecated_macro_check ) );
   if ( minmax_ck )
       inspectors.push_back( inspector_element( new boost::inspect::minmax_check ) );
   if ( unnamed_ck )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk