Skip to content

Commit

Permalink
Merge pull request #764 from gicmo/ndebug
Browse files Browse the repository at this point in the history
Turn on NDEBUG for Release builds

LGTM
  • Loading branch information
achilleas-k committed Jan 17, 2019
2 parents fcd92df + 6b5d264 commit 72e61da
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ src/pandora_cpp.cpp
.kdev4
nix.kdev4

# cquery
# cquery / ccls
compile_commands.json
.cquery_cached_index/
.ccls-cache/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef") # boost + clang

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -ggdb3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG")

if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_COVERAGE)
set (HAVE_COVERAGE ON)
Expand Down
3 changes: 1 addition & 2 deletions backend/hdf5/h5x/H5DataType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ DataType data_type_from_h5(const h5x::DataType &dtype) {
if (ftclass == H5T_COMPOUND) {
//if it is a compound data type then it must be a
//a property dataset, we can handle that
int nmems = dtype.member_count();
assert(nmems == 6);
assert(dtype.member_count() == 6);
h5x::DataType vtype = dtype.member_type(0);

ftclass = vtype.class_t();
Expand Down
9 changes: 7 additions & 2 deletions backend/hdf5/h5x/H5Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ void check_h5_arg_name_loc(const std::string &name, const SourceLocation &loc) {
if (name.find("/") != std::string::npos) {
std::stringstream stream;
stream << "Invalid Name: " << name << " contains a '/'!";
stream << " [" << loc.funcsig << " in " << loc.filepath << ": " << loc.fileline << "]";
stream << " [" << loc.funcsig;

if (!loc.filepath.empty()) {
stream << " in " << loc.filepath << ": " << loc.fileline;
}
stream << "]";
throw InvalidName(stream.str());
}
}


} //nix::hdf5::check
} //nix::hdf5
} //nix
} //nix
21 changes: 14 additions & 7 deletions backend/hdf5/h5x/H5Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// The single include point of HDF5
//
// A bit of a hack, but we directly include
// A bit of a hack, but we directly include
// hdf5's H5version.h to bypass any potetional
// H5_USE_16_API defines set in H5pubconf.h
// especially on old hdf5 versions (ubuntu precise)
Expand Down Expand Up @@ -67,18 +67,25 @@ namespace check {

struct SourceLocation {

SourceLocation(const std::string &fp, int fl, const std::string &fs) :
filepath(fp), fileline(fl), funcsig(fs) {}
SourceLocation(const std::string &fs, const std::string &fp = "", int fl = -1) :
funcsig(fs), filepath(fp), fileline(fl) {}

std::string funcsig;
std::string filepath;
int fileline;
std::string funcsig;


};

NIXAPI void check_h5_arg_name_loc(const std::string &name, const SourceLocation &location);
#define check_h5_arg_name(name__) nix::hdf5::check::check_h5_arg_name_loc(name__, {NIX_SRC_FILE, \
NIX_SRC_LINE, \
NIX_SRC_FUNC})

#ifdef NDEBUG
#define check_h5_arg_name(name__) nix::hdf5::check::check_h5_arg_name_loc(name__, {NIX_SRC_FUNC})
#else
#define check_h5_arg_name(name__) nix::hdf5::check::check_h5_arg_name_loc(name__, {NIX_SRC_FUNC, \
NIX_SRC_FILE, \
NIX_SRC_LINE})
#endif

} //nix::hdf5::check
} // nix::hdf5
Expand Down

0 comments on commit 72e61da

Please sign in to comment.