From 319da5651575945a4ef5a42702935fcfc8f56cca Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Wed, 25 May 2022 14:18:55 -0500 Subject: [PATCH] clang-tidy (#9) - Fixed some clang-tidy warnings - Fixed issue with omnitrace_launch_compiler + clang-tidy [ROCm/rocprofiler-systems commit: 6af5b2a7e2dc834f372b7ba3b8e6db6b30e9f68d] --- .../examples/CMakeLists.txt | 15 +++--------- .../scripts/omnitrace_launch_compiler | 24 +++++++++++++++++++ .../source/lib/omnitrace/library.cpp | 2 +- .../lib/omnitrace/library/components/fwd.hpp | 6 ++--- .../lib/omnitrace/library/thread_sampler.cpp | 1 - 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/projects/rocprofiler-systems/examples/CMakeLists.txt b/projects/rocprofiler-systems/examples/CMakeLists.txt index 2d806bcbb3..445204f70d 100644 --- a/projects/rocprofiler-systems/examples/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/CMakeLists.txt @@ -4,6 +4,8 @@ project(omnitrace-dyninst-examples LANGUAGES CXX) set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF) set(CMAKE_CXX_VISIBILITY_PRESET "default") +set(CMAKE_CXX_CLANG_TIDY) +option(BUILD_SHARED_LIBS "Build dynamic libraries" ON) add_subdirectory(transpose) add_subdirectory(parallel-overhead) @@ -11,15 +13,4 @@ add_subdirectory(code-coverage) add_subdirectory(user-api) add_subdirectory(openmp) add_subdirectory(mpi) - -if(CMAKE_VERSION VERSION_LESS 3.16 AND (NOT DEFINED LULESH_BUILD_KOKKOS - OR LULESH_BUILD_KOKKOS)) - message( - AUTHOR_WARNING - "lulesh example cannot build Kokkos (requires CMake 3.16+, current version is ${CMAKE_VERSION})" - ) -else() - option(BUILD_SHARED_LIBS "Build dynamic libraries" ON) - - add_subdirectory(lulesh) -endif() +add_subdirectory(lulesh) diff --git a/projects/rocprofiler-systems/scripts/omnitrace_launch_compiler b/projects/rocprofiler-systems/scripts/omnitrace_launch_compiler index 9e6abf3459..5df1ecb357 100755 --- a/projects/rocprofiler-systems/scripts/omnitrace_launch_compiler +++ b/projects/rocprofiler-systems/scripts/omnitrace_launch_compiler @@ -55,6 +55,30 @@ CXX_COMPILER=${1} # remove the expected C++ compiler from the arguments shift +# discards the clang-tidy arguments +if [ "$(basename ${1})" = "cmake" ] && [ "${2}" = "-E" ] && [ "${3}" = "__run_co_compile" ]; then + c=1 + n=1 + for i in "${@}" + do + if [ "${i}" = "--" ]; then + break; + fi + if [ "${c}" -gt 3 ]; then + n=$((${n} + 1)) + fi + c=$((${c} + 1)) + done + + if [[ $# -gt ${c} ]]; then + n=$((${n} + 3)) # add three because of the first 3 args + for i in $(seq 1 1 ${n}) + do + shift + done + fi +fi + if [[ "${CXX_COMPILER}" != "${1}" ]]; then debug-message $@ # the command does not depend on omnitrace so just execute the command w/o re-directing to ${OMNITRACE_COMPILER} diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp index db6da02c81..38cc626848 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp @@ -1022,7 +1022,7 @@ omnitrace_finalize_hidden(void) auto& _aitr = get_timemory_hash_aliases(i); if(_hzero && _hitr) { - for(auto itr : *_hitr) + for(const auto& itr : *_hitr) _hzero->emplace(itr.first, itr.second); } if(_azero && _aitr) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/fwd.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/fwd.hpp index cb0d682d28..f50749f45a 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/fwd.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/fwd.hpp @@ -53,10 +53,8 @@ TIMEMORY_DECLARE_TYPE_TRAIT(name, typename Tp) static constexpr auto value = NAME; \ }; \ template <> \ - struct name> \ - { \ - static constexpr auto value = NAME; \ - }; \ + struct name> : name<__VA_ARGS__> \ + {}; \ } \ } diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/thread_sampler.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/thread_sampler.cpp index d18ab9d24b..bc25dbf154 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/thread_sampler.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/thread_sampler.cpp @@ -36,7 +36,6 @@ namespace thread_sampler { namespace { -using tim::type_mutex; using auto_lock_t = tim::auto_lock_t; using promise_t = std::promise; std::unique_ptr polling_finished = {};