This file is indexed.

/usr/include/rdkit/RDGeneral/Invariant.h is in librdkit-dev 201603.5+dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// Copyright (C)  2001-2013 Greg Landrum, Randal M. Henne and Rational Discovery
// LLC
//
//  @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//

#ifndef __RD_INVARIANT_H__
#define __RD_INVARIANT_H__

#include <assert.h>
#include <string>
#include <iostream>
#include <stdexcept>

#include <RDGeneral/RDLog.h>

#ifdef RDDEBUG
// Enable RDDEBUG for testing whether rdcast
//  conversions are within numerical limits
#include <boost/numeric/conversion/cast.hpp>
#endif
//
// What if no invariant method is defined?
//
#if !defined INVARIANT_EXCEPTION_METHOD && !defined INVARIANT_ASSERT_METHOD && \
    !defined INVARIANT_SILENT_METHOD
#define INVARIANT_EXCEPTION_METHOD 1
#endif

//
// What if an invariant method is defined, but none are true?
//
#if !INVARIANT_EXCEPTION_METHOD && !INVARIANT_ASSERT_METHOD && \
    !INVARIANT_SILENT_METHOD
#undef INVARIANT_EXCEPTION_METHOD
#define INVARIANT_EXCEPTION_METHOD 1
#endif

namespace Invar {

class Invariant : public std::runtime_error {
 public:
  Invariant(const char* prefix, const char* mess, const char* expr,
            const char* const file, int line)
      : std::runtime_error(prefix),
        mess_d(mess),
        expr_d(expr),
        prefix_d(prefix),
        file_dp(file),
        line_d(line) {}
  Invariant(const char* prefix, const std::string& mess, const char* expr,
            const char* const file, int line)
      : std::runtime_error(prefix),
        mess_d(mess.c_str()),
        expr_d(expr),
        prefix_d(prefix),
        file_dp(file),
        line_d(line) {}
  ~Invariant() throw(){};

  std::string getMessage() const { return mess_d; }

  const char* getFile() const { return file_dp; }

  std::string getExpression() const { return expr_d; }

  int getLine() const { return line_d; }

  std::string toString() const;
  std::string toUserString() const; // strips build info, adds version

 private:
  std::string mess_d, expr_d, prefix_d;

  const char* const file_dp;

  int line_d;
};
std::ostream& operator<<(std::ostream& s, const Invariant& inv);
}  // end of namespace Invar

#define ASSERT_INVARIANT(expr, mess) assert(expr)

//
// Set desired reporting method
//

#if INVARIANT_EXCEPTION_METHOD

#define CHECK_INVARIANT(expr, mess)                                    \
  if (!(expr)) {                                                       \
    Invar::Invariant inv("Invariant Violation", mess, #expr, __FILE__, \
                         __LINE__);                                    \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";        \
    throw inv;                                                         \
  }

#define PRECONDITION(expr, mess)                                           \
  if (!(expr)) {                                                           \
    Invar::Invariant inv("Pre-condition Violation", mess, #expr, __FILE__, \
                         __LINE__);                                        \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";            \
    throw inv;                                                             \
  }

#define POSTCONDITION(expr, mess)                                           \
  if (!(expr)) {                                                            \
    Invar::Invariant inv("Post-condition Violation", mess, #expr, __FILE__, \
                         __LINE__);                                         \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";             \
    throw inv;                                                              \
  }

#define UNDER_CONSTRUCTION(fn)                                        \
  Invar::Invariant inv("Incomplete Code",                             \
                       "This routine is still under development", fn, \
                       __FILE__, __LINE__);                           \
  BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";         \
  throw inv;

#define RANGE_CHECK(lo, x, hi)                                              \
  if ((lo) > (hi) || (x) < (lo) || (x) > (hi)) {                            \
    std::stringstream errstr;                                               \
    errstr << lo << " <= " << x << " <= " << hi;                            \
    Invar::Invariant inv("Range Error", #x, errstr.str().c_str(), __FILE__, \
                         __LINE__);                                         \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";             \
    throw inv;                                                              \
  }

#define URANGE_CHECK(x, hi)                                                 \
  if ((x) > (hi)) {                                                         \
    std::stringstream errstr;                                               \
    errstr << x << " <= " << hi;                                            \
    Invar::Invariant inv("Range Error", #x, errstr.str().c_str(), __FILE__, \
                         __LINE__);                                         \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";             \
    throw inv;                                                              \
  }

#define TEST_ASSERT(expr)                                             \
  if (!(expr)) {                                                      \
    Invar::Invariant inv("Test Assert", "Expression Failed: ", #expr, \
                         __FILE__, __LINE__);                         \
    BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n";       \
    throw inv;                                                        \
  }

#elif INVARIANT_ASSERT_METHOD

#define CHECK_INVARIANT(expr, mess) assert(expr);
#define PRECONDITION(expr, mess) assert(expr);
#define POSTCONDITION(expr, mess) assert(expr);
#define UNDER_CONSTRUCTION(fn) assert(0);
#define RANGE_CHECK(lo, x, hi) \
  assert((lo) <= (hi) && (x) >= (lo) && (x) <= (hi));
#define URANGE_CHECK(lo, x, hi) assert((x) <= (hi));
#define TEST_ASSERT(expr) assert(expr);

#elif INVARIANT_SILENT_METHOD

#define CHECK_INVARIANT(expr, mess)
#define PRECONDITION(expr, mess)
#define POSTCONDITION(expr, mess)
#define UNDER_CONSTRUCTION(fn)
#define RANGE_CHECK(lo, x, hi)
#define URANGE_CHECK(x, hi)
#define TEST_ASSERT(expr)

#endif

#ifdef RDDEBUG
// use rdcast to convert between types
//  when RDDEBUG is defined, this checks for
//  validity (overflow, etc)
//  when RDDEBUG is off, the cast is a no-cost
//   static_cast
#define rdcast boost::numeric_cast
#else
#define rdcast static_cast
#endif

// Silence warnings for unused params while
//   still indicating that they are unused
#define RDUNUSED_PARAM(x) (void) x;

#endif