Skip to content

Commit 17181bf

Browse files
committed
Some experimental filtering of headers, seems to work
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
1 parent a38b4b6 commit 17181bf

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

.clang-tidy-filter

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
LIST OF HEADER FILES TO BE IGNORED BY CLANG TIDY
2+
include/dali/util/half.hpp
3+
include/dali/core/tensor_shape.h
4+
include/dali/core/access_order.h

.clang-tidy-filter.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

CMakeLists.txt

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,48 @@ endif()
274274

275275
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
276276
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register -Wsign-compare")
277+
execute_process(COMMAND
278+
find ${CMAKE_SOURCE_DIR}/dali ${CMAKE_SOURCE_DIR}/include
279+
-type f
280+
-regex ".*\\.\\(h\\|hpp\\|cuh\\|inl\\)$"
281+
OUTPUT_VARIABLE ALL_HEADERS
282+
OUTPUT_STRIP_TRAILING_WHITESPACE)
283+
#ECHO_OUTPUT_VARIABLE
284+
#COMMAND_ECHO STDOUT)
285+
# string(REGEX REPLACE "\n$" "|" ALL_HEADERS "${ALL_HEADERS}")
286+
# string(REPLACE "\n" ";" ALL_HEADERS_LIST ${ALL_HEADERS})
287+
# Remove the absolute path so we can apply filter file easily.
288+
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" ALL_HEADERS ${ALL_HEADERS})
289+
# string(REGEX REPLACE "\\." "\." ALL_HEADERS "${ALL_HEADERS}")
290+
message(STATUS "ALL_HEADERS is set to ${ALL_HEADERS}")
291+
set(TEST_LIST "include/dali/core/tensor_shape\\.h|include/dali/core/util\\.h")
292+
293+
file(READ ".clang-tidy-filter" CLANG_TIDY_LINE_FILTER)
294+
# make this a list
295+
string(REPLACE "\n" ";" CLANG_TIDY_LINE_FILTER ${CLANG_TIDY_LINE_FILTER})
296+
foreach(FILTERED IN ITEMS ${CLANG_TIDY_LINE_FILTER})
297+
string(REPLACE ${FILTERED} "" ALL_HEADERS ${ALL_HEADERS})
298+
endforeach()
299+
# nice and consistent argument order, we need to strip
300+
string(STRIP ${ALL_HEADERS} ALL_HEADERS)
301+
302+
# Format into the regex - make every line an alternative, swap . into \. and
303+
# We may have some empty newlines after the filtering
304+
string(REGEX REPLACE "(\n)+" "|" ALL_HEADERS ${ALL_HEADERS})
305+
string(REPLACE "." "\\." ALL_HEADERS ${ALL_HEADERS})
306+
message(STATUS "ALL_HEADERS is set to ${ALL_HEADERS}")
307+
277308

278309
# Settings specific to builds where Clang is used for compiling CUDA code
279310
if (DALI_CLANG_ONLY)
280311
# Full power of clang-tidy
281312
# Remove some that appera in fp16 and tests, and try again
282-
file(READ ".clang-tidy-filter.json" CLANG_TIDY_LINE_FILTER)
283313
set(CMAKE_CXX_CLANG_TIDY "clang-tidy"
284-
"-warnings-as-errors=-*,bugprone-*,misc-*,modernize-*,clang-analyzer-*"
285-
"-checks=-clang-analyzer-security.FloatLoopCounter,-clang-analyzer-core.DivideZero,-clang-analyzer-core.UndefinedBinaryOperatorResult"
286-
"-header-filter=.*")
314+
"-header-filter=${ALL_HEADERS}")
315+
# "--extra-arg-before=--system-header-prefix=include/dali/util/half.hpp")
316+
# "-warnings-as-errors=-*,bugprone-*,misc-*,modernize-*,clang-analyzer-*"
317+
# "-checks=-clang-analyzer-security.FloatLoopCounter,-clang-analyzer-core.DivideZero,-clang-analyzer-core.UndefinedBinaryOperatorResult"
318+
# "-header-filter=.*")
287319
# Line filter filters too much
288320
# "-line-filter=${CLANG_TIDY_LINE_FILTER}")
289321
message(STATUS "CMAKE_CXX_CLANG_TIDY is set to ${CMAKE_CXX_CLANG_TIDY}")

dali/kernels/audio/mel_scale/mel_filter_bank_cpu.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
1+
// Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -67,12 +67,16 @@ class MelFilterBankCpu<T>::Impl: public MelFilterImplBase<T> {
6767
double freq = mel_scale.mel_to_hz(mel);
6868
interval_ends_[interval] = std::ceil(freq / hz_step_);
6969
}
70+
std::string str = "Hello, world!\n";
71+
std::vector<std::string> messages;
72+
messages.emplace_back(std::move(str));
73+
std::cout << str;
7074
}
7175

7276

7377
/**
74-
* @brief Applies mel filter bank to a 2D spectrogram, optimized for
75-
* frequency-major layout ("ft").
78+
* @brief Applies mel filter bank to a 2D spectrogram, optimized for
79+
* frequency-major layout ("ft").
7680
*/
7781
void ComputeFreqMajor(T* out, const T* in, int64_t nwindows,
7882
int64_t out_size, int64_t out_stride,

0 commit comments

Comments
 (0)