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

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 28 05:17:12 PST 2025


================
@@ -49,7 +49,7 @@ struct RegularException {
 
 // --------------
----------------
localspook wrote:

I see, that makes sense! It seems though that the existing tests already verify essentially the scenario you describe. The equivalent of your `RegularException` is `runtime_error`:
https://github.com/llvm/llvm-project/blob/1e985b6ddf023af5782d48c1cce881668fdf6ceb/clang-tools-extra/test/clang-tidy/checkers/bugprone/throw-keyword-missing.cpp#L24-L32
And indeed, the existing tests have lots of cases with intervening `ExprWithCleanups`: https://godbolt.org/z/vajK9n5eW. It seems the new matcher handles this correctly because, like you suggested, the check already defaults to `TK_IgnoreUnlessSpelledInSource`:
https://github.com/llvm/llvm-project/blob/1e985b6ddf023af5782d48c1cce881668fdf6ceb/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.h#L30-L32

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


More information about the cfe-commits mailing list