[clang-tools-extra] [clang-tidy] Fix some false negatives in `bugprone-throw-keyword-missing` (PR #173748)

via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 27 17:05:29 PST 2025


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

The build failed before running any tests. Click on a failure below to see the details.

<details>
<summary>tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.o</summary>

```
FAILED: tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.o
sccache /opt/llvm/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/clang-tidy/bugprone -I/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/clang-tidy -I/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/include -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include -I/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/include -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.o -MF tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.o.d -o tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.o -c /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp:9:
In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.h:12:
In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/../ClangTidyCheck.h:14:
In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h:43:
In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h:73:
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:128:26: error: no viable conversion from 'const Matcher<clang::Expr>' to 'const Matcher<clang::Stmt>'
128 |     return Execute(Arg1, static_cast<const ArgT &>(Args)...);
|                          ^                         ~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp:25:13: note: in instantiation of function template specialization 'clang::ast_matchers::internal::VariadicFunction<clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::Matcher<clang::Stmt>, &clang::ast_matchers::internal::makeAllOfComposite>::operator()<clang::ast_matchers::internal::Matcher<clang::Expr>>' requested here
25 |         stmt(anyOf(doStmt(), whileStmt(), forStmt(), compoundStmt(), ifStmt(),
|             ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:568:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const clang::ast_matchers::internal::Matcher<clang::Expr>' to 'const Matcher<clang::Stmt> &' for 1st argument
568 | class Matcher {
|       ^~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:568:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const clang::ast_matchers::internal::Matcher<clang::Expr>' to 'Matcher<clang::Stmt> &&' for 1st argument
568 | class Matcher {
|       ^~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:578:3: note: candidate template ignored: requirement 'std::is_base_of<clang::Expr, clang::Stmt>::value' was not satisfied [with From = clang::Expr]
578 |   Matcher(const Matcher<From> &Other,
|   ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:590:3: note: candidate template ignored: requirement 'std::is_same<clang::Stmt, clang::QualType>::value' was not satisfied [with TypeT = clang::Expr]
590 |   Matcher(const Matcher<TypeT> &Other,
|   ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:571:12: note: explicit constructor is not a candidate
571 |   explicit Matcher(MatcherInterface<T> *Implementation)
|            ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:666:12: note: explicit constructor is not a candidate
666 |   explicit Matcher(const DynTypedMatcher &Implementation)
|            ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:624:3: note: candidate function
624 |   operator DynTypedMatcher() const & { return Implementation; }
|   ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:626:3: note: candidate function not viable: 'this' argument has type 'const clang::ast_matchers::internal::Matcher<clang::Expr>', but method is not marked const
626 |   operator DynTypedMatcher() && { return std::move(Implementation); }
|   ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1363:13: error: no matching conversion for functional-style cast from 'const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt>' to 'Matcher<clang::Stmt>'
1363 |     return {Matcher<T>(std::get<Is>(Params))...};
|             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1355:16: note: in instantiation of function template specialization 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt> &>::getMatchers<clang::Stmt, 0UL, 1UL, 2UL, 3UL, 4UL, 5UL, 6UL, 7UL>' requested here
1355 |                getMatchers<T>(std::index_sequence_for<Ps...>()))
|                ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp:25:14: note: in instantiation of function template specialization 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, clang::ast_matchers::internal::BindableMatcher<clang::Stmt>, const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt> &>::operator Matcher<clang::Stmt>' requested here
25 |         stmt(anyOf(doStmt(), whileStmt(), forStmt(), compoundStmt(), ifStmt(),
|              ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:568:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt>' to 'const Matcher<clang::Stmt>' for 1st argument
568 | class Matcher {
|       ^~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:568:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt>' to 'Matcher<clang::Stmt>' for 1st argument
568 | class Matcher {
|       ^~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:571:12: note: candidate constructor not viable: no known conversion from 'const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt>' to 'MatcherInterface<clang::Stmt> *' for 1st argument
571 |   explicit Matcher(MatcherInterface<T> *Implementation)
|            ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:666:12: note: candidate constructor not viable: no known conversion from 'const clang::ast_matchers::internal::VariadicDynCastAllOfMatcher<clang::Stmt, clang::AttributedStmt>' to 'const DynTypedMatcher' for 1st argument
666 |   explicit Matcher(const DynTypedMatcher &Implementation)
|            ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:578:3: note: candidate template ignored: could not match 'Matcher' against 'clang::ast_matchers::internal::VariadicDynCastAllOfMatcher'
578 |   Matcher(const Matcher<From> &Other,
|   ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:590:3: note: candidate template ignored: could not match 'Matcher' against 'clang::ast_matchers::internal::VariadicDynCastAllOfMatcher'
590 |   Matcher(const Matcher<TypeT> &Other,
|   ^
2 errors generated.
```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

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


More information about the cfe-commits mailing list