Skip to content

Commit

Permalink
Merge pull request NVIDIA#1264 from NVIDIA/clang-tidy
Browse files Browse the repository at this point in the history
fix some problems found by clang-tidy
  • Loading branch information
ericniebler authored Feb 28, 2024
2 parents 54c9cbd + d449daa commit af0efa9
Show file tree
Hide file tree
Showing 50 changed files with 955 additions and 711 deletions.
151 changes: 151 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,modernize-*,-bugprone-reserved-identifier,-bugprone-unchecked-optional-access,-bugprone-macro-parentheses,-bugprone-easily-swappable-parameters'
WarningsAsErrors: ''
HeaderFileExtensions:
- ''
- h
- hh
- hpp
- hxx
ImplementationFileExtensions:
- c
- cc
- cpp
- cxx
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: eniebler
CheckOptions:
bugprone-argument-comment.CommentFloatLiterals: '0'
bugprone-argument-comment.CommentUserDefinedLiterals: '0'
modernize-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue'
modernize-use-bool-literals.IgnoreMacros: 'true'
bugprone-sizeof-expression.WarnOnSizeOfThis: 'true'
modernize-replace-auto-ptr.IncludeStyle: llvm
modernize-use-std-print.PrintfLikeFunctions: '::printf;absl::PrintF'
bugprone-suspicious-missing-comma.MaxConcatenatedTokens: '5'
bugprone-signed-char-misuse.CharTypdefsToIgnore: ''
modernize-make-unique.IgnoreMacros: 'true'
modernize-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque'
modernize-use-std-print.ReplacementPrintlnFunction: 'std::println'
modernize-use-noexcept.ReplacementString: ''
modernize-make-shared.IgnoreMacros: 'true'
modernize-loop-convert.MaxCopySize: '16'
bugprone-dangling-handle.HandleClasses: 'std::basic_string_view;std::experimental::basic_string_view'
modernize-loop-convert.MakeReverseRangeHeader: ''
llvm-else-after-return.WarnOnUnfixable: 'false'
bugprone-exception-escape.IgnoredExceptions: ''
bugprone-signal-handler.AsyncSafeFunctionSet: POSIX
bugprone-argument-comment.CommentIntegerLiterals: '0'
bugprone-argument-comment.CommentNullPtrs: '0'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
modernize-make-unique.MakeSmartPtrFunctionHeader: '<memory>'
modernize-make-unique.MakeSmartPtrFunction: 'std::make_unique'
modernize-deprecated-headers.CheckHeaderFile: 'false'
bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true'
bugprone-argument-comment.CommentCharacterLiterals: '0'
modernize-make-unique.IncludeStyle: llvm
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
bugprone-suspicious-missing-comma.RatioThreshold: '0.200000'
bugprone-string-constructor.LargeLengthThreshold: '8388608'
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
bugprone-string-constructor.WarnOnLargeLength: 'true'
bugprone-argument-comment.StrictMode: '0'
modernize-use-std-print.IncludeStyle: llvm
modernize-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
modernize-loop-convert.MakeReverseRangeFunction: ''
bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit: '16'
modernize-use-std-print.PrintHeader: '<print>'
modernize-use-override.FinalSpelling: final
bugprone-unused-return-value.CheckedFunctions: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname'
google-readability-namespace-comments.ShortNamespaceLines: '10'
modernize-replace-disallow-copy-and-assign-macro.MacroName: DISALLOW_COPY_AND_ASSIGN
bugprone-argument-comment.CommentStringLiterals: '0'
modernize-make-shared.IgnoreDefaultInitialization: 'true'
modernize-make-unique.IgnoreDefaultInitialization: 'true'
modernize-loop-convert.UseCxx20ReverseRanges: 'true'
bugprone-sizeof-expression.WarnOnSizeOfConstant: 'true'
bugprone-implicit-widening-of-multiplication-result.IncludeStyle: llvm
modernize-use-equals-default.IgnoreMacros: 'true'
modernize-loop-convert.IncludeStyle: llvm
bugprone-suspicious-include.HeaderFileExtensions: ';h;hh;hpp;hxx'
modernize-use-std-print.ReplacementPrintFunction: 'std::print'
modernize-use-override.IgnoreDestructors: 'false'
bugprone-empty-catch.AllowEmptyCatchForExceptions: ''
modernize-use-nullptr.NullMacros: 'NULL'
bugprone-argument-comment.CommentBoolLiterals: '0'
modernize-type-traits.IgnoreMacros: 'false'
modernize-use-std-print.StrictMode: 'false'
bugprone-narrowing-conversions.WarnOnEquivalentBitWidth: 'true'
modernize-replace-random-shuffle.IncludeStyle: llvm
bugprone-stringview-nullptr.IncludeStyle: llvm
bugprone-narrowing-conversions.PedanticMode: 'false'
modernize-raw-string-literal.DelimiterStem: lit
bugprone-suspicious-enum-usage.StrictMode: 'false'
llvm-qualified-auto.AddConstToQualified: 'false'
bugprone-suspicious-include.ImplementationFileExtensions: 'c;cc;cpp;cxx'
bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression: 'false'
modernize-use-emplace.TupleTypes: '::std::pair;::std::tuple'
bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField: 'true'
bugprone-dynamic-static-initializers.HeaderFileExtensions: ';h;hh;hpp;hxx'
google-readability-braces-around-statements.ShortStatementLines: '1'
bugprone-narrowing-conversions.WarnWithinTemplateInstantiation: 'false'
bugprone-argument-comment.IgnoreSingleArgument: '0'
bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true'
bugprone-suspicious-missing-comma.SizeThreshold: '5'
modernize-use-std-print.FprintfLikeFunctions: '::fprintf;absl::FPrintF'
modernize-use-using.IgnoreMacros: 'true'
modernize-use-auto.MinTypeNameLength: '5'
bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true'
modernize-use-override.IgnoreTemplateInstantiations: 'false'
modernize-loop-convert.MinConfidence: reasonable
bugprone-suspicious-string-compare.WarnOnLogicalNotComparison: 'false'
modernize-make-shared.MakeSmartPtrFunctionHeader: '<memory>'
modernize-use-emplace.IgnoreImplicitConstructors: 'false'
bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources: 'true'
bugprone-unsafe-functions.ReportMoreUnsafeFunctions: 'true'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
bugprone-suspicious-string-compare.StringCompareLikeFunctions: ''
google-readability-function-size.StatementThreshold: '800'
modernize-use-noexcept.UseNoexceptFalse: 'true'
bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources: 'true'
modernize-make-shared.IncludeStyle: llvm
bugprone-suspicious-string-compare.WarnOnImplicitComparison: 'true'
modernize-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
bugprone-unused-return-value.CheckedReturnTypes: '::std::error_code;::std::error_condition;::std::errc;::std::expected;::boost::system::error_code'
bugprone-assert-side-effect.IgnoredFunctions: __builtin_expect
bugprone-string-constructor.StringNames: '::std::basic_string;::std::basic_string_view'
bugprone-exception-escape.FunctionsThatShouldNotThrow: ''
modernize-use-default-member-init.IgnoreMacros: 'true'
bugprone-misplaced-widening-cast.CheckImplicitCasts: 'false'
modernize-use-equals-delete.IgnoreMacros: 'true'
modernize-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque'
modernize-pass-by-value.ValuesOnly: 'false'
bugprone-not-null-terminated-result.WantToUseSafeFunctions: 'true'
modernize-use-override.AllowOverrideAndFinal: 'false'
bugprone-non-zero-enum-to-bool-conversion.EnumIgnoreList: ''
bugprone-narrowing-conversions.IgnoreConversionFromTypes: ''
bugprone-assert-side-effect.AssertMacros: assert,NSAssert,NSCAssert
modernize-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple'
modernize-raw-string-literal.ReplaceShorterLiterals: 'false'
bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant: 'true'
bugprone-empty-catch.IgnoreCatchWithKeywords: '@TODO;@FIXME'
modernize-use-nodiscard.ReplacementString: '[[nodiscard]]'
modernize-pass-by-value.IncludeStyle: llvm
google-readability-namespace-comments.SpacesBeforeComments: '2'
bugprone-assert-side-effect.CheckFunctionCalls: 'false'
bugprone-sizeof-expression.WarnOnSizeOfPointerToAggregate: 'true'
modernize-loop-convert.NamingStyle: CamelCase
modernize-avoid-bind.PermissiveParameterList: 'false'
modernize-make-shared.MakeSmartPtrFunction: 'std::make_shared'
modernize-use-auto.RemoveStars: 'false'
modernize-use-default-member-init.UseAssignment: 'false'
bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons: 'true'
llvm-else-after-return.WarnOnConditionVariables: 'false'
modernize-use-override.OverrideSpelling: override
modernize-use-transparent-functors.SafeMode: 'false'
SystemHeaders: false
...

3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ ab2a3baef655db23fb7ec11ce7ec49575bbd2807

# replace all C-style casts with C++ casts; reformat
4410452fed3acda19d7b75b20ec2d3a3c92c9c38

# clang-modernize
3eaba4111bc8e8516ed1a4f516d753503b87e504
12 changes: 6 additions & 6 deletions include/exec/__detail/__atomic_intrusive_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace exec {
using __atomic_node_pointer = std::atomic<_Tp *>;

[[nodiscard]]
bool empty() const noexcept {
auto empty() const noexcept -> bool {
return __head_.load(std::memory_order_relaxed) == nullptr;
}

Expand All @@ -40,15 +40,15 @@ namespace exec {
bool __was_empty;
};

try_push_result try_push_front(__node_pointer t) noexcept {
auto try_push_front(__node_pointer t) noexcept -> try_push_result {
__node_pointer __old_head = __head_.load(std::memory_order_relaxed);
t->*_NextPtr = __old_head;
return {
__head_.compare_exchange_strong(__old_head, t, std::memory_order_acq_rel),
__old_head == nullptr};
}

bool push_front(__node_pointer t) noexcept {
auto push_front(__node_pointer t) noexcept -> bool {
__node_pointer __old_head = __head_.load(std::memory_order_relaxed);
do {
t->*_NextPtr = __old_head;
Expand All @@ -67,16 +67,16 @@ namespace exec {
queue.clear();
}

stdexec::__intrusive_queue<_NextPtr> pop_all() noexcept {
auto pop_all() noexcept -> stdexec::__intrusive_queue<_NextPtr> {
return stdexec::__intrusive_queue<_NextPtr>::make(reset_head());
}

stdexec::__intrusive_queue<_NextPtr> pop_all_reversed() noexcept {
auto pop_all_reversed() noexcept -> stdexec::__intrusive_queue<_NextPtr> {
return stdexec::__intrusive_queue<_NextPtr>::make_reversed(reset_head());
}

private:
__node_pointer reset_head() noexcept {
auto reset_head() noexcept -> __node_pointer {
__node_pointer __old_head = __head_.load(std::memory_order_relaxed);
while (!__head_.compare_exchange_weak(__old_head, nullptr, std::memory_order_acq_rel)) {
;
Expand Down
2 changes: 1 addition & 1 deletion include/exec/__detail/__basic_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace exec {
using __captures_t =
stdexec::__minvoke<__desc_t, stdexec::__q<stdexec::__detail::__captures_t>>;

static __tag_t __tag() noexcept {
static auto __tag() noexcept -> __tag_t {
return {};
}

Expand Down
Loading

0 comments on commit af0efa9

Please sign in to comment.