From 22f29f092ce9e83f931508586ebcb82ad9937a6d Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 11 Aug 2021 15:32:05 +0300 Subject: [PATCH] Remove nolint comments (#7020) * Remove nolint comments * Fixed comment --- .../src/inference_engine/CMakeLists.txt | 4 +- .../include/ie/details/ie_pre_allocator.hpp | 4 +- .../src/inference_engine/include/ie/ie_api.h | 2 +- .../inference_engine/include/ie/ie_common.h | 2 +- .../include/ie/ie_parallel.hpp | 2 +- .../include/ie/ie_parameter.hpp | 4 +- .../include/ie/ie_precision.hpp | 2 +- .../src/inference_engine/src/file_utils.cpp | 108 +++++++++--------- 8 files changed, 65 insertions(+), 63 deletions(-) diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt index 609b8a781a3..e79a5709366 100644 --- a/inference-engine/src/inference_engine/CMakeLists.txt +++ b/inference-engine/src/inference_engine/CMakeLists.txt @@ -142,8 +142,6 @@ if (TBBBIND_2_4_FOUND) target_link_libraries(${TARGET_NAME}_obj PRIVATE ${TBBBIND_2_4_IMPORTED_TARGETS}) endif() -add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}_obj) - # Create shared library file from object library add_library(${TARGET_NAME} SHARED @@ -152,6 +150,8 @@ add_library(${TARGET_NAME} SHARED ${vs_version_file} $) +add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${IE_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) + ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/openvino" ADDITIONAL_INCLUDE_DIRECTORIES $) diff --git a/inference-engine/src/inference_engine/include/ie/details/ie_pre_allocator.hpp b/inference-engine/src/inference_engine/include/ie/details/ie_pre_allocator.hpp index 949a31b646d..12428f4078a 100644 --- a/inference-engine/src/inference_engine/include/ie/details/ie_pre_allocator.hpp +++ b/inference-engine/src/inference_engine/include/ie/details/ie_pre_allocator.hpp @@ -37,7 +37,7 @@ public: /** * @brief The PreAllocator class does not utilize this function */ - void unlock(void*) noexcept override {} // NOLINT + void unlock(void*) noexcept override {} /** * @brief Returns a pointer to preallocated memory @@ -55,7 +55,7 @@ public: * @brief The PreAllocator class cannot release the handle * @return false */ - bool free(void*) noexcept override { // NOLINT + bool free(void*) noexcept override { return false; } }; diff --git a/inference-engine/src/inference_engine/include/ie/ie_api.h b/inference-engine/src/inference_engine/include/ie/ie_api.h index 538795b32be..eea1cc8dfe0 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_api.h +++ b/inference-engine/src/inference_engine/include/ie/ie_api.h @@ -119,7 +119,7 @@ IE_DO_PRAGMA(warning(disable : 1786)) # else # define INFERENCE_PLUGIN_API(type) extern "C" type # endif -#elif (__GNUC__ >= 4) // NOLINT +#elif (__GNUC__ >= 4) # ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN # define INFERENCE_PLUGIN_API(type) extern "C" __attribute__((visibility("default"))) type # else diff --git a/inference-engine/src/inference_engine/include/ie/ie_common.h b/inference-engine/src/inference_engine/include/ie/ie_common.h index 0a4a7857437..cb6ead29a92 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_common.h +++ b/inference-engine/src/inference_engine/include/ie/ie_common.h @@ -439,7 +439,7 @@ struct ThrowNow final { #ifdef NDEBUG # define IE_ASSERT(EXPRESSION) \ if (!(EXPRESSION)) \ - IE_THROW(GeneralError) << " AssertionFailed: " << #EXPRESSION // NOLINT + IE_THROW(GeneralError) << " AssertionFailed: " << #EXPRESSION #else /** * @private diff --git a/inference-engine/src/inference_engine/include/ie/ie_parallel.hpp b/inference-engine/src/inference_engine/include/ie/ie_parallel.hpp index 2411f077663..95494d46951 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_parallel.hpp +++ b/inference-engine/src/inference_engine/include/ie/ie_parallel.hpp @@ -110,7 +110,7 @@ inline int parallel_get_env_threads() { } #elif IE_THREAD == IE_THREAD_SEQ -# include // NOLINT +# include inline int parallel_get_env_threads() { return 1; } diff --git a/inference-engine/src/inference_engine/include/ie/ie_parameter.hpp b/inference-engine/src/inference_engine/include/ie/ie_parameter.hpp index 9aedae54cef..f68637b5e0d 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_parameter.hpp +++ b/inference-engine/src/inference_engine/include/ie/ie_parameter.hpp @@ -62,7 +62,7 @@ public: template ::type, Parameter>::value && !std::is_abstract::type>::value>::type> - Parameter(T&& parameter) { // NOLINT + Parameter(T&& parameter) { static_assert(!std::is_same::type, Parameter>::value, "To prevent recursion"); ptr = new RealData::type>(std::forward(parameter)); } @@ -72,7 +72,7 @@ public: * * @param str char array */ - Parameter(const char* str) : Parameter(std::string(str)) {} // NOLINT + Parameter(const char* str) : Parameter(std::string(str)) {} /** * @brief Destructor diff --git a/inference-engine/src/inference_engine/include/ie/ie_precision.hpp b/inference-engine/src/inference_engine/include/ie/ie_precision.hpp index 29c84b88eef..9cd256355dc 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_precision.hpp +++ b/inference-engine/src/inference_engine/include/ie/ie_precision.hpp @@ -67,7 +67,7 @@ public: * @brief Constructor with specified precision * @param value A value of ePrecision to create an object from */ - Precision(const Precision::ePrecision value) { // NOLINT + Precision(const Precision::ePrecision value) { precisionInfo = getPrecisionInfo(value); } diff --git a/inference-engine/src/inference_engine/src/file_utils.cpp b/inference-engine/src/inference_engine/src/file_utils.cpp index e31e1fe29c8..3a72787063d 100644 --- a/inference-engine/src/inference_engine/src/file_utils.cpp +++ b/inference-engine/src/inference_engine/src/file_utils.cpp @@ -7,90 +7,91 @@ #include #ifdef __MACH__ -#include -#include +# include +# include #endif #include #include #include + #include "ie_common.h" #ifndef _WIN32 -# include -# include -# include -# ifdef ENABLE_UNICODE_PATH_SUPPORT -# include -# include -# endif +# include +# include +# include +# ifdef ENABLE_UNICODE_PATH_SUPPORT +# include +# include +# endif #else -# if defined(WINAPI_FAMILY) && !WINAPI_PARTITION_DESKTOP -# error "Only WINAPI_PARTITION_DESKTOP is supported, because of GetModuleHandleEx[A|W]" -# endif -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include +# if defined(WINAPI_FAMILY) && !WINAPI_PARTITION_DESKTOP +# error "Only WINAPI_PARTITION_DESKTOP is supported, because of GetModuleHandleEx[A|W]" +# endif +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include #endif #ifdef _WIN32 -#include +# include // Copied from linux libc sys/stat.h: -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /// @brief Windows-specific 'mkdir' wrapper -#define makedir(dir) _mkdir(dir) +# define makedir(dir) _mkdir(dir) /// @brief Max length of absolute file path -#define MAX_ABS_PATH _MAX_PATH +# define MAX_ABS_PATH _MAX_PATH /// @brief Get absolute file path, returns NULL in case of error -#define get_absolute_path(result, path) _fullpath(result, path.c_str(), MAX_ABS_PATH) +# define get_absolute_path(result, path) _fullpath(result, path.c_str(), MAX_ABS_PATH) /// @brief Windows-specific 'stat' wrapper -#define stat _stat +# define stat _stat #else -#include +# include /// @brief mkdir wrapper -#define makedir(dir) mkdir(dir, 0755) +# define makedir(dir) mkdir(dir, 0755) /// @brief Max length of absolute file path -#define MAX_ABS_PATH PATH_MAX +# define MAX_ABS_PATH PATH_MAX /// @brief Get absolute file path, returns NULL in case of error -#define get_absolute_path(result, path) realpath(path.c_str(), result) +# define get_absolute_path(result, path) realpath(path.c_str(), result) #endif #ifdef ENABLE_UNICODE_PATH_SUPPORT std::string FileUtils::wStringtoMBCSstringChar(const std::wstring& wstr) { -#ifdef _WIN32 - int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); // NOLINT +# ifdef _WIN32 + int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); std::string strTo(size_needed, 0); - WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); // NOLINT + WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); return strTo; -#else +# else std::wstring_convert> wstring_decoder; return wstring_decoder.to_bytes(wstr); -#endif +# endif } std::wstring FileUtils::multiByteCharToWString(const char* str) { -#ifdef _WIN32 +# ifdef _WIN32 int strSize = static_cast(std::strlen(str)); int size_needed = MultiByteToWideChar(CP_UTF8, 0, str, strSize, NULL, 0); std::wstring wstrTo(size_needed, 0); MultiByteToWideChar(CP_UTF8, 0, str, strSize, &wstrTo[0], size_needed); return wstrTo; -#else +# else std::wstring_convert> wstring_encoder; std::wstring result = wstring_encoder.from_bytes(str); return result; -#endif +# endif } #endif // ENABLE_UNICODE_PATH_SUPPORT @@ -123,7 +124,7 @@ std::string FileUtils::absoluteFilePath(const std::string& filePath) { return absolutePath; } -bool FileUtils::directoryExists(const std::string &path) { +bool FileUtils::directoryExists(const std::string& path) { struct stat sb; if (stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) { @@ -145,8 +146,7 @@ void FileUtils::createDirectoryRecursive(const std::string& dirPath) { int err = makedir(dirPath.c_str()); if (err != 0 && errno != EEXIST) { // TODO: in case of exception it may be needed to remove all created sub-directories - IE_THROW() << "Couldn't create directory [" - << dirPath << "], err=" << strerror(errno) << ")"; + IE_THROW() << "Couldn't create directory [" << dirPath << "], err=" << strerror(errno) << ")"; } } @@ -154,7 +154,7 @@ namespace InferenceEngine { namespace { -template > +template > std::basic_string getPathName(const std::basic_string& s) { size_t i = s.rfind(FileUtils::FileTraits::FileSeparator, s.length()); if (i != std::string::npos) { @@ -171,50 +171,52 @@ static std::string getIELibraryPathA() { CHAR ie_library_path[MAX_PATH]; HMODULE hm = NULL; if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(getIELibraryPath), &hm)) { + reinterpret_cast(getIELibraryPath), + &hm)) { IE_THROW() << "GetModuleHandle returned " << GetLastError(); } GetModuleFileNameA(hm, (LPSTR)ie_library_path, sizeof(ie_library_path)); return getPathName(std::string(ie_library_path)); #elif defined(__APPLE__) || defined(__linux__) -# ifdef USE_STATIC_IE -# ifdef __APPLE__ +# ifdef USE_STATIC_IE +# ifdef __APPLE__ Dl_info info; dladdr(reinterpret_cast(getIELibraryPath), &info); std::string path = getPathName(std::string(info.dli_fname)).c_str(); -# else +# else char result[PATH_MAX]; ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); std::string path = getPathName(std::string(result, (count > 0) ? count : 0)); -# endif // __APPLE__ - return FileUtils::makePath(path, std::string( "lib")); -# else +# endif // __APPLE__ + return FileUtils::makePath(path, std::string("lib")); +# else Dl_info info; dladdr(reinterpret_cast(getIELibraryPath), &info); return getPathName(std::string(info.dli_fname)).c_str(); -# endif // USE_STATIC_IE +# endif // USE_STATIC_IE #else -# error "Unsupported OS" +# error "Unsupported OS" #endif // _WIN32 } #ifdef ENABLE_UNICODE_PATH_SUPPORT std::wstring getIELibraryPathW() { -#ifdef _WIN32 +# ifdef _WIN32 WCHAR ie_library_path[MAX_PATH]; HMODULE hm = NULL; if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(getIELibraryPath), &hm)) { + reinterpret_cast(getIELibraryPath), + &hm)) { IE_THROW() << "GetModuleHandle returned " << GetLastError(); } GetModuleFileNameW(hm, (LPWSTR)ie_library_path, sizeof(ie_library_path) / sizeof(ie_library_path[0])); return getPathName(std::wstring(ie_library_path)); -#elif defined(__linux__) || defined(__APPLE__) +# elif defined(__linux__) || defined(__APPLE__) return ::FileUtils::multiByteCharToWString(getIELibraryPathA().c_str()); -#else -# error "Unsupported OS" -#endif +# else +# error "Unsupported OS" +# endif } #endif // ENABLE_UNICODE_PATH_SUPPORT