diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..c3bffa2 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,13 @@ +Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming' +CheckOptions: + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.EnumCase + value: CamelCase + - key: readability-identifier-naming.FunctionCase + value: lowerCase + - key: readability-identifier-naming.UnionCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: CamelCase + diff --git a/include/rosa/config/config.h b/include/rosa/config/config.h index 0a37957..0d1686e 100644 --- a/include/rosa/config/config.h +++ b/include/rosa/config/config.h @@ -1,35 +1,35 @@ /******************************************************************************* * * File: config.h * * Contents: Configuration nformation on the build of the library. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ -#ifndef __ROSA_CONFIG_SYSTEM_H__ -#define __ROSA_CONFIG_SYSTEM_H__ +#ifndef ROSA_CONFIG_SYSTEM_H +#define ROSA_CONFIG_SYSTEM_H // Various preprocessor macros containing config information. #include "rosa-config.h" // This OS-specific block defines one of the following: // - ROSA_LINUX // - ROSA_WINDOWS // It also defines ROSA_POSIX for POSIX-compatible systems #if defined(__linux__) #define ROSA_LINUX #elif defined(WIN32) || defined(_WIN32) #define ROSA_WINDOWS #else #error Platform and/or compiler not supported #endif #if defined(ROSA_LINUX) #define ROSA_POSIX #endif -#endif // __ROSA_CONFIG_SYSTEM_H__ +#endif // ROSA_CONFIG_SYSTEM_H diff --git a/include/rosa/config/rosa-config.h.cmake b/include/rosa/config/rosa-config.h.cmake index a1b0606..3698825 100644 --- a/include/rosa/config/rosa-config.h.cmake +++ b/include/rosa/config/rosa-config.h.cmake @@ -1,38 +1,38 @@ -#ifndef __ROSA_CONFIG_ROSA_CONFIG_H__ -#define __ROSA_CONFIG_ROSA_CONFIG_H__ +#ifndef ROSA_CONFIG_ROSA_CONFIG_H +#define ROSA_CONFIG_ROSA_CONFIG_H #define CMAKE_SYSTEM "${CMAKE_SYSTEM}" #define CMAKE_GENERATOR "${CMAKE_GENERATOR}" #define CMAKE_C_COMPILER_ID "${CMAKE_C_COMPILER_ID}" #define CMAKE_C_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}" #define CMAKE_CXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}" #define CMAKE_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}" #define ROSA_VERSION_MAJOR ${ROSA_VERSION_MAJOR} #define ROSA_VERSION_MINOR ${ROSA_VERSION_MINOR} #define ROSA_VERSION_PATCH ${ROSA_VERSION_PATCH} #define PACKAGE_NAME "${PACKAGE_NAME}" #define PACKAGE_STRING "${PACKAGE_STRING}" #define PACKAGE_VERSION "${PACKAGE_VERSION}" #define PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" #define BUILD_DATE __DATE__ " " __TIME__ #if @ROSA_ENABLE_ASSERTIONS_INT@ != -1 #define ROSA_ENABLE_ASSERTIONS #endif -#endif // __ROSA_CONFIG_ROSA_CONFIG_H__ +#endif // ROSA_CONFIG_ROSA_CONFIG_H diff --git a/include/rosa/config/version.h b/include/rosa/config/version.h index df9e453..eb0c8cb 100644 --- a/include/rosa/config/version.h +++ b/include/rosa/config/version.h @@ -1,35 +1,35 @@ /******************************************************************************* * * File: version.h * * Contents: Version information about the build of the library. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ -#ifndef _ROSA__CONFIG_VERSION_H_ -#define _ROSA__CONFIG_VERSION_H_ +#ifndef ROSA_CONFIG_VERSION_H +#define ROSA_CONFIG_VERSION_H #include // Various preprocessor macros containing the information. #include "rosa/config/rosa-config.h" namespace rosa { // Returns a string containing the name of the library followed by its version. std::string library_string(void); // Returns a string containing the version number of the library. std::string version(void); // Returns a multi-line string containing verbose information on the library. std::string verbose_version(void); } // End namespace rosa -#endif // _ROSA__CONFIG_VERSION_H_ +#endif // ROSA_CONFIG_VERSION_H diff --git a/include/rosa/support/debug.hpp b/include/rosa/support/debug.hpp index 0b93355..0392388 100644 --- a/include/rosa/support/debug.hpp +++ b/include/rosa/support/debug.hpp @@ -1,81 +1,81 @@ /******************************************************************************* * * File: debug.hpp * * Contents: Facility for debugging * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ -#ifndef _ROSA__SUPPORT_DEBUG_HPP_ -#define _ROSA__SUPPORT_DEBUG_HPP_ +#ifndef ROSA_SUPPORT_DEBUG_HPP +#define ROSA_SUPPORT_DEBUG_HPP #include "rosa/support/types.hpp" #include #include namespace rosa { // Returns an output stream to use for debugging. std::ostream &dbgs(void); // Prints an array to the ostream. template std::ostream &operator<<(std::ostream &os, const std::array &arr) { os << '['; - for (unsigned i = 0; i < size; ++i) { - if (i) { + for (unsigned I = 0; I < size; ++I) { + if (I) { os << ','; } - os << (PRINTABLE(T)) arr[i]; + os << (PRINTABLE(T)) arr[I]; } os << ']'; return os; } } // End namespace rosa #ifndef ROSA_ENABLE_ASSERTIONS #define ASSERT(unused) static_cast(0) #elif defined(ROSA_WINDOWS) #define ASSERT(stmt) \ if (static_cast(stmt) == false) { \ rosa::dbgs() << __FILE__ << ":" << __LINE__ << ": requirement failed '" \ << #stmt << "'" << std::endl; \ ::abort(); \ } \ static_cast(0) #else // defined(ROSA_LINUX) #include #define ASSERT(stmt) \ if (static_cast(stmt) == false) { \ rosa::dbgs() << __FILE__ << ":" << __LINE__ << ": requirement failed '" \ << #stmt << "'" << std::endl; \ void *array[20]; \ auto bt_size = ::backtrace(array, 20); \ ::backtrace_symbols_fd(array, bt_size, 2); \ ::abort(); \ } \ static_cast(0) #endif // defined(ROSA_ENABLE_ASSERTIONS) #ifndef NDEBUG #define DEBUG(X) \ do { \ X; \ } while (0) #define DEBUGVAR(V) \ do { \ rosa::dbgs() << #V << " (" << __FILE__ << ":" << __LINE__ << "): " << (V) \ << std::endl; \ } while (0) #else // defined(NDEBUG) #define DEBUG(X) static_cast(0) #define DEBUGVAR(X) static_cast(0) #endif // defined(NDEBUG) -#endif // _ROSA__SUPPORT_DEBUG_HPP_ +#endif // ROSA_SUPPORT_DEBUG_HPP diff --git a/include/rosa/support/types.hpp b/include/rosa/support/types.hpp index ee503d7..3fe00af 100644 --- a/include/rosa/support/types.hpp +++ b/include/rosa/support/types.hpp @@ -1,46 +1,46 @@ /******************************************************************************* * * File: types.hpp * * Contents: Facility for type-related things * * Copyright 2016 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ -#ifndef _ROSA__SUPPORT_TYPES_HPP_ -#define _ROSA__SUPPORT_TYPES_HPP_ +#ifndef ROSA_SUPPORT_TYPES_HPP +#define ROSA_SUPPORT_TYPES_HPP #include namespace rosa { // A value of type [u]int8_t is treated as a character when being put to an // output stream, which can result in invisible characters being printed. To // avoid that, such a value needs to be casted to a wider type. It can be done // by using the following template to find a target type to cast our value to. // NOTE: There is a preprocessor macro below which can be used instead of the // tedious typename stuff. template struct PrintableType { typedef T type; }; template <> struct PrintableType { typedef unsigned int type; }; template <> struct PrintableType { typedef int type; }; #define PRINTABLE(T) typename PrintableType::type } // End namespace rosa -#endif // _ROSA__SUPPORT_TYPES_HPP_ +#endif // ROSA_SUPPORT_TYPES_HPP