[all-commits] [llvm/llvm-project] 57330c: Don't look into base class aliases in bugprone-thr...
Aaron Puchert via All-commits
all-commits at lists.llvm.org
Thu Sep 25 11:13:09 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 57330c8514c78e7032975961badf5fa59091f059
https://github.com/llvm/llvm-project/commit/57330c8514c78e7032975961badf5fa59091f059
Author: Aaron Puchert <aaron.puchert at sap.com>
Date: 2025-09-25 (Thu, 25 Sep 2025)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/test/clang-tidy/checkers/bugprone/throw-keyword-missing.cpp
Log Message:
-----------
Don't look into base class aliases in bugprone-throw-keyword-missing (#160725)
The check confusingly fires on non-exception classes if any base class
has an alias in an exception class. In our case, the exception had an
alias for an allocator interface, so every allocator inheriting from
that interface was treated as an exception type. (But only when the
header for the exception was included.)
The reason behind this is the odd (but documented) behavior of
isDerivedFrom and similar matchers: it does not only iterate through the
bases as written, but through all relevant nodes to check them for being
a base. This makes the matcher also finds aliases of the base classes.
Only going through the bases as written can be done with `hasAnyBase`.
However, that doesn't cover the class itself, and we have to check it
separately. Since we're no longer looking through aliases via the
matcher, and because we're apparently interested in the canonical type,
we check that (see the test with "typedef std::exception ERROR_BASE;").
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list