[clang-tools-extra] [clang-tidy] Add IgnoreAboveThreshold option to readability-function-cognitive-complexity (PR #178965)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 1 07:59:21 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE LINT COMMENT: clang-tidy-->


:warning: C/C++ code linter, clang-tidy found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

```bash

git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py   -path build -p1 -quiet
```

</details>

<details>
<summary>
View the output from clang-tidy here.
</summary>

```

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:477:7: error: no matching constructor for initialization of 'const std::optional<unsigned int>' [clang-diagnostic-error]
  477 |       IgnoreAboveThreshold(Options.get("IgnoreAboveThreshold")),
      |       ^                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:707:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'optional<StringRef>' to 'const optional<unsigned int>' for 1st argument
  707 |     class optional
      |           ^~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:707:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'optional<StringRef>' to 'optional<unsigned int>' for 1st argument
  707 |     class optional
      |           ^~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:741:17: note: candidate constructor not viable: no known conversion from 'std::optional<StringRef>' to 'nullopt_t' for 1st argument
  741 |       constexpr optional(nullopt_t) noexcept { }
      |                 ^        ~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:817:2: note: candidate constructor template not viable: no known conversion from 'std::optional<StringRef>' to 'in_place_t' for 1st argument
  817 |         optional(in_place_t, _Args&&... __args)
      |         ^        ~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:749:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<std::optional<unsigned int>, std::optional<llvm::StringRef>>>, std::__not_<std::is_same<std::in_place_t, std::optional<llvm::StringRef>>>, std::is_constructible<unsigned int, std::optional<llvm::StringRef>>, std::is_convertible<std::optional<llvm::StringRef>, unsigned int>>' was not satisfied [with _Up = std::optional<StringRef>]
  749 |         optional(_Up&& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:758:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<std::optional<unsigned int>, std::optional<llvm::StringRef>>>, std::__not_<std::is_same<std::in_place_t, std::optional<llvm::StringRef>>>, std::is_constructible<unsigned int, std::optional<llvm::StringRef>>, std::__not_<std::is_convertible<std::optional<llvm::StringRef>, unsigned int>>>' was not satisfied [with _Up = std::optional<StringRef>]
  758 |         optional(_Up&& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:768:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<unsigned int, llvm::StringRef>>, std::is_constructible<unsigned int, const llvm::StringRef &>, std::is_convertible<const llvm::StringRef &, unsigned int>, std::__not_<std::__or_<std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &&>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &&>, std::is_convertible<const std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<const std::optional<llvm::StringRef> &&, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &&, unsigned int>>>>' was not satisfied [with _Up = llvm::StringRef]
  768 |         optional(const optional<_Up>& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:781:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<unsigned int, llvm::StringRef>>, std::is_constructible<unsigned int, const llvm::StringRef &>, std::__not_<std::is_convertible<const llvm::StringRef &, unsigned int>>, std::__not_<std::__or_<std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &&>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &&>, std::is_convertible<const std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<const std::optional<llvm::StringRef> &&, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &&, unsigned int>>>>' was not satisfied [with _Up = llvm::StringRef]
  781 |         optional(const optional<_Up>& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:794:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<unsigned int, llvm::StringRef>>, std::is_constructible<unsigned int, llvm::StringRef>, std::is_convertible<llvm::StringRef, unsigned int>, std::__not_<std::__or_<std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &&>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &&>, std::is_convertible<const std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<const std::optional<llvm::StringRef> &&, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &&, unsigned int>>>>' was not satisfied [with _Up = llvm::StringRef]
  794 |         optional(optional<_Up>&& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:807:2: note: candidate template ignored: requirement '__and_v<std::__not_<std::is_same<unsigned int, llvm::StringRef>>, std::is_constructible<unsigned int, llvm::StringRef>, std::__not_<std::is_convertible<llvm::StringRef, unsigned int>>, std::__not_<std::__or_<std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &>, std::is_constructible<unsigned int, const std::optional<llvm::StringRef> &&>, std::is_constructible<unsigned int, std::optional<llvm::StringRef> &&>, std::is_convertible<const std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &, unsigned int>, std::is_convertible<const std::optional<llvm::StringRef> &&, unsigned int>, std::is_convertible<std::optional<llvm::StringRef> &&, unsigned int>>>>' was not satisfied [with _Up = llvm::StringRef]
  807 |         optional(optional<_Up>&& __t)
      |         ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:739:17: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
  739 |       constexpr optional() noexcept { }
      |                 ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:826:2: note: candidate constructor template not viable: requires at least 2 arguments, but 1 was provided
  826 |         optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
      |         ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

</details>


https://github.com/llvm/llvm-project/pull/178965


More information about the cfe-commits mailing list