clang-tidy warnings as errors

This commit is contained in:
Christopher Lackner 2018-12-10 10:52:00 +01:00
parent 17aba88117
commit 6f808cb40f
4 changed files with 17 additions and 12 deletions

View File

@ -360,7 +360,7 @@ if(ENABLE_CPP_CORE_GUIDELINES_CHECK)
message(WARNING "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-default-arguments")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-warnings-as-errors=*" "-header-filter=libsrc/core/")
endif()
endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)

4
libsrc/core/.clang-tidy Normal file
View File

@ -0,0 +1,4 @@
Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion'
CheckOptions:
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 1

View File

@ -3,8 +3,8 @@
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
@ -25,12 +25,12 @@ namespace ngcore
NGCORE_API std::string demangle(const char* typeinfo);
// create new pointer of type T if it is default constructible, else throw
template<typename T>
T* constructIfPossible_impl(...)
template<typename T, typename ...Rest>
T* constructIfPossible_impl(Rest... /*unused*/)
{ throw std::runtime_error(std::string(demangle(typeid(T).name())) + " is not default constructible!"); }
template<typename T, typename= typename std::enable_if<std::is_constructible<T>::value>::type>
T* constructIfPossible_impl(int) { return new T; }
T* constructIfPossible_impl(int /*unused*/) { return new T; }
template<typename T>
T* constructIfPossible() { return constructIfPossible_impl<T>(int{}); }
@ -45,7 +45,7 @@ namespace ngcore
typename std::is_same<decltype(std::declval<T2>().DoArchive(std::declval<Archive&>())),void>::type;
template<typename>
static constexpr std::false_type check(...);
typedef decltype(check<T>(0)) type;
using type = decltype(check<T>(nullptr));
public:
NGCORE_API static constexpr bool value = type::value;
};
@ -60,7 +60,7 @@ namespace ngcore
typename std::is_same<decltype(std::declval<Archive>() & std::declval<T2&>()),Archive&>::type;
template<typename>
static constexpr std::false_type check(...);
typedef decltype(check<T>(nullptr)) type;
using type = decltype(check<T>(nullptr));
public:
NGCORE_API static constexpr bool value = type::value;
};
@ -107,7 +107,8 @@ namespace ngcore
static void SetArchiveRegister(const std::string& classname, const ClassArchiveInfo& info);
static bool IsRegistered(const std::string& classname);
public:
Archive (bool ais_output) : is_output(ais_output), shared_ptr_count(0), ptr_count(0) { ; }
Archive (bool ais_output) : is_output(ais_output), shared_ptr_count(0), ptr_count(0)
shared_ptr2nr(), ptr2nr(), nr2shared_ptr(), nr2prt() { ; }
virtual ~Archive() { ; }
bool Output () { return is_output; }

View File

@ -53,16 +53,16 @@ namespace ngcore
std::string to_string() const
{ std::string vstring = "v" + std::to_string(mayor_);
if(minor_ || release || patch || git_hash.size())
if(minor_ || release || patch || !git_hash.empty())
{
vstring += "." + std::to_string(minor_);
if(release || patch || git_hash.size())
if(release || patch || !git_hash.empty())
{
vstring += "." + std::to_string(release);
if(patch || git_hash.size())
if(patch || !git_hash.empty())
{
vstring += "-" + std::to_string(patch);
if(git_hash.size())
if(!git_hash.empty())
vstring += "-" + git_hash;
}
}