summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/inspect/deprecated_macro_check.cpp
blob: 7eeeda00cf538bba24ac180a828e23f68e32a0d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//  deprecated macro check implementation  ---------------------------------------------//
//  Protect against ourself: boostinspect:ndprecated_macros

//  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 [] = {
    "BOOST_NO_AUTO_DECLARATIONS",
    "BOOST_NO_AUTO_MULTIDECLARATIONS",
    "BOOST_NO_CHAR16_T",
    "BOOST_NO_CHAR32_T",
    "BOOST_NO_TEMPLATE_ALIASES",
    "BOOST_NO_CONSTEXPR",
    "BOOST_NO_DECLTYPE",
    "BOOST_NO_DECLTYPE_N3276",
    "BOOST_NO_DEFAULTED_FUNCTIONS",
    "BOOST_NO_DELETED_FUNCTIONS",
    "BOOST_NO_EXPLICIT_CONVERSION_OPERATORS",
    "BOOST_NO_EXTERN_TEMPLATE",
    "BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS",
    "BOOST_NO_LAMBDAS",
    "BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS",
    "BOOST_NO_NOEXCEPT",
    "BOOST_NO_NULLPTR",
    "BOOST_NO_RAW_LITERALS",
    "BOOST_NO_RVALUE_REFERENCES",
    "BOOST_NO_SCOPED_ENUMS",
    "BOOST_NO_STATIC_ASSERT",
    "BOOST_NO_STD_UNORDERED",
    "BOOST_NO_UNICODE_LITERALS",
    "BOOST_NO_UNIFIED_INITIALIZATION_SYNTAX",
    "BOOST_NO_VARIADIC_TEMPLATES",
    "BOOST_NO_VARIADIC_MACROS",
    "BOOST_NO_NUMERIC_LIMITS_LOWEST",
    NULL
    };

  const char * boost153macros [] = {
    "BOOST_HAS_STATIC_ASSERT",
    "BOOST_HAS_RVALUE_REFS",
    "BOOST_HAS_VARIADIC_TMPL",
    "BOOST_HAS_CHAR16_T",
    "BOOST_HAS_CHAR32_T",
    NULL
    };
} // unnamed namespace


namespace boost
{
  namespace inspect
  {
   deprecated_macro_check::deprecated_macro_check()
     : m_files_with_errors(0)
     , m_from_boost_root(
         fs::exists(search_root_path() / "boost") &&
         fs::exists(search_root_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;

      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 ( "Boost macro deprecated in 1.50: " ) + *ptr );
          }
      }

      for ( ptr = boost151macros; *ptr != NULL; ++ptr )
      {
        if ( contents.find( *ptr ) != string::npos ) {
          ++errors;
          error( library_name, full_path, string ( "Boost macro deprecated in 1.51: " ) + *ptr );
          }
      }

      for ( ptr = boost153macros; *ptr != NULL; ++ptr )
      {
        if ( contents.find( *ptr ) != string::npos ) {
          ++errors;
          error( library_name, full_path, string ( "Boost macro deprecated in 1.53: " ) + *ptr );
          }
      }

      if(errors > 0)
        ++m_files_with_errors;
    }
  } // namespace inspect
} // namespace boost