[clang-tools-extra] [clang-tidy] Rename hicpp-exception-baseclass to bugprone-exception-baseclass (PR #183474)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 10 17:09:20 PDT 2026
https://github.com/IamYJLee updated https://github.com/llvm/llvm-project/pull/183474
>From 4551a569ac391866767e962de206d6d5a423102b Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Thu, 26 Feb 2026 17:16:46 +0900
Subject: [PATCH 1/8] [clang-tidy] Rename hicpp-exception-baseclass to
bugprone-exception-baseclass
---
.../clang-tidy/bugprone/BugproneTidyModule.cpp | 3 +++
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 1 +
.../{hicpp => bugprone}/ExceptionBaseclassCheck.cpp | 4 ++--
.../{hicpp => bugprone}/ExceptionBaseclassCheck.h | 10 +++++-----
clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt | 1 -
clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp | 1 +
clang-tools-extra/clangd/TidyFastChecks.inc | 2 +-
.../checks/{hicpp => bugprone}/exception-baseclass.rst | 4 ++--
clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 +
.../clang-tidy/checkers/hicpp/exception-baseclass.cpp | 2 +-
10 files changed, 17 insertions(+), 12 deletions(-)
rename clang-tools-extra/clang-tidy/{hicpp => bugprone}/ExceptionBaseclassCheck.cpp (97%)
rename clang-tools-extra/clang-tidy/{hicpp => bugprone}/ExceptionBaseclassCheck.h (77%)
rename clang-tools-extra/docs/clang-tidy/checks/{hicpp => bugprone}/exception-baseclass.rst (89%)
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 310184037afbd..45bce2aabbed0 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -29,6 +29,7 @@
#include "DynamicStaticInitializersCheck.h"
#include "EasilySwappableParametersCheck.h"
#include "EmptyCatchCheck.h"
+#include "ExceptionBaseclassCheck.h"
#include "ExceptionCopyConstructorThrowsCheck.h"
#include "ExceptionEscapeCheck.h"
#include "FloatLoopCounterCheck.h"
@@ -158,6 +159,8 @@ class BugproneModule : public ClangTidyModule {
CheckFactories.registerCheck<EasilySwappableParametersCheck>(
"bugprone-easily-swappable-parameters");
CheckFactories.registerCheck<EmptyCatchCheck>("bugprone-empty-catch");
+ CheckFactories.registerCheck<ExceptionBaseclassCheck>(
+ "bugprone-exception-baseclass");
CheckFactories.registerCheck<ExceptionCopyConstructorThrowsCheck>(
"bugprone-exception-copy-constructor-throws");
CheckFactories.registerCheck<ExceptionEscapeCheck>(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 96ad671d03b39..e272793b4b21f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule STATIC
DynamicStaticInitializersCheck.cpp
EasilySwappableParametersCheck.cpp
EmptyCatchCheck.cpp
+ ExceptionBaseclassCheck.cpp
ExceptionCopyConstructorThrowsCheck.cpp
ExceptionEscapeCheck.cpp
FloatLoopCounterCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp
similarity index 97%
rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
rename to clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp
index 71b82875c09a0..625ed48ef3cf5 100644
--- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp
@@ -12,7 +12,7 @@
using namespace clang::ast_matchers;
-namespace clang::tidy::hicpp {
+namespace clang::tidy::bugprone {
void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
@@ -54,4 +54,4 @@ void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) {
diag(TypeDecl->getBeginLoc(), "type defined here", DiagnosticIDs::Note);
}
-} // namespace clang::tidy::hicpp
+} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
similarity index 77%
rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
rename to clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
index 800e7ac9663d5..4a589aebde99f 100644
--- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
#include "../ClangTidyCheck.h"
-namespace clang::tidy::hicpp {
+namespace clang::tidy::bugprone {
/// Check for thrown exceptions and enforce they are all derived from
/// std::exception.
@@ -29,6 +29,6 @@ class ExceptionBaseclassCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
-} // namespace clang::tidy::hicpp
+} // namespace clang::tidy::bugprone
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
index e8401e750642d..b5bcbf389b4ae 100644
--- a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
)
add_clang_library(clangTidyHICPPModule STATIC
- ExceptionBaseclassCheck.cpp
HICPPTidyModule.cpp
MultiwayPathsCoveredCheck.cpp
SignedBitwiseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index 3eb6d5de39d04..2926037876e88 100644
--- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -8,6 +8,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
+#include "../bugprone/ExceptionBaseclassCheck.h"
#include "../bugprone/UndelegatedConstructorCheck.h"
#include "../bugprone/UnusedReturnValueCheck.h"
#include "../bugprone/UseAfterMoveCheck.h"
diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc
index de1a025602fa9..e5d7711b201cb 100644
--- a/clang-tools-extra/clangd/TidyFastChecks.inc
+++ b/clang-tools-extra/clangd/TidyFastChecks.inc
@@ -63,6 +63,7 @@ FAST(bugprone-dangling-handle, -0.0)
FAST(bugprone-dynamic-static-initializers, 0.0)
FAST(bugprone-easily-swappable-parameters, 2.0)
FAST(bugprone-empty-catch, 1.0)
+FAST(bugprone-exception-baseclass, -1.0)
FAST(bugprone-exception-escape, 0.0)
FAST(bugprone-fold-init-type, 1.0)
FAST(bugprone-forward-declaration-namespace, 0.0)
@@ -247,7 +248,6 @@ FAST(hicpp-avoid-c-arrays, 1.0)
FAST(hicpp-avoid-goto, -0.0)
FAST(hicpp-braces-around-statements, 0.0)
FAST(hicpp-deprecated-headers, 1.0)
-FAST(hicpp-exception-baseclass, -1.0)
FAST(hicpp-explicit-conversions, 1.0)
FAST(hicpp-function-size, 1.0)
FAST(hicpp-ignored-remove-result, 3.0)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
similarity index 89%
rename from clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
rename to clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
index 7a1c1a07c49e3..b166df8897f8b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
@@ -1,6 +1,6 @@
-.. title:: clang-tidy - hicpp-exception-baseclass
+.. title:: clang-tidy - bugprone-exception-baseclass
-hicpp-exception-baseclass
+bugprone-exception-baseclass
=========================
Ensure that every value that in a ``throw`` expression is an instance of
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 362455796bd50..5aa1168bd4559 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -99,6 +99,7 @@ Clang-Tidy Checks
:doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`,
:doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`,
:doc:`bugprone-empty-catch <bugprone/empty-catch>`,
+ :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`,
:doc:`bugprone-exception-copy-constructor-throws <bugprone/exception-copy-constructor-throws>`,
:doc:`bugprone-exception-escape <bugprone/exception-escape>`,
:doc:`bugprone-float-loop-counter <bugprone/float-loop-counter>`,
diff --git a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp
index b5e405a691848..4bf52936c0b63 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s hicpp-exception-baseclass %t -- -- -fcxx-exceptions
+// RUN: %check_clang_tidy %s bugprone-exception-baseclass %t -- -- -fcxx-exceptions
namespace std {
class exception {};
>From 2eeea47fadff80427b39aff5c1f3c6880f8641d1 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Thu, 26 Feb 2026 17:28:42 +0900
Subject: [PATCH 2/8] [clang-tidy] Move test case
---
.../checkers/{hicpp => bugprone}/exception-baseclass.cpp | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename clang-tools-extra/test/clang-tidy/checkers/{hicpp => bugprone}/exception-baseclass.cpp (100%)
diff --git a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp
similarity index 100%
rename from clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp
rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp
>From 05b031545f394085284b51837bc58fa46ce19ac4 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Fri, 27 Feb 2026 11:18:37 +0900
Subject: [PATCH 3/8] [clang-tidy] Address review feedback: keep alias
---
.../clang-tidy/bugprone/ExceptionBaseclassCheck.h | 2 +-
clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp | 2 +-
clang-tools-extra/clangd/TidyFastChecks.inc | 2 +-
.../clang-tidy/checks/bugprone/exception-baseclass.rst | 5 +----
.../clang-tidy/checks/hicpp/exception-baseclass.rst | 10 ++++++++++
clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 +
6 files changed, 15 insertions(+), 7 deletions(-)
create mode 100644 clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
index 4a589aebde99f..d5728b843ec19 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
@@ -17,7 +17,7 @@ namespace clang::tidy::bugprone {
/// std::exception.
///
/// For the user-facing documentation see:
-/// https://clang.llvm.org/extra/clang-tidy/checks/hicpp/exception-baseclass.html
+/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-baseclass.html
class ExceptionBaseclassCheck : public ClangTidyCheck {
public:
ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context)
diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index 2926037876e88..ab2f84eda560e 100644
--- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -56,7 +56,7 @@ class HICPPModule : public ClangTidyModule {
"hicpp-braces-around-statements");
CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>(
"hicpp-deprecated-headers");
- CheckFactories.registerCheck<ExceptionBaseclassCheck>(
+ CheckFactories.registerCheck<bugprone::ExceptionBaseclassCheck>(
"hicpp-exception-baseclass");
CheckFactories.registerCheck<bugprone::UnusedReturnValueCheck>(
"hicpp-ignored-remove-result");
diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc
index e5d7711b201cb..de1a025602fa9 100644
--- a/clang-tools-extra/clangd/TidyFastChecks.inc
+++ b/clang-tools-extra/clangd/TidyFastChecks.inc
@@ -63,7 +63,6 @@ FAST(bugprone-dangling-handle, -0.0)
FAST(bugprone-dynamic-static-initializers, 0.0)
FAST(bugprone-easily-swappable-parameters, 2.0)
FAST(bugprone-empty-catch, 1.0)
-FAST(bugprone-exception-baseclass, -1.0)
FAST(bugprone-exception-escape, 0.0)
FAST(bugprone-fold-init-type, 1.0)
FAST(bugprone-forward-declaration-namespace, 0.0)
@@ -248,6 +247,7 @@ FAST(hicpp-avoid-c-arrays, 1.0)
FAST(hicpp-avoid-goto, -0.0)
FAST(hicpp-braces-around-statements, 0.0)
FAST(hicpp-deprecated-headers, 1.0)
+FAST(hicpp-exception-baseclass, -1.0)
FAST(hicpp-explicit-conversions, 1.0)
FAST(hicpp-function-size, 1.0)
FAST(hicpp-ignored-remove-result, 3.0)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
index b166df8897f8b..8fd9c6093a3f4 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
@@ -1,14 +1,11 @@
.. title:: clang-tidy - bugprone-exception-baseclass
bugprone-exception-baseclass
-=========================
+============================
Ensure that every value that in a ``throw`` expression is an instance of
``std::exception``.
-This enforces `rule 15.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_
-of the High Integrity C++ Coding Standard.
-
.. code-block:: c++
class custom_exception {};
diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
new file mode 100644
index 0000000000000..e7e25b0aa4a87
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - hicpp-exception-baseclass
+.. meta::
+ :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html
+
+hicpp-exception-baseclass
+=========================
+
+The `hicpp-exception-baseclass` check is an alias, please see
+`bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_
+for more information.
\ No newline at end of file
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 5aa1168bd4559..cef75b35c8fc6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -601,6 +601,7 @@ Check aliases
:doc:`hicpp-avoid-goto <hicpp/avoid-goto>`, :doc:`cppcoreguidelines-avoid-goto <cppcoreguidelines/avoid-goto>`,
:doc:`hicpp-braces-around-statements <hicpp/braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes"
:doc:`hicpp-deprecated-headers <hicpp/deprecated-headers>`, :doc:`modernize-deprecated-headers <modernize/deprecated-headers>`, "Yes"
+ :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`,
:doc:`hicpp-explicit-conversions <hicpp/explicit-conversions>`, :doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes"
:doc:`hicpp-function-size <hicpp/function-size>`, :doc:`readability-function-size <readability/function-size>`,
:doc:`hicpp-ignored-remove-result <hicpp/ignored-remove-result>`, :doc:`bugprone-unused-return-value <bugprone/unused-return-value>`,
>From 98f15ac19de1a67c920a6e784324f74deae4a85f Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Fri, 27 Feb 2026 11:39:42 +0900
Subject: [PATCH 4/8] [clang-tidy] Fix RST documentation linter issues
---
.../docs/clang-tidy/checks/hicpp/exception-baseclass.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
index e7e25b0aa4a87..bb570d618093e 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
@@ -1,10 +1,10 @@
.. title:: clang-tidy - hicpp-exception-baseclass
.. meta::
- :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html
+ :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html
hicpp-exception-baseclass
=========================
The `hicpp-exception-baseclass` check is an alias, please see
`bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_
-for more information.
\ No newline at end of file
+for more information.
>From 62248e4726fee9cc4582e5c9abc80b28cd845fb3 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Tue, 3 Mar 2026 12:30:47 +0900
Subject: [PATCH 5/8] [clang-tidy] Add 'Std' prefix to related files and tests
---
.../clang-tidy/bugprone/BugproneTidyModule.cpp | 6 +++---
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 2 +-
...classCheck.cpp => StdExceptionBaseclassCheck.cpp} | 6 +++---
...BaseclassCheck.h => StdExceptionBaseclassCheck.h} | 12 ++++++------
.../clang-tidy/hicpp/HICPPTidyModule.cpp | 4 ++--
...ion-baseclass.rst => std-exception-baseclass.rst} | 6 +++---
.../clang-tidy/checks/hicpp/exception-baseclass.rst | 4 ++--
clang-tools-extra/docs/clang-tidy/checks/list.rst | 4 ++--
...ion-baseclass.cpp => std-exception-baseclass.cpp} | 2 +-
9 files changed, 23 insertions(+), 23 deletions(-)
rename clang-tools-extra/clang-tidy/bugprone/{ExceptionBaseclassCheck.cpp => StdExceptionBaseclassCheck.cpp} (92%)
rename clang-tools-extra/clang-tidy/bugprone/{ExceptionBaseclassCheck.h => StdExceptionBaseclassCheck.h} (66%)
rename clang-tools-extra/docs/clang-tidy/checks/bugprone/{exception-baseclass.rst => std-exception-baseclass.rst} (80%)
rename clang-tools-extra/test/clang-tidy/checkers/bugprone/{exception-baseclass.cpp => std-exception-baseclass.cpp} (99%)
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 45bce2aabbed0..c6a6eac988c1e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -29,7 +29,6 @@
#include "DynamicStaticInitializersCheck.h"
#include "EasilySwappableParametersCheck.h"
#include "EmptyCatchCheck.h"
-#include "ExceptionBaseclassCheck.h"
#include "ExceptionCopyConstructorThrowsCheck.h"
#include "ExceptionEscapeCheck.h"
#include "FloatLoopCounterCheck.h"
@@ -77,6 +76,7 @@
#include "SizeofExpressionCheck.h"
#include "SpuriouslyWakeUpFunctionsCheck.h"
#include "StandaloneEmptyCheck.h"
+#include "StdExceptionBaseclassCheck.h"
#include "StdNamespaceModificationCheck.h"
#include "StringConstructorCheck.h"
#include "StringIntegerAssignmentCheck.h"
@@ -159,8 +159,8 @@ class BugproneModule : public ClangTidyModule {
CheckFactories.registerCheck<EasilySwappableParametersCheck>(
"bugprone-easily-swappable-parameters");
CheckFactories.registerCheck<EmptyCatchCheck>("bugprone-empty-catch");
- CheckFactories.registerCheck<ExceptionBaseclassCheck>(
- "bugprone-exception-baseclass");
+ CheckFactories.registerCheck<StdExceptionBaseclassCheck>(
+ "bugprone-std-exception-baseclass");
CheckFactories.registerCheck<ExceptionCopyConstructorThrowsCheck>(
"bugprone-exception-copy-constructor-throws");
CheckFactories.registerCheck<ExceptionEscapeCheck>(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index e272793b4b21f..f7f185d53b269 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,7 +26,6 @@ add_clang_library(clangTidyBugproneModule STATIC
DynamicStaticInitializersCheck.cpp
EasilySwappableParametersCheck.cpp
EmptyCatchCheck.cpp
- ExceptionBaseclassCheck.cpp
ExceptionCopyConstructorThrowsCheck.cpp
ExceptionEscapeCheck.cpp
FloatLoopCounterCheck.cpp
@@ -40,6 +39,7 @@ add_clang_library(clangTidyBugproneModule STATIC
InvalidEnumDefaultInitializationCheck.cpp
UnintendedCharOstreamOutputCheck.cpp
ReturnConstRefFromParameterCheck.cpp
+ StdExceptionBaseclassCheck.cpp
SuspiciousStringviewDataUsageCheck.cpp
SwitchMissingDefaultCaseCheck.cpp
IncDecInConditionsCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
similarity index 92%
rename from clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp
rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
index 625ed48ef3cf5..24a11dd266f8e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ExceptionBaseclassCheck.h"
+#include "StdExceptionBaseclassCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {
-void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
+void StdExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
cxxThrowExpr(
unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))),
@@ -34,7 +34,7 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
this);
}
-void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) {
+void StdExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) {
const auto *BadThrow = Result.Nodes.getNodeAs<CXXThrowExpr>("bad_throw");
assert(BadThrow && "Did not match the throw expression");
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
similarity index 66%
rename from clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
index d5728b843ec19..717e1b7878546 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
#include "../ClangTidyCheck.h"
@@ -17,10 +17,10 @@ namespace clang::tidy::bugprone {
/// std::exception.
///
/// For the user-facing documentation see:
-/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-baseclass.html
-class ExceptionBaseclassCheck : public ClangTidyCheck {
+/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/std-exception-baseclass.html
+class StdExceptionBaseclassCheck : public ClangTidyCheck {
public:
- ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context)
+ StdExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
@@ -31,4 +31,4 @@ class ExceptionBaseclassCheck : public ClangTidyCheck {
} // namespace clang::tidy::bugprone
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index ab2f84eda560e..00a7b476102dc 100644
--- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -8,7 +8,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
-#include "../bugprone/ExceptionBaseclassCheck.h"
+#include "../bugprone/StdExceptionBaseclassCheck.h"
#include "../bugprone/UndelegatedConstructorCheck.h"
#include "../bugprone/UnusedReturnValueCheck.h"
#include "../bugprone/UseAfterMoveCheck.h"
@@ -56,7 +56,7 @@ class HICPPModule : public ClangTidyModule {
"hicpp-braces-around-statements");
CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>(
"hicpp-deprecated-headers");
- CheckFactories.registerCheck<bugprone::ExceptionBaseclassCheck>(
+ CheckFactories.registerCheck<bugprone::StdExceptionBaseclassCheck>(
"hicpp-exception-baseclass");
CheckFactories.registerCheck<bugprone::UnusedReturnValueCheck>(
"hicpp-ignored-remove-result");
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
similarity index 80%
rename from clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
rename to clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
index 8fd9c6093a3f4..68d13169ebeb5 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - bugprone-exception-baseclass
+.. title:: clang-tidy - bugprone-std-exception-baseclass
-bugprone-exception-baseclass
-============================
+bugprone-std-exception-baseclass
+================================
Ensure that every value that in a ``throw`` expression is an instance of
``std::exception``.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
index bb570d618093e..df92f8407d5d7 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
@@ -1,10 +1,10 @@
.. title:: clang-tidy - hicpp-exception-baseclass
.. meta::
- :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html
+ :http-equiv=refresh: 5;URL=../bugprone/std-exception-baseclass.html
hicpp-exception-baseclass
=========================
The `hicpp-exception-baseclass` check is an alias, please see
-`bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_
+`bugprone-std-exception-baseclass <../bugprone/std-exception-baseclass.html>`_
for more information.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index cef75b35c8fc6..fcde0ea474913 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -99,7 +99,6 @@ Clang-Tidy Checks
:doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`,
:doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`,
:doc:`bugprone-empty-catch <bugprone/empty-catch>`,
- :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`,
:doc:`bugprone-exception-copy-constructor-throws <bugprone/exception-copy-constructor-throws>`,
:doc:`bugprone-exception-escape <bugprone/exception-escape>`,
:doc:`bugprone-float-loop-counter <bugprone/float-loop-counter>`,
@@ -147,6 +146,7 @@ Clang-Tidy Checks
:doc:`bugprone-sizeof-expression <bugprone/sizeof-expression>`,
:doc:`bugprone-spuriously-wake-up-functions <bugprone/spuriously-wake-up-functions>`,
:doc:`bugprone-standalone-empty <bugprone/standalone-empty>`, "Yes"
+ :doc:`bugprone-std-exception-baseclass <bugprone/std-exception-baseclass>`,
:doc:`bugprone-std-namespace-modification <bugprone/std-namespace-modification>`,
:doc:`bugprone-string-constructor <bugprone/string-constructor>`, "Yes"
:doc:`bugprone-string-integer-assignment <bugprone/string-integer-assignment>`, "Yes"
@@ -601,7 +601,7 @@ Check aliases
:doc:`hicpp-avoid-goto <hicpp/avoid-goto>`, :doc:`cppcoreguidelines-avoid-goto <cppcoreguidelines/avoid-goto>`,
:doc:`hicpp-braces-around-statements <hicpp/braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes"
:doc:`hicpp-deprecated-headers <hicpp/deprecated-headers>`, :doc:`modernize-deprecated-headers <modernize/deprecated-headers>`, "Yes"
- :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`,
+ :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-std-exception-baseclass <bugprone/std-exception-baseclass>`,
:doc:`hicpp-explicit-conversions <hicpp/explicit-conversions>`, :doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes"
:doc:`hicpp-function-size <hicpp/function-size>`, :doc:`readability-function-size <readability/function-size>`,
:doc:`hicpp-ignored-remove-result <hicpp/ignored-remove-result>`, :doc:`bugprone-unused-return-value <bugprone/unused-return-value>`,
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp
similarity index 99%
rename from clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp
rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp
index 4bf52936c0b63..56a85f282c0e7 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-exception-baseclass %t -- -- -fcxx-exceptions
+// RUN: %check_clang_tidy %s bugprone-std-exception-baseclass %t -- -- -fcxx-exceptions
namespace std {
class exception {};
>From f5bdd28863f5c3fad0f0952b4efb49ab8e657988 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Tue, 3 Mar 2026 12:41:19 +0900
Subject: [PATCH 6/8] [clang-tidy] Fix header guard
---
.../clang-tidy/bugprone/StdExceptionBaseclassCheck.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
index 717e1b7878546..42e96822b97d8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H
#include "../ClangTidyCheck.h"
@@ -31,4 +31,4 @@ class StdExceptionBaseclassCheck : public ClangTidyCheck {
} // namespace clang::tidy::bugprone
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H
>From d138c5f7cdfdfea83041ecf2ccb4ba623dd2e5b9 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Tue, 3 Mar 2026 13:14:53 +0900
Subject: [PATCH 7/8] [clang-tidy] Add ReleaseNotes.rst
---
clang-tools-extra/docs/ReleaseNotes.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 077335c16c331..6995e02247861 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -163,6 +163,12 @@ New checks
New check aliases
^^^^^^^^^^^^^^^^^
+- Renamed :doc:`hicpp-exception-baseclass
+ <clang-tidy/checks/hicpp/exception-baseclass>`
+ to :doc:`bugprone-std-exception-baseclass
+ <clang-tidy/checks/bugprone/std-exception-baseclass>`.
+ The `hicpp-exception-baseclass` name is kept as an alias.
+
- Renamed :doc:`hicpp-ignored-remove-result
<clang-tidy/checks/hicpp/ignored-remove-result>`
to :doc:`bugprone-unused-return-value
>From 189c9ac3716371048387bfa50d35eb35c33f6b07 Mon Sep 17 00:00:00 2001
From: LeeYoungJoon <dog3hk.dev at gmail.com>
Date: Thu, 5 Mar 2026 13:22:40 +0900
Subject: [PATCH 8/8] [clang-tidy] Address review feedback: add more
description
---
.../clang-tidy/checks/bugprone/std-exception-baseclass.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
index 68d13169ebeb5..9c221813286e5 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
@@ -6,6 +6,11 @@ bugprone-std-exception-baseclass
Ensure that every value that in a ``throw`` expression is an instance of
``std::exception``.
+Exception types should inherit from ``std::exception`` so they can be
+handled consistently and caught as ``std::exception``.
+Exception objects exist to propagate error information
+and must not be created without being thrown.
+
.. code-block:: c++
class custom_exception {};
More information about the cfe-commits
mailing list