[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: Windows-->
# :window: Windows x64 Test Results
The build failed before running any tests. Click on a failure below to see the details.
<details>
<summary>[code=1] tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.obj</summary>
```
FAILED: [code=1] tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/ThrowKeywordMissingCheck.cpp.obj
sccache C:\clang\clang-msvc\bin\clang-cl.exe /nologo -TP -DCLANG_BUILD_STATIC -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\clang\tools\extra\clang-tidy\bugprone -IC:\_work\llvm-project\llvm-project\clang-tools-extra\clang-tidy\bugprone -Itools\clang\tools\extra\clang-tidy -IC:\_work\llvm-project\llvm-project\clang\include -Itools\clang\include -Iinclude -IC:\_work\llvm-project\llvm-project\llvm\include /DWIN32 /D_WINDOWS /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj /permissive- -Werror=unguarded-availability-new /W4 -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -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 /Gw /O2 /Ob2 -MD /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\clang\tools\extra\clang-tidy\bugprone\CMakeFiles\obj.clangTidyBugproneModule.dir\ThrowKeywordMissingCheck.cpp.obj /Fdtools\clang\tools\extra\clang-tidy\bugprone\CMakeFiles\obj.clangTidyBugproneModule.dir\ -c -- C:\_work\llvm-project\llvm-project\clang-tools-extra\clang-tidy\bugprone\ThrowKeywordMissingCheck.cpp
In file included from C:\_work\llvm-project\llvm-project\clang-tools-extra\clang-tidy\bugprone\ThrowKeywordMissingCheck.cpp:9:
In file included from C:\_work\llvm-project\llvm-project\clang-tools-extra\clang-tidy\bugprone\ThrowKeywordMissingCheck.h:12:
In file included from C:\_work\llvm-project\llvm-project\clang-tools-extra\clang-tidy\bugprone\../ClangTidyCheck.h:14:
In file included from C:\_work\llvm-project\llvm-project\clang\include\clang/ASTMatchers/ASTMatchFinder.h:43:
In file included from C:\_work\llvm-project\llvm-project\clang\include\clang/ASTMatchers/ASTMatchers.h:73:
C:\_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)...);
| ^ ~~~~
C:\_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(),
| ^
C:\_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 {
| ^~~~~~~
C:\_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 {
| ^~~~~~~
C:\_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,
| ^
C:\_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,
| ^
C:\_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)
| ^
C:\_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)
| ^
C:\_work\llvm-project\llvm-project\clang\include\clang/ASTMatchers/ASTMatchersInternal.h(624,3): note: candidate function
624 | operator DynTypedMatcher() const & { return Implementation; }
| ^
C:\_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); }
| ^
C:\_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))...};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_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, 0ULL, 1ULL, 2ULL, 3ULL, 4ULL, 5ULL, 6ULL, 7ULL>' requested here
1355 | getMatchers<T>(std::index_sequence_for<Ps...>()))
| ^
C:\_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(),
| ^
C:\_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 {
| ^~~~~~~
C:\_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 {
| ^~~~~~~
C:\_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)
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_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)
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_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,
| ^
C:\_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